Commit 46d23b76 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10689] Updated the comm_split_type test to respect MPI_UNDEFINED.

Reviewed by goodell.
parent 0ff102e3
......@@ -24,15 +24,35 @@ int main(int argc, char *argv[])
verbose = 1;
MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &comm);
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
if (rank == 0 && verbose)
printf("Created subcommunicator of size %d\n", size);
/* Check to see if MPI_COMM_TYPE_SHARED works correctly */
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &comm);
if (comm == MPI_COMM_NULL)
printf("Expected a non-null communicator, but got MPI_COMM_NULL\n");
else {
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
if (rank == 0 && verbose)
printf("Created subcommunicator of size %d\n", size);
MPI_Comm_free(&comm);
}
MPI_Comm_free(&comm);
/* Check to see if MPI_UNDEFINED is respected */
MPI_Comm_split_type(MPI_COMM_WORLD, (wrank % 2 == 0) ? MPI_COMM_TYPE_SHARED : MPI_UNDEFINED,
0, MPI_INFO_NULL, &comm);
if ((wrank % 2) && (comm != MPI_COMM_NULL))
printf("Expected MPI_COMM_NULL, but did not get one\n");
if (wrank % 2 == 0) {
if (comm == MPI_COMM_NULL)
printf("Expected a non-null communicator, but got MPI_COMM_NULL\n");
else {
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
if (rank == 0 && verbose)
printf("Created subcommunicator of size %d\n", size);
MPI_Comm_free(&comm);
}
}
/* Use wrank because Comm_split_type may return more than one communicator
across the job, and if so, each will have a rank 0 entry. Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment