OffTarget

Observed issues › clang-c-map-iterator-omp51

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

OpenMP 5.1/5.2/6.0 forms HPE does not claim are rejected, and some crash the compiler instead of a diagnostic

Legality: not independently confirmed. no independent review yet How this is checked

Same issue as catalog/cce-c-map-iterator-ice; this program is another reproducer of it.

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.0not supportednot supportednot supportednot supportednot supportedn/an/a
CCE 19.0.0not supportednot supportednot supportedunknown
not run
unknown
not run
n/an/a
CCE 20.0.2not supportednot supportednot supportedunknown
not run
unknown
not run
n/an/a
CCE 21.0.3not supportednot supportednot supportedunknown
not run
unknown
not run
n/an/a
CCE 21.0.4not supportednot supportednot supportedunknown
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.0correctcorrectcorrectcorrectcorrectcorrectn/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 supportedAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI250X
AFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
CCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 19.0.0, MI250X
CCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 20.0.2, MI250X
CCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.3, MI250X
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
CCE 21.0.4, MI250X
show
clang-c-map-iterator-omp51.c:7:46: error: incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'
    7 |   #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)
      |                                              ^
1 error generated.
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
"clang-c-map-iterator-omp51.c", line 7: error: invalid text in pragma
    #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)
                                    ^
"clang-c-map-iterator-omp51.c", line 7: error: invalid text in pragma
    #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)
                                       ^
"clang-c-map-iterator-omp51.c", line 7: error: extra text after expected end of preprocessing directive
    #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)

Reproduce

AFAR 24.3.0, MI300A unified

$AFAR/bin/amdclang -fopenmp --offload-arch=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 19.0.0, MI300A unified

module load cce/19.0.0 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 20.0.2, MI300A unified

module load cce/20.0.2 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.3, MI300A unified

module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.4, MI300A unified

module load cce/21.0.4 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

GCC 16.2.0, MI300A unified (runs correctly)

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
Program (45 lines)
/* Finding (C), reproducer replaced: at OpenMP 5.1
   (the default of both clang C front ends) the iterator map-type modifier
   is rejected.

   Legal OpenMP 5.1 C: iterator(iterators-definition) is a map-type-modifier
   of the map clause (5.1 §2.21.7.1 p.347). The iterator it = 0:1 has the
   one value 0 (C ranges exclude the end, 5.1 §2.1.6 p.49), so the map is
   map(tofrom: a[0:n]); with one instance no two instances share a
   containing array (5.1 §2.21.7.1 p.353: "the list item instances that
   would result from different values of the iterator must not have the
   same containing array"). The first reproducer, map(iterator(it = 0:n),
   tofrom: a[it]) as in omp_vv test_target_map_iterators.c, broke that
   restriction and was withdrawn.
   Expected: "RESULT ran_on_host=0 check=pass".

   Observed (tuolumne, MI300A, -O2, HSA_XNACK 1 and 0, 3 runs each,
   2026-10-22, data/evidence/triage_probe/map_iter.c, results/t27b/probes_fr1.jsonl):
   - AFAR amdclang 24.0.0git and CCE craycc 19.0.0, 20.0.2, 21.0.3, with
     their default flags and with -fopenmp-version=51: "error: incorrect
     map type modifier, expected one of: 'always', 'close', 'mapper',
     'present', 'ompx_hold'".
   - At -fopenmp-version=52: AFAR correct in both modes; CCE craycc 19, 20
     and 21 crash in the front end (internal compiler error, "clang
     frontend command failed due to signal").
   The AMD clang status table at the AFAR commit lists "device | iterators
   in map clause or motion clauses | done" in its 5.1 section.

   amdclang -fopenmp --offload-arch=gfx942 [-fopenmp-version=51] -O2
   craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa
          -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 */
#include <stdio.h>
#include <omp.h>
enum { n = 8 };
int main(void) {
  int a[n], bad = 0, host_flag = 1;
  for (int i = 0; i < n; i++) a[i] = i;
  #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)
  {
    host_flag = omp_is_initial_device() ? 1 : 0;
    for (int i = 0; i < n; i++) a[i] += 1;
  }
  for (int i = 0; i < n; i++) bad += a[i] != i + 1;
  printf("RESULT ran_on_host=%d check=%s\n", host_flag, bad ? "fail" : "pass");
  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

RESULT ran_on_host=0 check=pass

Observed where it behaves incorrectly

clang-c-map-iterator-omp51.c:7:46: error: incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'
    7 |   #pragma omp target map(iterator(it = 0:1), tofrom: a[it:n]) map(tofrom: host_flag)
      |                                              ^
1 error generated.

What the specification requires

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

OpenMP 5.1 §2.21.7.1 p.347

OpenMP 5.1 §2.1.6 p.49

OpenMP 5.1 §2.21.7.1 p.353

the list item instances that would result from different values of the iterator must not have the same containing array

Evidence

Same compiler, one change

  • map(tofrom: a[0:n]) without the iterator modifier: AFAR 24.3.0: correct; CCE 19.0.0: correct; CCE 20.0.2: correct; CCE 21.0.3: correct; CCE 21.0.4: correct
    Control program
    #include <stdio.h>
    #include <omp.h>
    enum { n = 8 };
    int main(void) {
      int a[n], bad = 0, host_flag = 1;
      for (int i = 0; i < n; i++) a[i] = i;
      #pragma omp target map(tofrom: a[0:n]) map(tofrom: host_flag)
      {
        host_flag = omp_is_initial_device() ? 1 : 0;
        for (int i = 0; i < n; i++) a[i] += 1;
      }
      for (int i = 0; i < n; i++) bad += a[i] != i + 1;
      printf("RESULT ran_on_host=%d check=%s\n", host_flag, bad ? "fail" : "pass");
      return 0;
    }
    

Other compilers run it correctly

GCC 16.2.0