summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-fortran
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2021-12-02 18:24:03 +0800
committerChung-Lin Tang <cltang@codesourcery.com>2021-12-02 18:27:16 +0800
commit1ac7a8c9e4798d352eb8c64905dd38086af4e1cd (patch)
tree3aa91b3f74382e391ec248cbca909f7a6a59df7b /libgomp/testsuite/libgomp.oacc-fortran
parent1c5317d6214baec897120320423e6ad9f4980fdf (diff)
downloadgcc-1ac7a8c9e4798d352eb8c64905dd38086af4e1cd.tar.gz
fortran: OpenMP/OpenACC array mapping alignment fix (PR90030)
Fix issue with the Fortran front-end when mapping arrays: when creating the data MEM_REF for the map clause, there was a convention of casting the referencing pointer to 'c_char *' by fold_convert (build_pointer_type (char_type_node), ptr). This causes the alignment passed to the libgomp runtime for array data hardwared to '1', and causes alignment errors on the offload target. This patch fixes this by removing the char_type_node pointer converts, and adding gcc_asserts to ensure POINTER_TYPE_P (TREE_TYPE (ptr)). PR fortran/90030 gcc/fortran/ChangeLog: * trans-openmp.c (gfc_omp_finish_clause): Remove fold_convert to pointer to char_type_node, add gcc_assert of POINTER_TYPE_P. (gfc_trans_omp_array_section): Likewise. (gfc_trans_omp_clauses): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/finalize-1.f: Adjust scan test. * gfortran.dg/gomp/affinity-clause-1.f90: Likewise. * gfortran.dg/gomp/affinity-clause-5.f90: Likewise. * gfortran.dg/gomp/defaultmap-4.f90: Likewise. * gfortran.dg/gomp/defaultmap-5.f90: Likewise. * gfortran.dg/gomp/defaultmap-6.f90: Likewise. * gfortran.dg/gomp/map-3.f90: Likewise. * gfortran.dg/gomp/pr78260-2.f90: Likewise. * gfortran.dg/gomp/pr78260-3.f90: Likewise. libgomp/ChangeLog: * testsuite/libgomp.oacc-fortran/pr90030.f90: New test. * testsuite/libgomp.fortran/pr90030.f90: New test.
Diffstat (limited to 'libgomp/testsuite/libgomp.oacc-fortran')
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/pr90030.f9029
1 files changed, 29 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/pr90030.f90 b/libgomp/testsuite/libgomp.oacc-fortran/pr90030.f90
new file mode 100644
index 00000000000..bbfcff3a869
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/pr90030.f90
@@ -0,0 +1,29 @@
+! PR90030.
+! Test if the array data associated with c is properly aligned
+! on the accelerator. If it is not, this program will crash.
+
+! This is also included from '../libgomp.fortran/pr90030.f90'.
+
+! { dg-do run }
+
+program routine_align_main
+ implicit none
+ integer :: i, n
+ real*8, dimension(:), allocatable :: c
+
+ n = 10
+
+ allocate (c(n))
+
+ !$omp target map(to: n) map(from: c(1:n))
+ !$acc parallel copyin(n) copyout(c(1:n))
+ do i = 1, n
+ c(i) = i
+ enddo
+ !$acc end parallel
+ !$omp end target
+
+ do i = 1, n
+ if (c(i) .ne. i) stop i
+ enddo
+end program routine_align_main