diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-18 09:54:21 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-18 09:54:21 +0000 |
commit | 5205ccb0520a21ad8aae863b91e3d623621490c5 (patch) | |
tree | d01dbe463d0b40bd2cac5bd2b07a86da47384d6c /libgomp/iter.c | |
parent | 8123bff6b151c39b5d55fb3ff7f37e68f7c68409 (diff) | |
download | gcc-5205ccb0520a21ad8aae863b91e3d623621490c5.tar.gz |
PR libgomp/35625
* iter.c (gomp_iter_guided_next_locked): If q > n, set end to ws->end.
(gomp_iter_guided_next): Likewise.
* testsuite/libgomp.c/pr35625.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133306 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/iter.c')
-rw-r--r-- | libgomp/iter.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libgomp/iter.c b/libgomp/iter.c index 1a8a2a7d04f..2d5dd2edd5a 100644 --- a/libgomp/iter.c +++ b/libgomp/iter.c @@ -242,16 +242,16 @@ gomp_iter_guided_next_locked (long *pstart, long *pend) if (ws->next == ws->end) return false; - n = (ws->end - ws->next) / ws->incr; + start = ws->next; + n = (ws->end - start) / ws->incr; q = (n + nthreads - 1) / nthreads; if (q < ws->chunk_size) q = ws->chunk_size; - if (q > n) - q = n; - - start = ws->next; - end = start + q * ws->incr; + if (q <= n) + end = start + q * ws->incr; + else + end = ws->end; ws->next = end; *pstart = start; @@ -286,15 +286,15 @@ gomp_iter_guided_next (long *pstart, long *pend) if (start == end) return false; - n = (end - start) / ws->incr; + n = (end - start) / incr; q = (n + nthreads - 1) / nthreads; if (q < chunk_size) q = chunk_size; - if (q > n) - q = n; - - nend = start + q * incr; + if (__builtin_expect (q <= n, 1)) + nend = start + q * incr; + else + nend = end; tmp = __sync_val_compare_and_swap (&ws->next, start, nend); if (__builtin_expect (tmp == start, 1)) |