Skip to content

Commit

Permalink
test/mpi/threads/spawn: initialize the thread package
Browse files Browse the repository at this point in the history
th_taskmaster.c uses MTest thread functions for forking and joining threads, but
the thread package is not initialized.  This patch fixes it.

Note that we cannot explicitly use MTest_Init_thread() since the corresponding
MTest_Finalize() prints "No Errors" as many as spawned MPI processes, breaking
this test.
  • Loading branch information
shintaro-iwasaki committed Apr 12, 2020
1 parent db30d4f commit c3561d7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/mpi/threads/spawn/th_taskmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ int main(int argc, char *argv[])
#endif /* USE_THREADS */

#ifdef USE_THREADS
/* Initialize the thread package. It should not be initialized via
* MTest_Init_thread since MTest_Finalize cannot be called. */
MTest_init_thread_pkg();

/* We need different communicators per thread */
for (i = 0; i < DEFAULT_TASK_WINDOW; i++)
CHECK_SUCCESS(MPI_Comm_dup(MPI_COMM_WORLD, &th_comms[i]));
Expand All @@ -117,6 +121,9 @@ int main(int argc, char *argv[])

for (i = 0; i < DEFAULT_TASK_WINDOW; i++)
CHECK_SUCCESS(MPI_Comm_free(&th_comms[i]));

/* Release the thread package. */
MTest_finalize_thread_pkg();
#else
/* Directly spawn a child process to perform each task */
for (i = 0; i < tasks;) {
Expand All @@ -141,6 +148,8 @@ int main(int argc, char *argv[])
}

fn_exit:
/* Do not call MTest_Finalize (and thus MTest_Init) to avoid printing extra
* "No Errors" as many as spawned MPI processes. */
MPI_Finalize();

return 0;
Expand Down

0 comments on commit c3561d7

Please sign in to comment.