Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extend MPI_COMM_TYPE_HW_GUIDED test to include MPI_UNDEFINED
Signed-off-by: Joshua Hursey <[email protected]>
  • Loading branch information
jjhursey authored and whit-schonbein committed May 2, 2024
commit 415704269eab0ff6e9aab4e788902d5667b442eb
56 changes: 56 additions & 0 deletions comm_split_type/cmsplit_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ int main(int argc, char *argv[])
MPI_Comm comm;
MPI_Info info;
int ret;
int value = 0;
int expected_value = 3;

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &mcw_rank);
Expand Down Expand Up @@ -181,6 +183,60 @@ int main(int argc, char *argv[])

sync_hr();

/*
* Test MPI_COMM_TYPE_HW_GUIDED:
* - Test with "mpi_hw_resource_type" = "mpi_shared_memory"
* - Mix in some MPI_UNDEFINED values to make sure those are handled properly
*/
expected_value = 3;
if (expected_value > mcw_size) {
expected_value = mcw_size;
}
MPI_Info_create(&info);
MPI_Info_set(info, "mpi_hw_resource_type", "mpi_shared_memory");
if (mcw_rank == 0 && verbose) {
printf("MPI_COMM_TYPE_HW_GUIDED: Trying MPI Standard value %s with some MPI_UNDEFINED\n", "mpi_shared_memory");
}
if (mcw_rank < expected_value) {
ret = MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_HW_GUIDED, 0, info, &comm);
} else {
ret = MPI_Comm_split_type(MPI_COMM_WORLD, MPI_UNDEFINED, 0, info, &comm);
}
if (ret != MPI_SUCCESS) {
printf("MPI_COMM_TYPE_HW_GUIDED (%s) failed\n", split_topo[i]);
errs++;
} else if (comm != MPI_COMM_NULL) {
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
value = 1;
if (rank == 0 && verbose) {
printf("MPI_COMM_TYPE_HW_GUIDED (%s): %d/%d Created shared subcommunicator of size %d\n",
"mpi_shared_memory", mcw_rank, mcw_size, size);
}
MPI_Comm_free(&comm);
} else if (verbose) {
value = 0;
printf("MPI_COMM_TYPE_HW_GUIDED (%s): %d/%d Returned MPI_COMM_NULL\n",
"mpi_shared_memory", mcw_rank, mcw_size);
}
MPI_Info_free(&info);

if (mcw_rank == 0) {
MPI_Reduce(MPI_IN_PLACE, &value, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (expected_value != value) {
printf("MPI_COMM_TYPE_HW_GUIDED (%s): Failed: Verify expected %d == actual %d\n",
"mpi_shared_memory", expected_value, value);
} else if (verbose) {
printf("MPI_COMM_TYPE_HW_GUIDED (%s): Passed: Verify expected %d == actual %d\n",
"mpi_shared_memory", expected_value, value);
}
} else {
MPI_Reduce(&value, NULL, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);

sync_hr();

/*
* Test MPI_COMM_TYPE_HW_GUIDED:
* - info with correct key, but different values a different ranks, it must throw an error
Expand Down