MPI::Grequest::Start proposal
Regarding https://svn.mpi-forum.org/trac/mpi-forum-web/wiki/mpi22/GrequestStartFnPtrAr... : 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
participants (1)
-
unknown@example.com