]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimplify.c (oacc_default_clause): Decode reference and pointer types for both kernels...
authorCesar Philippidis <cesar@codesourcery.com>
Fri, 15 Jan 2016 14:49:55 +0000 (06:49 -0800)
committerCesar Philippidis <cesar@gcc.gnu.org>
Fri, 15 Jan 2016 14:49:55 +0000 (06:49 -0800)
gcc/
* gimplify.c (oacc_default_clause): Decode reference and pointer
types for both kernels and parallel regions.

libgomp/
* testsuite/libgomp.oacc-fortran/kernels-data.f90: New test.

From-SVN: r232431

gcc/ChangeLog
gcc/gimplify.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.oacc-fortran/non-scalar-data.f90 [new file with mode: 0644]

index 59dc4abbab50e1238b10755810ce0d5ab0f8caa6..5680be8a8d3d4176dbba965dbf1f8dab0e7c6646 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-15  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * gimplify.c (oacc_default_clause): Decode reference and pointer
+       types for both kernels and parallel regions.
+
 2016-01-15  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR middle-end/69246
index ca66402babac14acdeaf9af93848f09ce6f3ea31..c8de1e62abd9c3785bca478e7af896eb03f73244 100644 (file)
@@ -5986,6 +5986,10 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
 {
   const char *rkind;
   bool on_device = false;
+  tree type = TREE_TYPE (decl);
+
+  if (lang_hooks.decls.omp_privatize_by_reference (decl))
+    type = TREE_TYPE (type);
 
   if ((ctx->region_type & (ORT_ACC_PARALLEL | ORT_ACC_KERNELS)) != 0
       && is_global_var (decl)
@@ -6004,7 +6008,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
       /* Scalars are default 'copy' under kernels, non-scalars are default
         'present_or_copy'.  */
       flags |= GOVD_MAP;
-      if (!AGGREGATE_TYPE_P (TREE_TYPE (decl)))
+      if (!AGGREGATE_TYPE_P (type))
        flags |= GOVD_MAP_FORCE;
 
       rkind = "kernels";
@@ -6012,12 +6016,6 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
 
     case ORT_ACC_PARALLEL:
       {
-       tree type = TREE_TYPE (decl);
-
-       if (TREE_CODE (type) == REFERENCE_TYPE
-           || POINTER_TYPE_P (type))
-         type = TREE_TYPE (type);
-
        if (on_device || AGGREGATE_TYPE_P (type))
          /* Aggregates default to 'present_or_copy'.  */
          flags |= GOVD_MAP;
index 5918752c3ea749dde9329de0392adc1a1ae362ac..be30656532a52e6efe67c9d27bfb6d3aea95125b 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-15  Cesar Philippidis  <cesar@codesourcery.com>
+
+       * testsuite/libgomp.oacc-fortran/kernels-data.f90: New test.
+
 2016-01-12  James Norris  <jnorris@codesourcery.com>
 
        * libgomp.texi: Updates for OpenACC.
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/non-scalar-data.f90 b/libgomp/testsuite/libgomp.oacc-fortran/non-scalar-data.f90
new file mode 100644 (file)
index 0000000..4afb562
--- /dev/null
@@ -0,0 +1,50 @@
+! Ensure that a non-scalar dummy arguments which are implicitly used inside
+! offloaded regions are properly mapped using present_or_copy.
+
+! { dg-do run }
+
+program main
+  implicit none
+
+  integer, parameter :: n = 100
+  integer :: array(n), i
+  
+  !$acc data copy(array)
+  call kernels(array, n)
+
+  !$acc update host(array)
+
+  do i = 1, n
+     if (array(i) .ne. i) call abort
+  end do
+
+  call parallel(array, n)
+  !$acc end data
+
+  do i = 1, n
+     if (array(i) .ne. i+i) call abort
+  end do
+end program main
+
+subroutine kernels (array, n)
+  integer, dimension (n) :: array
+  integer :: n, i
+
+  !$acc kernels
+  do i = 1, n
+     array(i) = i
+  end do
+  !$acc end kernels
+end subroutine kernels
+
+
+subroutine parallel (array, n)
+  integer, dimension (n) :: array
+  integer :: n, i
+
+  !$acc parallel
+  do i = 1, n
+     array(i) = i+i
+  end do
+  !$acc end parallel
+end subroutine parallel