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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> Despite recent improvements in mapping derived-type allocatable components, 
> the > following case is still not handled properly:
>
> !$omp target map(tofrom: chunk%tiles(1)%field(1)%density1, chunk)

In terms of validity, there might be a difference between mapping it first
partially in 'target enter data' and then using the 'chunk' mapping here. 

When commenting the 'chunk%left_rcv_buffer' line in the target region, it
actually works when not having 'target enter/exit data', but if keeping it, it
fail here with: 'cuCtxSynchronize error: an illegal memory access was
encountered'


[BTW: In GCC 15, also the variant without 'chuck' fails ('error: variable
'chunk' has been referenced in offloaded code but hasn't been marked to be
included in the offloaded code'). - However, with PR120505 fixed, it now works
without 'chunk'. (Without 'target enter data', it works when adding
'chunk%left_rcv_buffer' additionally to the 'map' clause f 'target.) With
chuck: well, see comment 0 and above.]

* * *

Lightly related is the following C++ testcase,
https://github.com/doru1004/omptests/blob/main/t-partial-struct/test.cpp#L222-L236


typedef struct {
  int *a;
} SSS;    
typedef struct {
  SSS *s;
} TTT;
constexpr int N = 10;
int main() {
    TTT t;
    t.s = new SSS();
    t.s->a = (int *) __builtin_malloc (N*sizeof(int));
    #pragma omp target map(from: t.s->a[:N])
    #pragma omp teams distribute parallel for
    for(int i = 0 ; i < N ; i++) {
      t.s->a[i] = i;
    }
}

which fails at runtime with:

  libgomp: Struct pointer member not mapped (0x7fffd35fc4d8)

unless 't' or 't.s' is explicitly mapped in addition; looks as if an implicit
mapping is missing here.

Reply via email to