diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-03-18 10:54:21 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-03-18 10:54:21 +0100 |
commit | 9e7759638ae59400bcd321db6404962c5f0ba29a (patch) | |
tree | d01dbe463d0b40bd2cac5bd2b07a86da47384d6c | |
parent | 483d8a4ab5b42d38d24deb698f7ac74780e953b6 (diff) | |
download | gcc-9e7759638ae59400bcd321db6404962c5f0ba29a.zip gcc-9e7759638ae59400bcd321db6404962c5f0ba29a.tar.gz gcc-9e7759638ae59400bcd321db6404962c5f0ba29a.tar.bz2 |
re PR libgomp/35625 (schedule(guided) loops forever if ((end - start) % incr) != 0)
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.
From-SVN: r133306
-rw-r--r-- | libgomp/ChangeLog | 7 | ||||
-rw-r--r-- | libgomp/iter.c | 22 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/pr35625.c | 18 |
3 files changed, 36 insertions, 11 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 5440f59..5c54884 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,10 @@ +2008-03-18 Jakub Jelinek <jakub@redhat.com> + + 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. + 2008-03-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * aclocal.m4: Regenerate. diff --git a/libgomp/iter.c b/libgomp/iter.c index 1a8a2a7..2d5dd2e 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)) diff --git a/libgomp/testsuite/libgomp.c/pr35625.c b/libgomp/testsuite/libgomp.c/pr35625.c new file mode 100644 index 0000000..f2978f9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr35625.c @@ -0,0 +1,18 @@ +/* PR libgomp/35625 */ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +int +main (void) +{ +#pragma omp parallel + { + #pragma omp for schedule (guided, 10) + for (int i = 0; i < 1826; i += 10) + ; + #pragma omp for schedule (guided, 10) + for (int i = 0; i > -1826; i -= 10) + ; + } + return 0; +} |