Skip to content

GPU macros: OpenMP renders attach as map(always,tofrom:), which is not what OpenACC's attach means #1693

Description

@sbryngelson

Bug

In src/common/include/omp_macros.fpp, the dedicated attach generator is commented out:

#! #:def OMP_ATTACH_STR(attach)
#! #:set attach_val = OMP_MAP_STR('always,to', attach)
#! $:attach_val

and the live path in OMP_PARALLEL_LOOP (line 135) renders it differently:

#:set attach_val = OMP_MAP_STR('always,tofrom', attach)

OpenACC's attach only fixes up device pointers within an aggregate that is already present;
it performs no data transfer, and certainly no copy-back. The OpenMP branch emits
map(always,tofrom:), which forces an unconditional host→device and device→host transfer
on every launch.

So the same GPU_PARALLEL_LOOP(..., attach='[...]') call means two different things depending
on backend: a pointer fix-up under OpenACC, a full round-trip copy under OpenMP. Besides the
performance cost, a copy-back can overwrite device-side updates with stale host data.

Suggested fix

Either restore the commented-out generator (always,to, matching the intent), or — closer to
OpenACC semantics — emit no map at all for attach and rely on the aggregate already being
present, since attach is a pointer-attachment operation rather than a data-movement one.

Context

Found during a systematic ACC-vs-OMP differential audit of the macro layer while porting MFC
to CCE 21 on Frontier. Two other divergences of the same shape have already been found in this
layer:

The pattern is that the OpenMP branch does more than the OpenACC branch means. A full audit
of the remaining clauses is worthwhile; the stubs at omp_macros.fpp:36 (default='none'),
:261 and :318 are the other known gaps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions