[hsa] Also copy distribute pre-body

Martin Jambor mjambor@suse.cz
Thu Oct 22 15:38:00 GMT 2015


Hi,

I had to interrupt my porting to OpenMP 4.5 to fix this bug.  We were
not copying the distribute loop pre-body to before target, thus
setting the grid size of quite a few kernels to bogus values.  Fixed
thusly and committed to the branch.

Thanks,

Martin


2015-10-22  Martin Jambor  <mjambor@suse.cz>

	* omp-low.c (process_kernel_body_copy): Also copy pre-bodies of
	distribute and inner loop to before target.
	(attempt_target_gridification): Do not copy inner loop pre-body.
---
 gcc/omp-low.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index a094163..b568175 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12987,6 +12987,9 @@ process_kernel_body_copy (gimple_seq seq, gimple_stmt_iterator *dst,
       gomp_for *dist;
       if ((dist = dyn_cast <gomp_for *> (stmt)))
 	{
+          gimple_seq prebody = gimple_omp_for_pre_body (dist);
+          if (prebody)
+            copy_leading_local_assignments (prebody, dst, tgt_bind, wi);
 	  gimple_omp_for_set_kernel_phony (dist, true);
 	  stmt = copy_leading_local_assignments (gimple_omp_body (dist), dst,
 						 tgt_bind, wi);
@@ -12999,6 +13002,10 @@ process_kernel_body_copy (gimple_seq seq, gimple_stmt_iterator *dst,
 					 tgt_bind, wi);
   gomp_for *inner_loop = as_a <gomp_for *> (stmt);
   gimple_omp_for_set_kind (inner_loop, GF_OMP_FOR_KIND_KERNEL_BODY);
+  gimple_seq prebody = gimple_omp_for_pre_body (inner_loop);
+  if (prebody)
+    copy_leading_local_assignments (prebody, dst, tgt_bind, wi);
+
   return inner_loop;
 }
 
@@ -13046,11 +13053,6 @@ attempt_target_gridification (gomp_target *target, gimple_stmt_iterator *gsi,
     (gimple_bind_body_ptr (as_a <gbind *> (gimple_omp_body (target))),
      gpukernel);
 
-  /* Copy loop pre-body before target: */
-  gimple_seq prebody = gimple_omp_for_pre_body (inner_loop);
-  if (prebody)
-    copy_leading_local_assignments (prebody, gsi, tgt_bind, &wi);
-
   target->kernel_group_size = group_size;
   size_t collapse = inner_loop->collapse;
   target->kernel_collapse = collapse;
-- 
2.6.0



More information about the Gcc-patches mailing list