Hi Julian, hi Thomas,

in terms of the check, it looks fine to me – but I am not sure about the spec.

At least the following test case seems to work fine:

integer :: A(10,10), out(12)
A = reshape([(i, i=0,100)], shape(A))
!$omp target map(A(3:6,3:5), out)
!$acc parallel copy(A(3:6,3:5), out)
  out = reshape(A(3:6,3:5), shape(out))
  A(3:6,3:5) = 4
!$acc end parallel
!$omp end target
print '(4i3)', out
print '(10i3)', A
end

The reason that it works is that the stride is included in the length 
calculation:
#pragma omp target num_teams(1) thread_limit(0) map(tofrom:MEM[(c_char *)_6] 
[len: _5])

Has for the section (with A(3:6,3:5) -> parm(1:4,1:3)):
              parm.1.dim[0].lbound = 1;
              parm.1.dim[0].ubound = 4;
              parm.1.dim[0].stride = 1;
              parm.1.dim[1].lbound = 1;
              parm.1.dim[1].ubound = 3;
              parm.1.dim[1].stride = 10;
And instead of doing '(4-1+1) * (3-1+1)' = 12 (i.e. multiplying the extends),
the code does: 'stride * (3-1+1)' = 30.

Cheers,

Tobias

PS: It also works if one puts the stride on the ptr, i.e.:

integer,target :: A(10,10), out(12)
integer, pointer :: ptr(:,:)
A = reshape([(i, i=0,100)], shape(A))
ptr => A(3:6,3:5)
!$omp target map(ptr, out)
!$acc parallel copy(ptr, out)
  out = reshape(ptr, shape(out))
  ptr = 4
!$acc end parallel
!$omp end target
print '(4i3)', out
print '(10i3)', A
end

On 1/4/20 3:25 AM, Julian Brown wrote:
This patch tightens up error checking for array references used in
OpenACC clauses such that they must now be contiguous. I believe this
matches up to the spec (as of 2.6). I've tried to make it so an error
only triggers if the compiler is sure that a given array expression must
be non-contiguous at compile time, although this errs on the side
of potentially allowing the user to shoot themselves in the foot at
runtime: at least one existing test in the testsuite appears to expect
that behaviour.
[…]

Reply via email to