From 9e5aefc5f93a0cdb00c89830e3cfaf5a706340c4 Mon Sep 17 00:00:00 2001 From: Joachim Protze Date: Sun, 14 Jun 2020 16:10:10 +0200 Subject: [PATCH] [OpenMP][Tests] fix data race in an OpenMP runtime test Reviewed by: AndreyChurbanov Differential Revision: https://reviews.llvm.org/D81804 --- openmp/runtime/test/tasking/omp_fill_taskqueue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openmp/runtime/test/tasking/omp_fill_taskqueue.c b/openmp/runtime/test/tasking/omp_fill_taskqueue.c index 17e1de380bcb..24090a2f83bd 100644 --- a/openmp/runtime/test/tasking/omp_fill_taskqueue.c +++ b/openmp/runtime/test/tasking/omp_fill_taskqueue.c @@ -47,10 +47,14 @@ int main() // all tasks, and detect the test failure if it has not been done yet. if (failed < 0) failed = throttling ? enqueued == NUM_TASKS : enqueued < NUM_TASKS; +#pragma omp atomic write block = 0; } - while (block) - ; + int wait = 0; + do { +#pragma omp atomic read + wait = block; + } while (wait); } } block = 0;