summaryrefslogtreecommitdiffstats
path: root/testpar/testphdf5.c
diff options
context:
space:
mode:
Diffstat (limited to 'testpar/testphdf5.c')
-rw-r--r--testpar/testphdf5.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index 57ef5c9..0b0a67c 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -301,10 +301,15 @@ int
main(int argc, char **argv)
{
int mpi_size, mpi_rank; /* mpi variables */
+ int mpi_code;
H5Ptest_param_t ndsets_params, ngroups_params;
H5Ptest_param_t collngroups_params;
H5Ptest_param_t io_mode_confusion_params;
H5Ptest_param_t rr_obj_flush_confusion_params;
+#ifdef H5_HAVE_TEST_API
+ int required = MPI_THREAD_MULTIPLE;
+ int provided;
+#endif
#ifndef H5_HAVE_WIN32_API
/* Un-buffer the stdout and stderr */
@@ -312,9 +317,37 @@ main(int argc, char **argv)
HDsetbuf(stdout, NULL);
#endif
- MPI_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
- MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+#ifdef H5_HAVE_TEST_API
+ /* Attempt to initialize with MPI_THREAD_MULTIPLE if possible */
+ if (MPI_SUCCESS != (mpi_code = MPI_Init_thread(&argc, &argv, required, &provided))) {
+ printf("MPI_Init_thread failed with error code %d\n", mpi_code);
+ return -1;
+ }
+#else
+ if (MPI_SUCCESS != (mpi_code = MPI_Init(&argc, &argv))) {
+ printf("MPI_Init failed with error code %d\n", mpi_code);
+ return -1;
+ }
+#endif
+
+ if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank))) {
+ printf("MPI_Comm_rank failed with error code %d\n", mpi_code);
+ MPI_Finalize();
+ return -1;
+ }
+
+#ifdef H5_HAVE_TEST_API
+ /* Warn about missing MPI_THREAD_MULTIPLE support */
+ if ((provided < required) && MAINPROCESS)
+ printf("** MPI doesn't support MPI_Init_thread with MPI_THREAD_MULTIPLE **\n");
+#endif
+
+ if (MPI_SUCCESS != (mpi_code = MPI_Comm_size(MPI_COMM_WORLD, &mpi_size))) {
+ if (MAINPROCESS)
+ printf("MPI_Comm_size failed with error code %d\n", mpi_code);
+ MPI_Finalize();
+ return -1;
+ }
mpi_rank_framework_g = mpi_rank;