aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-06-22 22:39:25 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-06-22 22:39:25 +0200
commitfb79f500af1b4d9ee5685e8934726b5e2ea4edd5 (patch)
treec2cc34ab7a462c76b41fcd457b365ba285e84685 /libgomp
parent4fb489e7968448aaa9321d863660530a81d06f4c (diff)
downloadgcc-fb79f500af1b4d9ee5685e8934726b5e2ea4edd5.zip
gcc-fb79f500af1b4d9ee5685e8934726b5e2ea4edd5.tar.gz
gcc-fb79f500af1b4d9ee5685e8934726b5e2ea4edd5.tar.bz2
re PR libgomp/49490 (suboptimal load balancing in loops)
PR libgomp/49490 * omp-low.c (expand_omp_for_static_nochunk): Only use n ceil/ nthreads size for the first n % nthreads threads in the team instead of all threads except for the last few ones which get less work or none at all. * iter.c (gomp_iter_static_next): For chunk size 0 only use n ceil/ nthreads size for the first n % nthreads threads in the team instead of all threads except for the last few ones which get less work or none at all. * iter_ull.c (gomp_iter_ull_static_next): Likewise. * env.c (parse_schedule): If OMP_SCHEDULE doesn't have chunk argument, set run_sched_modifier to 0 for static resp. 1 for other kinds. If chunk argument is 0 and not static, set value to 1. From-SVN: r175315
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog14
-rw-r--r--libgomp/env.c10
-rw-r--r--libgomp/iter.c15
-rw-r--r--libgomp/iter_ull.c15
4 files changed, 40 insertions, 14 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 7d3fe22..1d93273 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,17 @@
+2011-06-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/49490
+ * iter.c (gomp_iter_static_next): For chunk size 0
+ only use n ceil/ nthreads size for the first
+ n % nthreads threads in the team instead of
+ all threads except for the last few ones which
+ get less work or none at all.
+ * iter_ull.c (gomp_iter_ull_static_next): Likewise.
+ * env.c (parse_schedule): If OMP_SCHEDULE doesn't have
+ chunk argument, set run_sched_modifier to 0 for static
+ resp. 1 for other kinds. If chunk argument is 0
+ and not static, set value to 1.
+
2011-05-19 Jakub Jelinek <jakub@redhat.com>
PR c++/49043
diff --git a/libgomp/env.c b/libgomp/env.c
index 92fa8c3..0ca9a1c 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+/* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
@@ -108,7 +108,11 @@ parse_schedule (void)
while (isspace ((unsigned char) *env))
++env;
if (*env == '\0')
- return;
+ {
+ gomp_global_icv.run_sched_modifier
+ = gomp_global_icv.run_sched_var != GFS_STATIC;
+ return;
+ }
if (*env++ != ',')
goto unknown;
while (isspace ((unsigned char) *env))
@@ -129,6 +133,8 @@ parse_schedule (void)
if ((int)value != value)
goto invalid;
+ if (value == 0 && gomp_global_icv.run_sched_var != GFS_STATIC)
+ value = 1;
gomp_global_icv.run_sched_modifier = value;
return;
diff --git a/libgomp/iter.c b/libgomp/iter.c
index 9ec4dbd..cd9484a 100644
--- a/libgomp/iter.c
+++ b/libgomp/iter.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2008, 2009, 2011 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -59,7 +59,7 @@ gomp_iter_static_next (long *pstart, long *pend)
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 +74,14 @@ gomp_iter_static_next (long *pstart, long *pend)
/* 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)
diff --git a/libgomp/iter_ull.c b/libgomp/iter_ull.c
index 1754e63..a393920 100644
--- a/libgomp/iter_ull.c
+++ b/libgomp/iter_ull.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2008, 2009, 2011 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -60,7 +60,7 @@ gomp_iter_ull_static_next (gomp_ull *pstart, gomp_ull *pend)
trip through the outer loop. */
if (ws->chunk_size_ull == 0)
{
- gomp_ull n, q, i, s0, e0, s, e;
+ gomp_ull n, q, i, t, s0, e0, s, e;
if (thr->ts.static_trip > 0)
return 1;
@@ -75,11 +75,14 @@ gomp_iter_ull_static_next (gomp_ull *pstart, gomp_ull *pend)
/* 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)