Skip to content

Commit

Permalink
sessions: save a place for the world
Browse files Browse the repository at this point in the history
more complex test cases for sessions and world model showed
a problem when creating sessions before calling mpi_init.

This patch addresses this problem.

Related to PR open-mpi#9097

Signed-off-by: Howard Pritchard <[email protected]>
  • Loading branch information
hppritcha committed Mar 15, 2022
1 parent 35a967a commit 4848109
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ int ompi_comm_init(void)
OBJ_RETAIN( &ompi_mpi_errors_are_fatal.eh );
opal_pointer_array_set_item (&ompi_mpi_communicators, 2, &ompi_mpi_comm_null);

/*
* first three places in ompi_mpi_communicators are reserved for
* MPI world model communicators MPI_COMM_WORLD, MPI_COMM_SELF, in addition to
* MPI_COMM_NULL which is needed both for world and sessions models.
* We conditionally insert ompi_mpi_comm_null into slots 0 and 1. If MPI_Init was
* already called then these two slots are already occupied. If
* MPI_Init is called after one or more MPI_Session_init, then
* slots 0 and 1 will be filled in with MPI_COMM_WORLD and MPI_COMM_SELF.
*/
(void)opal_pointer_array_test_and_set_item(&ompi_mpi_communicators, 0, &ompi_mpi_comm_null);
(void)opal_pointer_array_test_and_set_item(&ompi_mpi_communicators, 1, &ompi_mpi_comm_null);

opal_string_copy(ompi_mpi_comm_null.comm.c_name, "MPI_COMM_NULL",
sizeof(ompi_mpi_comm_null.comm.c_name));
ompi_mpi_comm_null.comm.c_flags |= OMPI_COMM_NAMEISSET | OMPI_COMM_INTRINSIC |
Expand Down

0 comments on commit 4848109

Please sign in to comment.