Re: [mpich-discuss] MPI_Init and MPI_COMM_WORLD
Bruce, According to the standard, MPI_COMM_WORLD is a named constant handle which does not change value between MPI_INIT and MPI_FINALIZE. Therefore, I believe your example is OK from the standard perspective. In MPICH, MPI_COMM_WORLD is an integer constant defined at compile-time. I believe in Open MPI the value is defined at link-time, which should still meet the requirements of your example. Ken On 4/13/22, 12:29 PM, "Palmer, Bruce J via discuss" <[email protected]> wrote: Hi, Does MPI_COMM_WORLD exist in any sense before MPI_Init is called? In particular, does this code violate the standard? InitializeMyApp(MPI_Comm comm, int argc, char **argv) { int initialized; MPI_Initialized(&initialized); if (!initialized) MPI_Init(&argc, &argv); /* call some function that uses comm */ } int main(int argc, char **argv) { MPI_Comm comm = MPI_COMM_WORLD; InitializeMyApp(comm, argc, argv); : } My instinct is that this is wrong, but I would like to be sure before I complain about it. It appears to work with some existing implementations, but it looks sketchy to me. Bruce
participants (1)
-
Raffenetti, Ken