From 78be3690e79eaa3f4f85c3d02f9ef95b472e5357 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Mon, 24 Aug 2015 12:17:07 +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: r227122 --- 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 2f3ec02055b9..d59d80b47733 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-07-16 Release Manager * GCC 5.2.0 released. diff --git a/libgomp/config/linux/wait.h b/libgomp/config/linux/wait.h index 96d2fbe5f8c3..46a461553535 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 0ceb41d909e2..1def8bde0661 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 b1cad84d4c86..1c2d118b6318 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;