2015-09-22 Cesar Philippidis <cesar@codesourcery.com>
gcc/
* fortran/trans-openmp.c (gfc_omp_finish_clause): Don't cast ptr
into a character pointer.
(gfc_trans_omp_clauses_1): Likewise.
libgomp/
* testsuite/libgomp.oacc-fortran/data-alignment.f90: New test.
@@ -1065,7 +1065,6 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p)
gfc_start_block (&block);
tree type = TREE_TYPE (decl);
tree ptr = gfc_conv_descriptor_data_get (decl);
- ptr = fold_convert (build_pointer_type (char_type_node), ptr);
ptr = build_fold_indirect_ref (ptr);
OMP_CLAUSE_DECL (c) = ptr;
c2 = build_omp_clause (input_location, OMP_CLAUSE_MAP);
@@ -1972,8 +1971,6 @@ gfc_trans_omp_clauses_1 (stmtblock_t *block, gfc_omp_clauses *clauses,
{
tree type = TREE_TYPE (decl);
tree ptr = gfc_conv_descriptor_data_get (decl);
- ptr = fold_convert (build_pointer_type (char_type_node),
- ptr);
ptr = build_fold_indirect_ref (ptr);
OMP_CLAUSE_DECL (node) = ptr;
node2 = build_omp_clause (input_location,
@@ -2066,8 +2063,6 @@ gfc_trans_omp_clauses_1 (stmtblock_t *block, gfc_omp_clauses *clauses,
OMP_CLAUSE_SIZE (node), elemsz);
}
gfc_add_block_to_block (block, &se.post);
- ptr = fold_convert (build_pointer_type (char_type_node),
- ptr);
OMP_CLAUSE_DECL (node) = build_fold_indirect_ref (ptr);
if (POINTER_TYPE_P (TREE_TYPE (decl))
new file mode 100644
@@ -0,0 +1,35 @@
+! Test if the array data associated with c is properly aligned
+! on the accelerator. If it is not, this program will crash.
+
+! { dg-do run }
+
+integer function routine_align()
+ implicit none
+ integer, parameter :: n = 10000
+ real*8, dimension(:), allocatable :: c
+ integer :: i, idx
+
+ allocate (c(n))
+ routine_align = 0
+ c = 0.0
+
+ !$acc data copyin(idx) copy(c(1:n))
+
+ !$acc parallel vector_length(32)
+ !$acc loop vector
+ do i=1, n
+ c(i) = i
+ enddo
+ !$acc end parallel
+
+ !$acc end data
+end function routine_align
+
+
+! main driver
+program routine_align_main
+ implicit none
+ integer :: success
+ integer routine_align
+ success = routine_align()
+end program routine_align_main