Skip to content

Commit

Permalink
test/mpi/threads: insert MTest_thread_yield() in busy loops
Browse files Browse the repository at this point in the history
This patch adds MTest_thread_yield() to tests that I missed in
pmodels#4421.

Note this does not affect the program behavior if OS-level threads (Pthreads)
are used because MTest_thread_yield() is mapped to no-op.
  • Loading branch information
shintaro-iwasaki committed May 15, 2020
1 parent e200df5 commit ddd98ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/mpi/threads/pt2pt/greq_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ int main(int argc, char *argv[])
flag = 0;
while (!flag) {
MPI_Test(&request, &flag, &status);
MTest_thread_yield();
}
MTest_Join_threads();

Expand All @@ -102,6 +103,7 @@ int main(int argc, char *argv[])
outcount = 0;
while (!outcount) {
MPI_Testsome(1, &request, &outcount, indices, &status);
MTest_thread_yield();
}
MTest_Join_threads();

Expand All @@ -112,6 +114,7 @@ int main(int argc, char *argv[])
flag = 0;
while (!flag) {
MPI_Testall(1, &request, &flag, &status);
MTest_thread_yield();
}
MTest_Join_threads();

Expand Down
3 changes: 2 additions & 1 deletion test/mpi/threads/pt2pt/threaded_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ int main(int argc, char *argv[])
}

/* Loop until the send flag is set */
while (sendok == -1);
while (sendok == -1)
MTest_thread_yield();
if (!sendok) {
errs++;
}
Expand Down

0 comments on commit ddd98ef

Please sign in to comment.