* Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings)
@ 2015-08-22 11:15 VandeVondele Joost
2015-08-24 9:07 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: VandeVondele Joost @ 2015-08-22 11:15 UTC (permalink / raw)
To: gcc-patches; +Cc: pinskia, jakub
[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]
The following fixes two warnings reported by tsan when running OMP'ed code. As suggested by Andrew Pinski in PR67303 for gomp_iter_guided_next, by employing a relaxed atomic load. The same pattern occurred a couple of more times, so fixed as well. I used the same approach for the warning in do_spin (PR66761), even though this is a different context.
Bootstrapped and regtested on x86_64-unknown-linux-gnu for trunk, and manually verified that the PR is fixed using a tsan compiled libgomp based on gcc-5.1.
OK for trunk ?
This applies without changes to the 5 branch, should I commit there as well ?
libgomp/ChangeLog:
2015-08-22 Joost VandeVondele <vondele@gnu.gcc.org>
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-tsan-libgomp-v01.diff --]
[-- Type: text/x-patch; name="patch-tsan-libgomp-v01.diff", Size: 1984 bytes --]
Index: libgomp/iter.c
===================================================================
--- libgomp/iter.c (revision 227094)
+++ libgomp/iter.c (working copy)
@@ -218,7 +218,7 @@ gomp_iter_dynamic_next (long *pstart, lo
}
}
- 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, lon
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;
Index: libgomp/iter_ull.c
===================================================================
--- libgomp/iter_ull.c (revision 227094)
+++ libgomp/iter_ull.c (working copy)
@@ -219,7 +219,7 @@ gomp_iter_ull_dynamic_next (gomp_ull *ps
}
}
- 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 *pst
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;
Index: libgomp/config/linux/wait.h
===================================================================
--- libgomp/config/linux/wait.h (revision 227094)
+++ libgomp/config/linux/wait.h (working copy)
@@ -49,7 +49,8 @@ static inline int do_spin (int *addr, in
{
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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings)
2015-08-22 11:15 Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings) VandeVondele Joost
@ 2015-08-24 9:07 ` Jakub Jelinek
2015-08-24 11:12 ` VandeVondele Joost
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2015-08-24 9:07 UTC (permalink / raw)
To: VandeVondele Joost; +Cc: gcc-patches, pinskia, jakub
On Sat, Aug 22, 2015 at 10:36:45AM +0000, VandeVondele Joost wrote:
> OK for trunk ?
> This applies without changes to the 5 branch, should I commit there as well ?
Ok, with a small change:
> 2015-08-22 Joost VandeVondele <vondele@gnu.gcc.org>
>
> 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.
> --- libgomp/config/linux/wait.h (revision 227094)
> +++ libgomp/config/linux/wait.h (working copy)
> @@ -49,7 +49,8 @@ static inline int do_spin (int *addr, in
> {
> 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))
Please fix up formatting here, MEMMODEL_RELAXED should be below
&gomp_managed_threads and most likely > will need to be below
__atomic_load_n.
> count = gomp_throttled_spin_count_var;
> for (i = 0; i < count; i++)
> if (__builtin_expect (__atomic_load_n (addr, MEMMODEL_RELAXED) != val, 0))
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings)
2015-08-24 9:07 ` Jakub Jelinek
@ 2015-08-24 11:12 ` VandeVondele Joost
2015-08-24 11:44 ` Jakub Jelinek
0 siblings, 1 reply; 4+ messages in thread
From: VandeVondele Joost @ 2015-08-24 11:12 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, pinskia, jakub
Thanks, committed to trunk r227119 with the format fix. Do you want this on the 5 branch as well ?
Joost
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings)
2015-08-24 11:12 ` VandeVondele Joost
@ 2015-08-24 11:44 ` Jakub Jelinek
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2015-08-24 11:44 UTC (permalink / raw)
To: VandeVondele Joost; +Cc: gcc-patches, pinskia, jakub
On Mon, Aug 24, 2015 at 11:04:54AM +0000, VandeVondele Joost wrote:
> Thanks, committed to trunk r227119 with the format fix. Do you want this on the 5 branch as well ?
It is ok for 5 branch too.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-24 11:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-22 11:15 Fix PR libgomp/66761 and PR libgomp/67303 (tsan warnings) VandeVondele Joost
2015-08-24 9:07 ` Jakub Jelinek
2015-08-24 11:12 ` VandeVondele Joost
2015-08-24 11:44 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).