Mercurial > hg > CbC > CbC_gcc
diff libgomp/iter.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | a06113de4d67 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/libgomp/iter.c Sun Aug 21 07:07:55 2011 +0900 +++ b/libgomp/iter.c Fri Oct 27 22:46:09 2017 +0900 @@ -1,7 +1,8 @@ -/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2005-2017 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. - This file is part of the GNU OpenMP Library (libgomp). + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). Libgomp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,7 +60,7 @@ trip through the outer loop. */ if (ws->chunk_size == 0) { - unsigned long n, q, i; + unsigned long n, q, i, t; unsigned long s0, e0; long s, e; @@ -74,11 +75,14 @@ /* Compute the "zero-based" start and end points. That is, as if the loop began at zero and incremented by one. */ q = n / nthreads; - q += (q * nthreads != n); - s0 = q * i; + t = n % nthreads; + if (i < t) + { + t = 0; + q++; + } + s0 = q * i + t; e0 = s0 + q; - if (e0 > n) - e0 = n; /* Notice when no iterations allocated for this thread. */ if (s0 >= e0) @@ -214,7 +218,7 @@ } } - start = ws->next; + start = __atomic_load_n (&ws->next, MEMMODEL_RELAXED); while (1) { long left = end - start; @@ -297,7 +301,7 @@ 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;