summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2023-10-28 04:18:24 (GMT)
committerGitHub <noreply@github.com>2023-10-28 04:18:24 (GMT)
commit1bcef50b864fb1ea6e00900b3982e71d183cfda5 (patch)
tree4f88bd92088de8e0def6b93e6419c5307076ed0d /test
parent119e694f971470b26876d227ceedbaab36eef275 (diff)
downloadhdf5-1bcef50b864fb1ea6e00900b3982e71d183cfda5.zip
hdf5-1bcef50b864fb1ea6e00900b3982e71d183cfda5.tar.gz
hdf5-1bcef50b864fb1ea6e00900b3982e71d183cfda5.tar.bz2
Print some messages in parallel tests on MPI rank 0 only (#3785)
Avoids overly verbose output from all processes emitting progress, etc. info.
Diffstat (limited to 'test')
-rw-r--r--test/h5test.c28
-rw-r--r--test/testframe.c84
2 files changed, 64 insertions, 48 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 5348e1b..3046375 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -864,22 +864,23 @@ h5_show_hostname(void)
WSADATA wsaData;
int err;
#endif
+#ifdef H5_HAVE_PARALLEL
+ int mpi_rank, mpi_initialized, mpi_finalized;
+#endif
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_PARALLEL
- {
- int mpi_rank, mpi_initialized, mpi_finalized;
-
- MPI_Initialized(&mpi_initialized);
- MPI_Finalized(&mpi_finalized);
+ MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
- if (mpi_initialized && !mpi_finalized) {
- MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
- printf("MPI-process %d.", mpi_rank);
- }
- else
- printf("thread 0.");
+ if (mpi_initialized && !mpi_finalized) {
+ /* Prevent output here from getting mixed with later output */
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ printf("MPI-process %d.", mpi_rank);
}
+ else
+ printf("thread 0.");
#else
printf("thread %" PRIu64 ".", H5TS_thread_id());
#endif
@@ -915,6 +916,11 @@ h5_show_hostname(void)
#ifdef H5_HAVE_WIN32_API
WSACleanup();
#endif
+#ifdef H5_HAVE_PARALLEL
+ /* Prevent output here from getting mixed with later output */
+ if (mpi_initialized && !mpi_finalized)
+ MPI_Barrier(MPI_COMM_WORLD);
+#endif
}
#ifdef H5_HAVE_PARALLEL
diff --git a/test/testframe.c b/test/testframe.c
index 2b65027..5cb25ed 100644
--- a/test/testframe.c
+++ b/test/testframe.c
@@ -155,35 +155,37 @@ TestUsage(void)
{
unsigned i;
- print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", TestProgName,
- (TestPrivateUsage ? "<extra options>" : ""));
- print_func(" [-[e]x[clude] name]+ \n");
- print_func(" [-o[nly] name]+ \n");
- print_func(" [-b[egin] name] \n");
- print_func(" [-s[ummary]] \n");
- print_func(" [-c[leanoff]] \n");
- print_func(" [-h[elp]] \n");
- print_func("\n\n");
- print_func("verbose controls the amount of information displayed\n");
- print_func("exclude to exclude tests by name\n");
- print_func("only to name tests which should be run\n");
- print_func("begin start at the name of the test given\n");
- print_func("summary prints a summary of test results at the end\n");
- print_func("cleanoff does not delete *.hdf files after execution of tests\n");
- print_func("help print out this information\n");
- if (TestPrivateUsage) {
- print_func("\nExtra options\n");
- TestPrivateUsage();
- }
- print_func("\n\n");
- print_func("This program currently tests the following: \n\n");
- print_func("%16s %s\n", "Name", "Description");
- print_func("%16s %s\n", "----", "-----------");
+ if (mpi_rank_framework_g == 0) {
+ print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", TestProgName,
+ (TestPrivateUsage ? "<extra options>" : ""));
+ print_func(" [-[e]x[clude] name]+ \n");
+ print_func(" [-o[nly] name]+ \n");
+ print_func(" [-b[egin] name] \n");
+ print_func(" [-s[ummary]] \n");
+ print_func(" [-c[leanoff]] \n");
+ print_func(" [-h[elp]] \n");
+ print_func("\n\n");
+ print_func("verbose controls the amount of information displayed\n");
+ print_func("exclude to exclude tests by name\n");
+ print_func("only to name tests which should be run\n");
+ print_func("begin start at the name of the test given\n");
+ print_func("summary prints a summary of test results at the end\n");
+ print_func("cleanoff does not delete *.hdf files after execution of tests\n");
+ print_func("help print out this information\n");
+ if (TestPrivateUsage) {
+ print_func("\nExtra options\n");
+ TestPrivateUsage();
+ }
+ print_func("\n\n");
+ print_func("This program currently tests the following: \n\n");
+ print_func("%16s %s\n", "Name", "Description");
+ print_func("%16s %s\n", "----", "-----------");
- for (i = 0; i < Index; i++)
- print_func("%16s %s\n", Test[i].Name, Test[i].Description);
+ for (i = 0; i < Index; i++)
+ print_func("%16s %s\n", Test[i].Name, Test[i].Description);
- print_func("\n\n");
+ print_func("\n\n");
+ }
}
/*
@@ -192,12 +194,14 @@ TestUsage(void)
void
TestInfo(const char *ProgName)
{
- unsigned major, minor, release;
+ if (mpi_rank_framework_g == 0) {
+ unsigned major, minor, release;
- H5get_libversion(&major, &minor, &release);
+ H5get_libversion(&major, &minor, &release);
- print_func("\nFor help use: %s -help\n", ProgName);
- print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
+ print_func("\nFor help use: %s -help\n", ProgName);
+ print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
+ }
}
/*
@@ -301,20 +305,24 @@ PerformTests(void)
for (Loop = 0; Loop < Index; Loop++)
if (Test[Loop].SkipFlag) {
- MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
+ if (mpi_rank_framework_g == 0)
+ MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
}
else {
if (mpi_rank_framework_g == 0)
MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
- MESSAGE(5, ("===============================================\n"));
+ if (mpi_rank_framework_g == 0)
+ MESSAGE(5, ("===============================================\n"));
Test[Loop].NumErrors = num_errs;
Test_parameters = Test[Loop].Parameters;
TestAlarmOn();
Test[Loop].Call();
TestAlarmOff();
Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
- MESSAGE(5, ("===============================================\n"));
- MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
+ if (mpi_rank_framework_g == 0) {
+ MESSAGE(5, ("===============================================\n"));
+ MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
+ }
}
Test_parameters = NULL; /* clear it. */
@@ -358,7 +366,8 @@ TestCleanup(void)
{
unsigned Loop;
- MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
+ if (mpi_rank_framework_g == 0)
+ MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
/* call individual cleanup routines in each source module */
for (Loop = 0; Loop < Index; Loop++)
@@ -619,7 +628,8 @@ SetTest(const char *testname, int action)
break;
default:
/* error */
- printf("*** ERROR: Unknown action (%d) for SetTest\n", action);
+ if (mpi_rank_framework_g == 0)
+ printf("*** ERROR: Unknown action (%d) for SetTest\n", action);
break;
}
}