
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.
29 lines
596 B
Fortran
29 lines
596 B
Fortran
! 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
|