From bfe7ac89a0be108eaccfa277db28ed6141a3d5af Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Mon, 24 Aug 2015 11:01:25 +0000 Subject: [PATCH] re PR libgomp/66761 (libgomp: ThreadSanitizer: data race in libgomp) PR libgomp/66761 PR libgomp/67303 * iter.c (gomp_iter_dynamic_next): Employ an atomic load. (gomp_iter_guided_next): Idem. * iter_ull.c (gomp_iter_ull_dynamic_next): Idem. (gomp_iter_ull_guided_next): Idem. * config/linux/wait.h (do_spin): Idem. From-SVN: r227119 --- libgomp/ChangeLog | 10 ++++++++++ libgomp/config/linux/wait.h | 4 +++- libgomp/iter.c | 4 ++-- libgomp/iter_ull.c | 4 ++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 1d265b62e99..bd9111b86a9 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,13 @@ +2015-08-24 Joost VandeVondele + + PR libgomp/66761 + PR libgomp/67303 + * iter.c (gomp_iter_dynamic_next): Employ an atomic load. + (gomp_iter_guided_next): Idem. + * iter_ull.c (gomp_iter_ull_dynamic_next): Idem. + (gomp_iter_ull_guided_next): Idem. + * config/linux/wait.h (do_spin): Idem. + 2015-08-10 Thomas Schwinge * libgomp-plugin.h (enum offload_target_type): Remove diff --git a/libgomp/config/linux/wait.h b/libgomp/config/linux/wait.h index 7f57454a510..e561c2ddf6b 100644 --- a/libgomp/config/linux/wait.h +++ b/libgomp/config/linux/wait.h @@ -49,7 +49,9 @@ static inline int do_spin (int *addr, int val) { unsigned long long i, count = gomp_spin_count_var; - if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0)) + if (__builtin_expect (__atomic_load_n (&gomp_managed_threads, + MEMMODEL_RELAXED) + > gomp_available_cpus, 0)) count = gomp_throttled_spin_count_var; for (i = 0; i < count; i++) if (__builtin_expect (__atomic_load_n (addr, MEMMODEL_RELAXED) != val, 0)) diff --git a/libgomp/iter.c b/libgomp/iter.c index 0ceb41d909e..1def8bde066 100644 --- a/libgomp/iter.c +++ b/libgomp/iter.c @@ -218,7 +218,7 @@ gomp_iter_dynamic_next (long *pstart, long *pend) } } - start = ws->next; + start = __atomic_load_n (&ws->next, MEMMODEL_RELAXED); while (1) { long left = end - start; @@ -301,7 +301,7 @@ gomp_iter_guided_next (long *pstart, long *pend) long start, end, nend, incr; unsigned long chunk_size; - start = ws->next; + start = __atomic_load_n (&ws->next, MEMMODEL_RELAXED); end = ws->end; incr = ws->incr; chunk_size = ws->chunk_size; diff --git a/libgomp/iter_ull.c b/libgomp/iter_ull.c index b1cad84d4c8..1c2d118b631 100644 --- a/libgomp/iter_ull.c +++ b/libgomp/iter_ull.c @@ -219,7 +219,7 @@ gomp_iter_ull_dynamic_next (gomp_ull *pstart, gomp_ull *pend) } } - start = ws->next_ull; + start = __atomic_load_n (&ws->next_ull, MEMMODEL_RELAXED); while (1) { gomp_ull left = end - start; @@ -305,7 +305,7 @@ gomp_iter_ull_guided_next (gomp_ull *pstart, gomp_ull *pend) gomp_ull start, end, nend, incr; gomp_ull chunk_size; - start = ws->next_ull; + start = __atomic_load_n (&ws->next_ull, MEMMODEL_RELAXED); end = ws->end_ull; incr = ws->incr_ull; chunk_size = ws->chunk_size_ull; -- 2.30.2