aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2019-08-09 13:01:33 -0700
committerThomas Schwinge <thomas@codesourcery.com>2020-03-03 12:50:41 +0100
commit3f2d70bb7ed647e662f049d445b9fac1ae03044c (patch)
tree78c24824a131fe52a3d69a56cb50507af3c5f0bb
parentbdb426046046cbdb08fef00ae96a801ad94af8b7 (diff)
downloadgcc-3f2d70bb7ed647e662f049d445b9fac1ae03044c.zip
gcc-3f2d70bb7ed647e662f049d445b9fac1ae03044c.tar.gz
gcc-3f2d70bb7ed647e662f049d445b9fac1ae03044c.tar.bz2
[og9] Wait at end of OpenACC asynchronous kernels regions
gcc/ * omp-oacc-kernels.c (add_wait): New function, split out of... (add_async_clauses_and_wait): ...here. Call new outlined function. (decompose_kernels_region_body): Add wait at the end of explicitly-asynchronous kernels regions. (cherry picked from openacc-gcc-9-branch commit 79cc9084f24fec88df02daa5b099c8288ee06626)
-rw-r--r--gcc/ChangeLog.omp7
-rw-r--r--gcc/omp-oacc-kernels.c28
2 files changed, 28 insertions, 7 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 84d8051..a22f07c 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,10 @@
+2019-08-13 Julian Brown <julian@codesourcery.com>
+
+ * omp-oacc-kernels.c (add_wait): New function, split out of...
+ (add_async_clauses_and_wait): ...here. Call new outlined function.
+ (decompose_kernels_region_body): Add wait at the end of
+ explicitly-asynchronous kernels regions.
+
2019-08-08 Julian Brown <julian@codesourcery.com>
* config/gcn/gcn.c (gcn_goacc_validate_dims): Ensure
diff --git a/gcc/omp-oacc-kernels.c b/gcc/omp-oacc-kernels.c
index 2091385..a6c4220 100644
--- a/gcc/omp-oacc-kernels.c
+++ b/gcc/omp-oacc-kernels.c
@@ -900,6 +900,18 @@ maybe_build_inner_data_region (location_t loc, gimple *body,
return body;
}
+static void
+add_wait (location_t loc, gimple_seq *region_body)
+{
+ /* A "#pragma acc wait" is just a call GOACC_wait (acc_async_sync, 0). */
+ tree wait_fn = builtin_decl_explicit (BUILT_IN_GOACC_WAIT);
+ tree sync_arg = build_int_cst (integer_type_node, GOMP_ASYNC_SYNC);
+ gimple *wait_call = gimple_build_call (wait_fn, 2,
+ sync_arg, integer_zero_node);
+ gimple_set_location (wait_call, loc);
+ gimple_seq_add_stmt (region_body, wait_call);
+}
+
/* Helper function of decompose_kernels_region_body. The statements in
REGION_BODY are expected to be decomposed parallel regions; add an
"async" clause to each. Also add a "wait" pragma at the end of the
@@ -923,13 +935,7 @@ add_async_clauses_and_wait (location_t loc, gimple_seq *region_body)
gimple_omp_target_set_clauses (as_a <gomp_target *> (stmt),
target_clauses);
}
- /* A "#pragma acc wait" is just a call GOACC_wait (acc_async_sync, 0). */
- tree wait_fn = builtin_decl_explicit (BUILT_IN_GOACC_WAIT);
- tree sync_arg = build_int_cst (integer_type_node, GOMP_ASYNC_SYNC);
- gimple *wait_call = gimple_build_call (wait_fn, 2,
- sync_arg, integer_zero_node);
- gimple_set_location (wait_call, loc);
- gimple_seq_add_stmt (region_body, wait_call);
+ add_wait (loc, region_body);
}
/* Auxiliary analysis of the body of a kernels region, to determine for each
@@ -1378,6 +1384,14 @@ decompose_kernels_region_body (gimple *kernels_region, tree kernels_clauses)
a wait directive at the end. */
if (async_clause == NULL)
add_async_clauses_and_wait (loc, &region_body);
+ else
+ /* !!! If we have asynchronous parallel blocks inside a (synchronous) data
+ region, then target memory will get unmapped at the point the data
+ region ends, even if the inner asynchronous parallels have not yet
+ completed. For kernels marked "async", we might want to use "enter data
+ async(...)" and "exit data async(...)" instead.
+ For now, insert a (synchronous) wait at the end of the block. */
+ add_wait (loc, &region_body);
tree kernels_locals = gimple_bind_vars (as_a <gbind *> (kernels_body));
gimple *body = gimple_build_bind (kernels_locals, region_body,