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-11-02 16:49:16 +0000 |
commit | 7f7936a0fd18043e6acfe444cef9b44933af6853 (patch) | |
tree | d2dae1be7bb297c1a4680f6b11c4189ac90d7457 /src | |
parent | fbb805450c1509cee2d9270bc8e04ce9165ac4bc (diff) | |
download | ComputeLibrary-7f7936a0fd18043e6acfe444cef9b44933af6853.tar.gz |
COMPMID-959 Fix race condition on info.thread_id in OpenMP scheduler (#399)
Fix from Github
Additionally refactor improper use of OpenMP's worksharing
construct (for).
Change-Id: Ia88b8d8793ba992f8009497aa9ee83b860f2ebb2
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/126266
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Reviewed-by: Pablo Tello <pablo.tello@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/OMP/OMPScheduler.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/runtime/OMP/OMPScheduler.cpp b/src/runtime/OMP/OMPScheduler.cpp index 1dd2511990..3b30f1e56b 100644 --- a/src/runtime/OMP/OMPScheduler.cpp +++ b/src/runtime/OMP/OMPScheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -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); } } } |