https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63247

            Bug ID: 63247
           Summary: fortran array alignment in omp target map
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cesar at codesourcery dot com

I've noticed that lower_omp_target is not passing the proper pointer alignment
to libgomp for fortran array maps. While this isn't a problem for trunk, it
does affect our nvptx target. Here is a test case:

program test
  implicit none

  integer a(5)

  a = 10;

  write (*, '(a,Z16)') 'address of a = ', loc(a)

  !$omp target map(a(1:5))                                                      
  a(1) = 5
  a(2) = 5
  a(3) = 5
  a(4) = 5
  a(5) = 5
  !$omp end target                                                              

end program test

Here's my gdb session:

Breakpoint 5, lower_omp_target (gsi_p=, ctx=) at
../../../gcc/gcc/omp-low.c:10191
10191            CONSTRUCTOR_APPEND_ELT (vkind, purpose,
(gdb) p talign
$10 = 2
(gdb) p ovar
$11 = (tree) 
(gdb) pt
warning: Expression is not an assignment (and might have no effect)
 <var_decl 0x7ffff630a900 a
    type <array_type 0x7ffff643e3f0
        type <integer_type 0x7ffff6303690 integer(kind=4) public SI
            size <integer_cst 0x7ffff62ffdb0 constant 32>
            unit size <integer_cst 0x7ffff62ffdc8 constant 4>
            align 32 symtab 0 alias set -1 canonical type 0x7ffff6303690
precision 32 min <integer_cst 0x7ffff62ffd68 -2147483648> max <integer_cst
0x7ffff62ffd80 2147483647>
            pointer_to_this <pointer_type 0x7ffff6319738>>
        type_2 BLK
        size <integer_cst 0x7ffff641b798 constant 160>
        unit size <integer_cst 0x7ffff643a300 constant 20>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff643e3f0
        domain <integer_type 0x7ffff643e738 type <integer_type 0x7ffff63037e0
integer(kind=8)>
            DI
            size <integer_cst 0x7ffff62ffb70 constant 64>
            unit size <integer_cst 0x7ffff62ffb88 constant 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff643e738
precision 64 min <integer_cst 0x7ffff631d1f8 0> max <integer_cst 0x7ffff643a1f8
4>>
        pointer_to_this <pointer_type 0x7ffff643e930>>
    addressable used decl_0 BLK file
/home/cphilipp/tools/nvidia/demos/fortran-tests/pointer-align-2.f90 line 4 col
0 size <integer_cst 0x7ffff641b798 160> unit size <integer_cst 0x7ffff643a300
20>
    align 32 context <function_decl 0x7ffff643d360 test>>
(gdb) p talign
$12 = 2

How should this issue be resolved? I think the fortran FE behavior is correct.
Should lower_omp_target have something like this

        if (tkind == OMP_CLAUSE_MAP_POINTER)
          talign = POINTER_SIZE / BITS_PER_UNIT;

or should libgomp correct the alignment for OMP_CLAUSE_MAP_POINTER? It should
be noted the C FE doesn't have this problem with arrays.

Thanks,
Cesar

Reply via email to