diff options
author | Simone Pellegrini <37897514+simpel01@users.noreply.github.com> | 2018-03-29 11:59:28 +0200 |
---|---|---|
committer | Anthony Barbier <Anthony.barbier@arm.com> | 2018-03-29 10:59:28 +0100 |
commit | bc0bbac5859707be771b5e2ea7295c893fc2d0ff (patch) | |
tree | 40d621c03829297f43843de9874e7e4c5bf2ccee /src | |
parent | 3dd034f2356319ee1cff6bcad5c58ed8611ae26e (diff) | |
download | armcl-bc0bbac5859707be771b5e2ea7295c893fc2d0ff.tar.gz armcl-bc0bbac5859707be771b5e2ea7295c893fc2d0ff.tar.bz2 armcl-bc0bbac5859707be771b5e2ea7295c893fc2d0ff.zip |
Fix race condition on info.thread_id in OpenMP scheduler (#399)
Additionally refactor improper use of OpenMP's worksharing
construct (for).
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/OMP/OMPScheduler.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/runtime/OMP/OMPScheduler.cpp b/src/runtime/OMP/OMPScheduler.cpp index 1dd251199..d68b8af02 100644 --- a/src/runtime/OMP/OMPScheduler.cpp +++ b/src/runtime/OMP/OMPScheduler.cpp @@ -71,15 +71,12 @@ void OMPScheduler::schedule(ICPPKernel *kernel, unsigned int split_dimension) } else { - #pragma omp parallel num_threads(info.num_threads) + #pragma omp parallel private(info) num_threads(info.num_threads) { - #pragma omp for - for(int t = 0; t < info.num_threads; ++t) - { - Window win = max_window.split_window(split_dimension, t, info.num_threads); - info.thread_id = t; - kernel->run(win, info); - } + const int tid = omp_get_thread_num(); + Window win = max_window.split_window(split_dimension, tid, info.num_threads); + info.thread_id = tid; + kernel->run(win, info); } } } |