OffTarget

Observed issues › gcc/gcc-c-motion-mapper-rejected

Appears not to supportRefused at compile time · C · OpenMP · Open

target update to(mapper(m): x) and from(mapper(m): x) are rejected: "clause with modifier other than 'iterator' or 'present'"

Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked

GCC 16.2 accepts declare mapper and the mapper modifier of map in C, but rejects the same modifier on the to and from clauses of target update ("'to' clause with modifier other than 'iterator' or 'present'"). AFAR and CCE compile and run the program correctly.

Affected variants

CompilerMI300A gfx942
unified memory (XNACK 1)
MI300A gfx942
copy (XNACK 0)
MI250X gfx90a
copy (XNACK 0)
MI300X gfx942
copy (XNACK 0)
MI350X gfx950
copy (XNACK 0)
A100 sm_80
separate memory
A100 sm_80
managed memory
AFAR 24.3.0correctcorrectunknown
not run
correctcorrectn/an/a
CCE 19.0.0correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/afails another wayfails another way
NVHPC 26.9n/an/an/an/an/afails another wayfails another way
GCC 16.2.0not supportednot supportednot supportednot supportednot supportednot supportedn/a

"behaves incorrectly" / "not supported": this issue, confirmed in up to four environments (another build directory, another node, a repeat). "fails another way": a different failure, not counted as this issue. "unknown": not run there, or the runs disagree.

Messages

ResultCompiler and GPUMessage
not supportedGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
GCC 16.2.0, MI250X
GCC 16.2.0, MI300X
GCC 16.2.0, MI350X
GCC 16.2.0, A100 separate
show
site-gcc--gcc-c-motion-mapper-rejected.c: In function ‘main’:
site-gcc--gcc-c-motion-mapper-rejected.c:89:32: error: ‘to’ clause with modifier other than ‘iterator’ or ‘present’
   89 |   #pragma omp target update to(mapper(mm): s)
      |                                ^~~~~~
site-gcc--gcc-c-motion-mapper-rejected.c:89:32: error: expected ‘)’ before ‘mapper’
   89 |   #pragma omp target update to(mapper(mm): s)
      |                               ~^~~~~~
      |                                )
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
"site-gcc--gcc-c-motion-mapper-rejected.c", line 43: error: invalid text in pragma
  #pragma omp declare mapper(mm: struct dt q) map(q.v)
                            ^
"site-gcc--gcc-c-motion-mapper-rejected.c", line 89: error: invalid text in pragma
    #pragma omp target update to(mapper(mm): s)
                                        ^
"site-gcc--gcc-c-motion-mapper-rejected.c", line 89: error: expected a ":"
    #pragma omp target update to(mapper(mm): s)

Reproduce

GCC 16.2.0, MI300A unified

export LD_LIBRARY_PATH=$GCC_16_2/lib64:/opt/rocm-7.2.1/lib
$GCC_16_2/bin/gcc -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

GCC 16.2.0, A100 separate

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=$GCC_16_2/lib64
$GCC_16_2/bin/gcc -fopenmp -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.c -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro

AFAR 24.3.0, MI300A unified (runs correctly)

$AFAR/bin/amdclang -fopenmp --offload-arch=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (103 lines)
// # Finding (GCC 16.2): the mapper modifier of the to and from clauses is rejected (C); the reproducer is the catalog program
//   omp52-c-clause-to-mapper
//
// - toolchains: gcc_g90 (GCC 16.2.0, AMD Instinct MI250X gfx90a, Tioga) and gcc_sm80 (GCC 16.2.0,
//   NVIDIA A100 sm_80, wingtip); separate memory only; -O2; OMP_TARGET_OFFLOAD=mandatory
// - build: gcc -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx90a -O2 (gcc_g90); -foffload=nvptx-none
//   -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 (gcc_sm80)
// - failure: rejected: clause with modifier other than .iterator. or .present.
// - observed: `error: 'to' clause with modifier other than 'iterator' or 'present'` (and the same for from), on both GPUs. The
//   declare mapper directive and map(mapper(mm), tofrom: s) of the C map programs compile and pass at 5.0 and 5.2.
// - expected: compiles; `RESULT ran_on_host=0 check=pass`
// - GCC 16.2 documentation (libgomp.texi of the GCC 16.2.0 release tarball, "OpenMP Implementation Status", OpenMP 5.0 table):
//   "declare mapper directive": P, "Initial support and for C/C++, only"; no row names the motion clauses' mapper modifier.
// - spec: "mapper" is a modifier of the to clause (5.2 §5.9.1 p.166).
// - other families: AFAR and CCE 19/20/21 compile and run the program correctly (MI300A, both modes; MI250X); NVHPC rejects it.
// - gate and confirmer: 12 cells (6 gcc_g90, 6 gcc_sm80), each confirmed in the gate's four environments (a-d;
//   results/gcc/gate-tioga/ and gate-wingtip/ verdicts.jsonl); confirmer verdicts (results/gcc/confirm/batch.gcc_*.jsonl):
//   compiler_bug (R11-compile-rejection) 8, unsupported (R11a-newer-form-unclaimed) 4
// - catalog programs (6): omp50-c-clause-from-mapper, omp50-c-clause-to-mapper, omp52-c-clause-from-mapper,
//   omp52-c-clause-to-mapper, omp60-c-clause-from-mapper, omp60-c-clause-to-mapper
// - legality: the catalog programs are legal by construction (offload.engine.gen, c_gen and acc_gen
//   check every program against the catalog rules and the offload scope as it is built; no
//   compiler). GCC is a compiler under test only: never a legality witness, here or for another
//   family's case (catalog/machines.yaml under_test_only).
// Generated by compliance.c_gen (OpenMP 5.2, C11): the C port (offload.engine.f2c) of omp52-clause-to-mapper. Do not edit.
// id: omp52-c-clause-to-mapper
// primary atom: omp.clause.to.mapper
// legal: yes
// observable: yes
// ran_on_host: inside the target region of interest
// evidence: copy_mode_only
// needs: none
// std: c11
#include <stdio.h>
#include <stdbool.h>
#include <omp.h>

enum { n = 64 };
struct dt {
  int v[8];
  int w[8];
};
#pragma omp declare mapper(mm: struct dt q) map(q.v)

int main(void) {
  int a[n];
  int b[n];
  int ref[n];
  int host_flag;
  bool ok;
  struct dt s;
  int rv;
  int rw;
  bool pres;
  bool shared_mem;
  int zc[1];
  for (int i = 1; i <= n; i++) {
    a[i - 1] = i;
    b[i - 1] = 0;
    ref[i - 1] = 2 * i + 1;
  }
  host_flag = 1;
  for (int k1_ = 0; k1_ < 8; k1_++)
    s.v[k1_] = 1;
  for (int k2_ = 0; k2_ < 8; k2_++)
    s.w[k2_] = 1;
  rv = 0;
  rw = 0;
  pres = true;
  for (int k3_ = 0; k3_ < 1; k3_++)
    zc[k3_] = 0;
  #pragma omp target map(to: zc)
  {
    zc[0] = 1;
  }
  shared_mem = zc[0] == 1;
  #pragma omp target map(to: a) map(from: b) map(tofrom: host_flag)
  {
    host_flag = (omp_is_initial_device() ? 1 : 0);
    for (int i = 1; i <= n; i++) {
      b[i - 1] = 2 * a[i - 1] + 1;
    }
  }
  #pragma omp target enter data map(to: s)
  for (int k4_ = 0; k4_ < 8; k4_++)
    s.v[k4_] = 5;
  for (int k5_ = 0; k5_ < 8; k5_++)
    s.w[k5_] = 5;
  #pragma omp target update to(mapper(mm): s)
  #pragma omp target map(from: rv, rw)
  {
    rv = s.v[0];
    rw = s.w[0];
  }
  #pragma omp target exit data map(delete: s)
  if (!shared_mem) pres = pres && ((rv == 5) && (rw == 1));
  bool t6_ = true;
  for (int k7_ = 0; k7_ < n; k7_++)
    t6_ = t6_ && (b[k7_] == ref[k7_]);
  ok = t6_ && pres;
  printf("RESULT ran_on_host=%d check=%s\n", host_flag, ok ? "pass" : "fail");
  return 0;
}

Source in the repository

Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page

Expected and observed

Expected

check=pass

Observed where it behaves incorrectly

site-gcc--gcc-c-motion-mapper-rejected.c: In function ‘main’:
site-gcc--gcc-c-motion-mapper-rejected.c:89:32: error: ‘to’ clause with modifier other than ‘iterator’ or ‘present’
   89 |   #pragma omp target update to(mapper(mm): s)
      |                                ^~~~~~
site-gcc--gcc-c-motion-mapper-rejected.c:89:32: error: expected ‘)’ before ‘mapper’
   89 |   #pragma omp target update to(mapper(mm): s)
      |                               ~^~~~~~
      |                                )

What the specification requires

The specification text this program relies on and the compiler is expected to support.

OpenMP 5.2 §5.9.1 p.166

Evidence

Other compilers run it correctly

AFAR 24.3.0, CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4