On Thu, Mar 19, 2015 at 15:57:10 +0100, Jakub Jelinek wrote:
> On Thu, Mar 19, 2015 at 05:49:47PM +0300, Ilya Verbin wrote:
> > If I understand correctly, it's not allowed to map global target arrays this
> > way, since it's already present in the initial device data environment:
> 
> It of course is allowed.  It just means that it doesn't allocate new memory
> (sizeof(int) large in the map(a1[10]) case, sizeof(int)*50 large in the 
> map(a1[0:50])
> case), nor copy the bytes around, all it will do is allocate memory for the
> target copy of the a1 pointer, and do pointer transformation such that the
> a1 pointer on the target will point to the global target a1 array.
> Without the map(a1[10]) or map(a1[0:50]) clauses (i.e. implicit 
> map(tofrom:a1))
> it does similar thing, except it copies the pointer value to the target (and
> back at the end of the region) instead, which is not what you want...

Ok, got it.

And what about global allocatable fortran arrays?  I didn't find any
restrictions in the specification.  Here is a reduced testcase:

module test
  integer, allocatable, target :: x(:)
  !$omp declare target(x)
end module test
  use test
  integer :: n = 1000
  allocate (x(n))
  !$omp target map(x(1:n))
     x(123) = 456
  !$omp end target
  deallocate (x)
end

It crashes on target with NULL-pointer access, however the memory for x(1:n) is
allocated on target.  Looks like there's something wrong with pointer
transformation.  Is this a wrong testcase or a bug in gcc?

Thanks,
  -- Ilya

Reply via email to