[Mpi-22] MPI::Grequest::Start proposal

Jeff Squyres jsquyres at [hidden]
Thu Sep 4 01:26:23 CDT 2008



Regarding https://svn.mpi-forum.org/trac/mpi-forum-web/wiki/mpi22/GrequestStartFnPtrArgs 
:

I have confirmed in Open MPI that if you change this:

     static Grequest Start(Query_function, Free_function,
            Cancel_function, void *);

to

     static Grequest Start(Query_function *, Free_function *,
            Cancel_function *, void *);

Recompile and reinstall, both the implementation and same C++ user  
code compiles without warning/error.

Erez raised the point that this would change the type of any  
implementation and user-declared variables that hold the function  
pointer.  It does not; such a variable type must always be  
(Free_function*); it's only the type that is passed through a function  
argument that can be either (Free_function) or (Free_function*).   
Someone smarter than me in C++ can explain why.  :-)

Specifically, the following compiles and runs without warning/error:

-----
#include <stdio.h>
typedef int Free_function(void *);

int my_function(void*) {
     printf("In my_function\n");
     return 0;
}

void foo1(Free_function ptr) {
     Free_function *save = ptr;
     save(0);
}
void foo2(Free_function* ptr) {
     Free_function *save = ptr;
     save(0);
}
int main (int argc, char*argv[]) {
     foo1(my_function);
     foo2(my_function);
     return 0;
}
-----

I tried 4 different C++ compilers (gnu, intel, pgi, pathscale):

-----
[23:19] svbu-mpi:~/tmp % g++ foo.cc -o foo && ./foo
In my_function
In my_function
[23:21] svbu-mpi:~/tmp % icpc foo.cc -o foo && ./foo
In my_function
In my_function
[23:21] svbu-mpi:~/tmp % pgCC foo.cc -o foo && ./foo
In my_function
In my_function
[23:22] svbu-mpi:~/tmp % pathCC foo.cc -o foo && ./foo
In my_function
In my_function
[23:22] svbu-mpi:~/tmp %
------

So I think the proposal stands as it is written.


-- 
Jeff Squyres
Cisco Systems




More information about the Mpi-22 mailing list