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

            Bug ID: 90247
           Summary: Reconsider OpenACC implicit data attributes for
                    pointers
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: openacc
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
  Target Milestone: ---

We've been reading the OpenACC specification such that a pointer variable is a
scalar (not an array), and thus gets an implicit 'firstprivate' clause (not
some kind of 'copy' clause).  This is not what users appear to expect:

    int *p = (int *) malloc([...})
    #pragma acc enter data create (p[0:100])

    #pragma acc parallel loop // implicit 'firstprivate(p)'
    for ([i])
      p[i] = [...]

    #pragma acc enter data copyout (p[0:100])

The implicit 'firstprivate' clause will not translate the host 'p' to the
corresponding device 'p' that has been 'create'd above, but will copy the host
pointer value untranslated, leading to run-time failure upon dereferencing the
host 'p' on the device.  What users instead would like is what OpenMP calls
"zero-length array section" mapping.

There is discussion that the OpenACC specification is moving into that
direction.

A patch has been proposed,
<http://mid.mail-archive.com/e4c72dcf-95b6-b919-64c6-a3e8c22d74df@codesourcery.com>,
but needs work.


Then, there are similar considerations to be made for other such data mapping
cases/constructs (not listed here now).

Reply via email to