@@ -1,5 +1,8 @@
2014-07-24 Thomas Schwinge <thomas@codesourcery.com>
+ * omp-low.c (extract_omp_for_data): Force OpenACC loop to use a
+ chunk size of one.
+
* omp-low.c (expand_omp_for_static_chunk): Merge changes
previously applied to expand_omp_for_static_nochunk.
@@ -619,6 +619,16 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd,
fd->loop.step = build_int_cst (TREE_TYPE (fd->loop.v), 1);
fd->loop.cond_code = LT_EXPR;
}
+
+ //TODO
+ /* For OpenACC loops, force a chunk size of one, as this avoids the default
+ scheduling where several subsequent iterations are being executed by the
+ same thread. */
+ if (gimple_omp_for_kind (for_stmt) == GF_OMP_FOR_KIND_OACC_LOOP)
+ {
+ gcc_assert (fd->chunk_size == NULL_TREE);
+ fd->chunk_size = build_int_cst (TREE_TYPE (fd->loop.v), 1);
+ }
}
In r213005, I committed changes to expand_omp_for_static_chunk that are
just what has previously been applied to expand_omp_for_static_nochunk.
(Internally, we have builtins to query the real nthreads and threadid,
insteead of the dummy one, zero values that I'm using here.)
commit 6c07d1bd13f6ceef80beb3c62cd25c3aaa397f1b
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu Jul 24 15:55:39 2014 +0000
Make expand_omp_for_static_chunk usable for OpenACC.
gcc/
* omp-low.c (expand_omp_for_static_chunk): Merge changes
previously applied to expand_omp_for_static_nochunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@213005 138bc75d-0d04-0410-961f-82ee72b054a4
---
gcc/ChangeLog.gomp | 5 +++++
gcc/omp-low.c | 19 +++++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
@@ -1,3 +1,8 @@
+2014-07-24 Thomas Schwinge <thomas@codesourcery.com>
+
+ * omp-low.c (expand_omp_for_static_chunk): Merge changes
+ previously applied to expand_omp_for_static_nochunk.
+
2014-07-14 Cesar Philippidis <cesar@codesourcery.com>
* omp-low.c (extract_omp_for_data): Likewise.
@@ -7040,8 +7040,6 @@ static void
expand_omp_for_static_chunk (struct omp_region *region,
struct omp_for_data *fd, gimple inner_stmt)
{
- gcc_assert (gimple_omp_for_kind (fd->for_stmt) != GF_OMP_FOR_KIND_OACC_LOOP);
-
tree n, s0, e0, e, t;
tree trip_var, trip_init, trip_main, trip_back, nthreads, threadid;
tree type, itype, vmain, vback, vextra;
@@ -7054,6 +7052,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
tree *counts = NULL;
tree n1, n2, step;
+ gcc_assert ((gimple_omp_for_kind (fd->for_stmt)
+ != GF_OMP_FOR_KIND_OACC_LOOP)
+ || !inner_stmt);
+
itype = type = TREE_TYPE (fd->loop.v);
if (POINTER_TYPE_P (type))
itype = signed_type_for (type);
@@ -7153,6 +7155,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
threadid = builtin_decl_explicit (BUILT_IN_OMP_GET_TEAM_NUM);
threadid = build_call_expr (threadid, 0);
break;
+ case GF_OMP_FOR_KIND_OACC_LOOP:
+ nthreads = integer_one_node;
+ threadid = integer_zero_node;
+ break;
default:
gcc_unreachable ();
}
@@ -7168,6 +7174,9 @@ expand_omp_for_static_chunk (struct omp_region *region,
step = fd->loop.step;
if (gimple_omp_for_combined_into_p (fd->for_stmt))
{
+ gcc_assert (gimple_omp_for_kind (fd->for_stmt)
+ != GF_OMP_FOR_KIND_OACC_LOOP);
+
tree innerc = find_omp_clause (gimple_omp_for_clauses (fd->for_stmt),
OMP_CLAUSE__LOOPTEMP_);
gcc_assert (innerc);
@@ -7351,6 +7360,9 @@ expand_omp_for_static_chunk (struct omp_region *region,
gsi = gsi_last_bb (exit_bb);
if (!gimple_omp_return_nowait_p (gsi_stmt (gsi)))
{
+ gcc_assert (gimple_omp_for_kind (fd->for_stmt)
+ != GF_OMP_FOR_KIND_OACC_LOOP);
+
t = gimple_omp_return_lhs (gsi_stmt (gsi));
gsi_insert_after (&gsi, build_omp_barrier (t), GSI_SAME_STMT);
}
@@ -7365,6 +7377,9 @@ expand_omp_for_static_chunk (struct omp_region *region,
se = find_edge (cont_bb, body_bb);
if (gimple_omp_for_combined_p (fd->for_stmt))
{
+ gcc_assert (gimple_omp_for_kind (fd->for_stmt)
+ != GF_OMP_FOR_KIND_OACC_LOOP);
+
remove_edge (se);
se = NULL;
}