diff options
Diffstat (limited to 'testpar/API/H5_api_test_parallel.c')
-rw-r--r-- | testpar/API/H5_api_test_parallel.c | 147 |
1 files changed, 135 insertions, 12 deletions
diff --git a/testpar/API/H5_api_test_parallel.c b/testpar/API/H5_api_test_parallel.c index 45fa4ec..ad0fdca 100644 --- a/testpar/API/H5_api_test_parallel.c +++ b/testpar/API/H5_api_test_parallel.c @@ -172,14 +172,34 @@ error: int main(int argc, char **argv) { + const char *vol_connector_string; const char *vol_connector_name; unsigned seed; - hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t default_con_id = H5I_INVALID_HID; + hid_t registered_con_id = H5I_INVALID_HID; + char *vol_connector_string_copy = NULL; + char *vol_connector_info = NULL; + int required = MPI_THREAD_MULTIPLE; + int provided; + + /* + * Attempt to initialize with MPI_THREAD_MULTIPLE for VOL connectors + * that require that level of threading support in MPI + */ + if (MPI_SUCCESS != MPI_Init_thread(&argc, &argv, required, &provided)) { + HDfprintf(stderr, "MPI_Init_thread failed\n"); + HDexit(EXIT_FAILURE); + } - MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + if (provided < required) { + if (MAINPROCESS) + HDprintf("** INFO: couldn't initialize with MPI_THREAD_MULTIPLE threading support **\n"); + } + /* Simple argument checking, TODO can improve that later */ if (argc > 1) { enum H5_api_test_type i = H5_api_test_name_to_type(argv[1]); @@ -209,7 +229,7 @@ main(int argc, char **argv) if (mpi_size > 1) { if (MPI_SUCCESS != MPI_Bcast(&seed, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD)) { if (MAINPROCESS) - HDprintf("Couldn't broadcast test seed\n"); + HDfprintf(stderr, "Couldn't broadcast test seed\n"); goto error; } } @@ -222,14 +242,45 @@ main(int argc, char **argv) HDsnprintf(H5_api_test_parallel_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, PARALLEL_TEST_FILE_NAME); - if (NULL == (vol_connector_name = HDgetenv(HDF5_VOL_CONNECTOR))) { + if (NULL == (vol_connector_string = HDgetenv(HDF5_VOL_CONNECTOR))) { if (MAINPROCESS) HDprintf("No VOL connector selected; using native VOL connector\n"); vol_connector_name = "native"; + vol_connector_info = NULL; + } + else { + char *token = NULL; + + BEGIN_INDEPENDENT_OP(copy_connector_string) + { + if (NULL == (vol_connector_string_copy = HDstrdup(vol_connector_string))) { + if (MAINPROCESS) + HDfprintf(stderr, "Unable to copy VOL connector string\n"); + INDEPENDENT_OP_ERROR(copy_connector_string); + } + } + END_INDEPENDENT_OP(copy_connector_string); + + BEGIN_INDEPENDENT_OP(get_connector_name) + { + if (NULL == (token = HDstrtok(vol_connector_string_copy, " "))) { + if (MAINPROCESS) + HDfprintf(stderr, "Error while parsing VOL connector string\n"); + INDEPENDENT_OP_ERROR(get_connector_name); + } + } + END_INDEPENDENT_OP(get_connector_name); + + vol_connector_name = token; + + if (NULL != (token = HDstrtok(NULL, " "))) { + vol_connector_info = token; + } } if (MAINPROCESS) { - HDprintf("Running parallel API tests with VOL connector '%s'\n\n", vol_connector_name); + HDprintf("Running parallel API tests with VOL connector '%s' and info string '%s'\n\n", + vol_connector_name, vol_connector_info ? vol_connector_info : ""); HDprintf("Test parameters:\n"); HDprintf(" - Test file name: '%s'\n", H5_api_test_parallel_filename); HDprintf(" - Number of MPI ranks: %d\n", mpi_size); @@ -237,17 +288,74 @@ main(int argc, char **argv) HDprintf("\n\n"); } - /* Retrieve the VOL cap flags - work around an HDF5 - * library issue by creating a FAPL - */ - BEGIN_INDEPENDENT_OP(get_capability_flags) + BEGIN_INDEPENDENT_OP(create_fapl) { if ((fapl_id = create_mpi_fapl(MPI_COMM_WORLD, MPI_INFO_NULL, FALSE)) < 0) { if (MAINPROCESS) HDfprintf(stderr, "Unable to create FAPL\n"); - INDEPENDENT_OP_ERROR(get_capability_flags); + INDEPENDENT_OP_ERROR(create_fapl); } + } + END_INDEPENDENT_OP(create_fapl); + BEGIN_INDEPENDENT_OP(check_vol_register) + { + /* + * If using a VOL connector other than the native + * connector, check whether the VOL connector was + * successfully registered before running the tests. + * Otherwise, HDF5 will default to running the tests + * with the native connector, which could be misleading. + */ + if (0 != HDstrcmp(vol_connector_name, "native")) { + htri_t is_registered; + + if ((is_registered = H5VLis_connector_registered_by_name(vol_connector_name)) < 0) { + if (MAINPROCESS) + HDfprintf(stderr, "Unable to determine if VOL connector is registered\n"); + INDEPENDENT_OP_ERROR(check_vol_register); + } + + if (!is_registered) { + if (MAINPROCESS) + HDfprintf(stderr, "Specified VOL connector '%s' wasn't correctly registered!\n", + vol_connector_name); + INDEPENDENT_OP_ERROR(check_vol_register); + } + else { + /* + * If the connector was successfully registered, check that + * the connector ID set on the default FAPL matches the ID + * for the registered connector before running the tests. + */ + if (H5Pget_vol_id(fapl_id, &default_con_id) < 0) { + if (MAINPROCESS) + HDfprintf(stderr, "Couldn't retrieve ID of VOL connector set on default FAPL\n"); + INDEPENDENT_OP_ERROR(check_vol_register); + } + + if ((registered_con_id = H5VLget_connector_id_by_name(vol_connector_name)) < 0) { + if (MAINPROCESS) + HDfprintf(stderr, "Couldn't retrieve ID of registered VOL connector\n"); + INDEPENDENT_OP_ERROR(check_vol_register); + } + + if (default_con_id != registered_con_id) { + if (MAINPROCESS) + HDfprintf(stderr, + "VOL connector set on default FAPL didn't match specified VOL connector\n"); + INDEPENDENT_OP_ERROR(check_vol_register); + } + } + } + } + END_INDEPENDENT_OP(check_vol_register); + + /* Retrieve the VOL cap flags - work around an HDF5 + * library issue by creating a FAPL + */ + BEGIN_INDEPENDENT_OP(get_capability_flags) + { vol_cap_flags_g = H5VL_CAP_FLAG_NONE; if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { if (MAINPROCESS) @@ -265,7 +373,8 @@ main(int argc, char **argv) { if (MAINPROCESS) { if (create_test_container(H5_api_test_parallel_filename, vol_cap_flags_g) < 0) { - HDprintf(" failed to create testing container file '%s'\n", H5_api_test_parallel_filename); + HDfprintf(stderr, " failed to create testing container file '%s'\n", + H5_api_test_parallel_filename); INDEPENDENT_OP_ERROR(create_test_container); } } @@ -314,9 +423,19 @@ main(int argc, char **argv) } } + if (default_con_id >= 0 && H5VLclose(default_con_id) < 0) { + if (MAINPROCESS) + HDfprintf(stderr, " failed to close VOL connector ID\n"); + } + + if (registered_con_id >= 0 && H5VLclose(registered_con_id) < 0) { + if (MAINPROCESS) + HDfprintf(stderr, " failed to close VOL connector ID\n"); + } + if (fapl_id >= 0 && H5Pclose(fapl_id) < 0) { if (MAINPROCESS) - HDprintf(" failed to close MPI FAPL\n"); + HDfprintf(stderr, " failed to close MPI FAPL\n"); } H5close(); @@ -326,8 +445,12 @@ main(int argc, char **argv) HDexit(EXIT_SUCCESS); error: + HDfree(vol_connector_string_copy); + H5E_BEGIN_TRY { + H5VLclose(default_con_id); + H5VLclose(registered_con_id); H5Pclose(fapl_id); } H5E_END_TRY; |