Mercurial > hg > CbC > CbC_gcc
comparison libgomp/iter.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | a06113de4d67 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc. | 1 /* Copyright (C) 2005-2017 Free Software Foundation, Inc. |
2 Contributed by Richard Henderson <rth@redhat.com>. | 2 Contributed by Richard Henderson <rth@redhat.com>. |
3 | 3 |
4 This file is part of the GNU OpenMP Library (libgomp). | 4 This file is part of the GNU Offloading and Multi Processing Library |
5 (libgomp). | |
5 | 6 |
6 Libgomp is free software; you can redistribute it and/or modify it | 7 Libgomp is free software; you can redistribute it and/or modify it |
7 under the terms of the GNU General Public License as published by | 8 under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 3, or (at your option) | 9 the Free Software Foundation; either version 3, or (at your option) |
9 any later version. | 10 any later version. |
57 /* We interpret chunk_size zero as "unspecified", which means that we | 58 /* We interpret chunk_size zero as "unspecified", which means that we |
58 should break up the iterations such that each thread makes only one | 59 should break up the iterations such that each thread makes only one |
59 trip through the outer loop. */ | 60 trip through the outer loop. */ |
60 if (ws->chunk_size == 0) | 61 if (ws->chunk_size == 0) |
61 { | 62 { |
62 unsigned long n, q, i; | 63 unsigned long n, q, i, t; |
63 unsigned long s0, e0; | 64 unsigned long s0, e0; |
64 long s, e; | 65 long s, e; |
65 | 66 |
66 if (thr->ts.static_trip > 0) | 67 if (thr->ts.static_trip > 0) |
67 return 1; | 68 return 1; |
72 i = thr->ts.team_id; | 73 i = thr->ts.team_id; |
73 | 74 |
74 /* Compute the "zero-based" start and end points. That is, as | 75 /* Compute the "zero-based" start and end points. That is, as |
75 if the loop began at zero and incremented by one. */ | 76 if the loop began at zero and incremented by one. */ |
76 q = n / nthreads; | 77 q = n / nthreads; |
77 q += (q * nthreads != n); | 78 t = n % nthreads; |
78 s0 = q * i; | 79 if (i < t) |
80 { | |
81 t = 0; | |
82 q++; | |
83 } | |
84 s0 = q * i + t; | |
79 e0 = s0 + q; | 85 e0 = s0 + q; |
80 if (e0 > n) | |
81 e0 = n; | |
82 | 86 |
83 /* Notice when no iterations allocated for this thread. */ | 87 /* Notice when no iterations allocated for this thread. */ |
84 if (s0 >= e0) | 88 if (s0 >= e0) |
85 { | 89 { |
86 thr->ts.static_trip = 1; | 90 thr->ts.static_trip = 1; |
212 *pend = nend; | 216 *pend = nend; |
213 return true; | 217 return true; |
214 } | 218 } |
215 } | 219 } |
216 | 220 |
217 start = ws->next; | 221 start = __atomic_load_n (&ws->next, MEMMODEL_RELAXED); |
218 while (1) | 222 while (1) |
219 { | 223 { |
220 long left = end - start; | 224 long left = end - start; |
221 long tmp; | 225 long tmp; |
222 | 226 |
295 struct gomp_team *team = thr->ts.team; | 299 struct gomp_team *team = thr->ts.team; |
296 unsigned long nthreads = team ? team->nthreads : 1; | 300 unsigned long nthreads = team ? team->nthreads : 1; |
297 long start, end, nend, incr; | 301 long start, end, nend, incr; |
298 unsigned long chunk_size; | 302 unsigned long chunk_size; |
299 | 303 |
300 start = ws->next; | 304 start = __atomic_load_n (&ws->next, MEMMODEL_RELAXED); |
301 end = ws->end; | 305 end = ws->end; |
302 incr = ws->incr; | 306 incr = ws->incr; |
303 chunk_size = ws->chunk_size; | 307 chunk_size = ws->chunk_size; |
304 | 308 |
305 while (1) | 309 while (1) |