gcc/libgomp/testsuite/libgomp.fortran/aligned1.f03
Jakub Jelinek b46ebd6c7b gimplify.c (gimplify_scan_omp_clauses) <case OMP_CLAUSE_MAP, [...]): Make sure OMP_CLAUSE_SIZE is non-NULL.
* gimplify.c (gimplify_scan_omp_clauses) <case OMP_CLAUSE_MAP,
	OMP_CLAUSE_TO, OMP_CLAUSE_FROM): Make sure OMP_CLAUSE_SIZE is
	non-NULL.
	<case OMP_CLAUSE_ALIGNED>: Gimplify OMP_CLAUSE_ALIGNED_ALIGNMENT.
	(gimplify_adjust_omp_clauses_1): Make sure OMP_CLAUSE_SIZE is
	non-NULL.
	(gimplify_adjust_omp_clauses): Likewise.
	* omp-low.c (lower_rec_simd_input_clauses,
	lower_rec_input_clauses, expand_omp_simd): Handle non-constant
	safelen the same as safelen(1).
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Handle OMP_CLAUSE_ALIGNED.  For
	OMP_CLAUSE_{MAP,TO,FROM} if not decl use walk_tree.
	(convert_nonlocal_reference_stmt, convert_local_reference_stmt):
	Fixup handling of GIMPLE_OMP_TARGET.
	(convert_tramp_reference_stmt, convert_gimple_call): Handle
	GIMPLE_OMP_TARGET.
gcc/fortran/
	* dump-parse-tree.c (show_omp_namelist): Use n->udr->udr instead
	of n->udr.
	* f95-lang.c (gfc_init_builtin_functions): Initialize
	BUILT_IN_ASSUME_ALIGNED.
	* gfortran.h (gfc_omp_namelist): Change udr field type to
	struct gfc_omp_namelist_udr.
	(gfc_omp_namelist_udr): New type.
	(gfc_get_omp_namelist_udr): Define.
	(gfc_resolve_code): New prototype.
	* match.c (gfc_free_omp_namelist): Free name->udr.
	* module.c (intrinsics): Add INTRINSIC_USER.
	(fix_mio_expr): Likewise.
	(mio_expr): Handle INSTRINSIC_USER and non-resolved EXPR_FUNCTION.
	* openmp.c (gfc_match_omp_clauses): Adjust initialization of n->udr.
	(gfc_match_omp_declare_reduction): Treat len=: the same as len=*.
	Set attr.flavor on omp_{out,in,priv,orig} artificial variables.
	(struct resolve_omp_udr_callback_data): New type.
	(resolve_omp_udr_callback, resolve_omp_udr_callback2,
	resolve_omp_udr_clause): New functions.
	(resolve_omp_clauses): Adjust for n->udr changes, resolve UDR clauses
	here.
	(omp_udr_callback): Don't check for implicitly declared functions
	here.
	(gfc_resolve_omp_udr): Don't call gfc_resolve.  Don't check for
	implicitly declared subroutines here.
	* resolve.c (resolve_function): If value.function.isym is non-NULL,
	consider it already resolved.
	(resolve_code): Renamed to ...
	(gfc_resolve_code): ... this.  No longer static.
	(gfc_resolve_blocks, generate_component_assignments, resolve_codes):
	Adjust callers.
	* trans-openmp.c (gfc_omp_privatize_by_reference): Don't privatize
	by reference type (C_PTR) variables.
	(gfc_omp_finish_clause): Make sure OMP_CLAUSE_SIZE is non-NULL.
	(gfc_trans_omp_udr_expr): Remove.
	(gfc_trans_omp_array_reduction_or_udr): Adjust for n->udr changes.
	Don't call gfc_trans_omp_udr_expr, even for sym->attr.dimension
	expand it as assignment or subroutine call.  Don't initialize
	value.function.isym.
gcc/testsuite/
	* gfortran.dg/gomp/udr2.f90 (f7, f9): Add !$omp parallel with
	reduction clause.
	* gfortran.dg/gomp/udr4.f90 (f4): Likewise.
	Remove Label is never defined expected error.
	* gfortran.dg/gomp/udr8.f90: New test.
libgomp/
	* testsuite/libgomp.fortran/aligned1.f03: New test.
	* testsuite/libgomp.fortran/nestedfn5.f90: New test.
	* testsuite/libgomp.fortran/target7.f90: Surround loop spawning
	tasks with !$omp parallel !$omp single.
	* testsuite/libgomp.fortran/target8.f90: New test.
	* testsuite/libgomp.fortran/udr4.f90 (foo UDR, bar UDR): Adjust
	not to use trim in the combiner, instead call elemental function.
	(fn): New elemental function.
	* testsuite/libgomp.fortran/udr6.f90 (do_add, dp_add, dp_init):
	Make elemental.
	* testsuite/libgomp.fortran/udr7.f90 (omp_priv, omp_orig, omp_out,
	omp_in): Likewise.
	* testsuite/libgomp.fortran/udr12.f90: New test.
	* testsuite/libgomp.fortran/udr13.f90: New test.
	* testsuite/libgomp.fortran/udr14.f90: New test.
	* testsuite/libgomp.fortran/udr15.f90: New test.

From-SVN: r211929
2014-06-24 09:45:22 +02:00

134 lines
3.0 KiB
Fortran

! { dg-do run }
! { dg-options "-fopenmp -fcray-pointer" }
use iso_c_binding, only : c_ptr, c_ptrdiff_t, c_loc
interface
subroutine foo (x, y, z, w)
use iso_c_binding, only : c_ptr
real, pointer :: x(:), y(:), w(:)
type(c_ptr) :: z
end subroutine
subroutine bar (x, y, z, w)
use iso_c_binding, only : c_ptr
real, pointer :: x(:), y(:), w(:)
type(c_ptr) :: z
end subroutine
subroutine baz (x, c)
real, pointer :: x(:)
real, allocatable :: c(:)
end subroutine
end interface
type dt
real, allocatable :: a(:)
end type
type (dt) :: b(64)
real, target :: a(4096+63)
real, pointer :: p(:), q(:), r(:), s(:)
real, allocatable :: c(:)
integer(c_ptrdiff_t) :: o
integer :: i
o = 64 - mod (loc (a), 64)
if (o == 64) o = 0
o = o / sizeof(0.0)
p => a(o + 1:o + 1024)
q => a(o + 1025:o + 2048)
r => a(o + 2049:o + 3072)
s => a(o + 3073:o + 4096)
do i = 1, 1024
p(i) = i
q(i) = i
r(i) = i
s(i) = i
end do
call foo (p, q, c_loc (r(1)), s)
do i = 1, 1024
if (p(i) /= i * i + 3 * i + 2) call abort
p(i) = i
end do
call bar (p, q, c_loc (r(1)), s)
do i = 1, 1024
if (p(i) /= i * i + 3 * i + 2) call abort
end do
! Attempt to create 64-byte aligned allocatable
do i = 1, 64
allocate (c(1023 + i))
if (iand (loc (c(1)), 63) == 0) exit
deallocate (c)
allocate (b(i)%a(1023 + i))
allocate (c(1023 + i))
if (iand (loc (c(1)), 63) == 0) exit
deallocate (c)
end do
if (allocated (c)) then
do i = 1, 1024
c(i) = 2 * i
end do
call baz (p, c)
do i = 1, 1024
if (p(i) /= i * i + 5 * i + 2) call abort
end do
end if
end
subroutine foo (x, y, z, w)
use iso_c_binding, only : c_ptr, c_f_pointer
real, pointer :: x(:), y(:), w(:), p(:)
type(c_ptr) :: z
integer :: i
real :: pt(1024)
pointer (ip, pt)
ip = loc (w)
!$omp simd aligned (x, y : 64)
do i = 1, 1024
x(i) = x(i) * y(i) + 2.0
end do
!$omp simd aligned (x, z : 64) private (p)
do i = 1, 1024
call c_f_pointer (z, p, shape=[1024])
x(i) = x(i) + p(i)
end do
!$omp simd aligned (x, ip : 64)
do i = 1, 1024
x(i) = x(i) + 2 * pt(i)
end do
!$omp end simd
end subroutine
subroutine bar (x, y, z, w)
use iso_c_binding, only : c_ptr, c_f_pointer
real, pointer :: x(:), y(:), w(:), a(:), b(:)
type(c_ptr) :: z, c
integer :: i
real :: pt(1024)
pointer (ip, pt)
ip = loc (w)
a => x
b => y
c = z
!$omp simd aligned (a, b : 64)
do i = 1, 1024
a(i) = a(i) * b(i) + 2.0
end do
!$omp simd aligned (a, c : 64)
do i = 1, 1024
block
real, pointer :: p(:)
call c_f_pointer (c, p, shape=[1024])
a(i) = a(i) + p(i)
end block
end do
!$omp simd aligned (a, ip : 64)
do i = 1, 1024
a(i) = a(i) + 2 * pt(i)
end do
!$omp end simd
end subroutine
subroutine baz (x, c)
real, pointer :: x(:)
real, allocatable :: c(:)
integer :: i
!$omp simd aligned (x, c : 64)
do i = 1, 1024
x(i) = x(i) + c(i)
end do
!$omp end simd
end subroutine baz