diff options
author | Andrey Churbanov <Andrey.Churbanov@intel.com> | 2015-04-02 13:18:50 +0000 |
---|---|---|
committer | Andrey Churbanov <Andrey.Churbanov@intel.com> | 2015-04-02 13:18:50 +0000 |
commit | 1362ae750fbd9cbf32e23a56852a5d116720182d (patch) | |
tree | 4dd36b6c183a10c5967e5f0d80fee4104e7e00e3 /openmp/runtime/src | |
parent | 8bf6b3eaf76ac17db38d9f757395043bf8b16bdc (diff) | |
download | bcm5719-llvm-1362ae750fbd9cbf32e23a56852a5d116720182d.tar.gz bcm5719-llvm-1362ae750fbd9cbf32e23a56852a5d116720182d.zip |
Eliminated the write to depth field of the machine_hierarchy data structure in __kmp_get_hierarchy(), thus fixing race condition. Now local variable used by each thread.
llvm-svn: 233914
Diffstat (limited to 'openmp/runtime/src')
-rw-r--r-- | openmp/runtime/src/kmp_affinity.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index 9a9b4d278c5..2a4b9629b84 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -323,7 +323,6 @@ public: number of levels along the longest path from root to any leaf. It corresponds to the number of entries in numPerLevel if we exclude all but one trailing 1. */ kmp_uint32 depth; - kmp_uint32 base_depth; kmp_uint32 base_num_threads; bool uninitialized; @@ -395,24 +394,23 @@ public: for (kmp_uint32 i=1; i<depth; ++i) skipPerLevel[i] = numPerLevel[i-1] * skipPerLevel[i-1]; - base_depth = depth; } }; static hierarchy_info machine_hierarchy; void __kmp_get_hierarchy(kmp_uint32 nproc, kmp_bstate_t *thr_bar) { + kmp_uint32 depth; if (machine_hierarchy.uninitialized) machine_hierarchy.init(NULL, nproc); - if (nproc <= machine_hierarchy.base_num_threads) - machine_hierarchy.depth = machine_hierarchy.base_depth; - KMP_DEBUG_ASSERT(machine_hierarchy.depth > 0); - while (nproc > machine_hierarchy.skipPerLevel[machine_hierarchy.depth-1]) { - machine_hierarchy.depth++; - machine_hierarchy.skipPerLevel[machine_hierarchy.depth-1] = 2*machine_hierarchy.skipPerLevel[machine_hierarchy.depth-2]; + depth = machine_hierarchy.depth; + KMP_DEBUG_ASSERT(depth > 0); + while (nproc > machine_hierarchy.skipPerLevel[depth-1]) { + depth++; + machine_hierarchy.skipPerLevel[depth-1] = 2*machine_hierarchy.skipPerLevel[depth-2]; } - thr_bar->depth = machine_hierarchy.depth; + thr_bar->depth = depth; thr_bar->base_leaf_kids = (kmp_uint8)machine_hierarchy.numPerLevel[0]-1; thr_bar->skip_per_level = machine_hierarchy.skipPerLevel; } |