OffTarget

Observed issues › catalog/cce-c-device-type-directive-name-ice

Appears to behave incorrectlyCompiler crash · C · OpenMP · Open

craycc/ftn: 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.0fails another wayfails another wayfails another wayfails another wayfails another wayn/an/a
CCE 19.0.0behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 20.0.2behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 21.0.3behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 21.0.4behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
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.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/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
behaves incorrectlyCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 19.0.0, MI250X
show
cce-c-device-type-directive-name-ice.c:13:57: error: expected ')'
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                         ^
cce-c-device-type-directive-name-ice.c:13:48: note: to match this '('
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                ^
Unexpected device_type
UNREACHABLE executed at /workspace/clang/lib/Parse/ParseOpenMP.cpp:1938!
behaves incorrectlyCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 20.0.2, MI250X
show
cce-c-device-type-directive-name-ice.c:13:57: error: expected ')'
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                         ^
cce-c-device-type-directive-name-ice.c:13:48: note: to match this '('
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                ^
Unexpected device_type
UNREACHABLE executed at /workspace/clang/lib/Parse/ParseOpenMP.cpp:1924!
behaves incorrectlyCCE 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
cce-c-device-type-directive-name-ice.c:13:57: error: expected ')'
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                         ^
cce-c-device-type-directive-name-ice.c:13:48: note: to match this '('
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                ^
Unexpected device_type
UNREACHABLE executed at /workspace/clang/lib/Parse/ParseOpenMP.cpp:1847!
fails another wayAFAR 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
show
cce-c-device-type-directive-name-ice.c:13:57: error: expected ')'
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                         ^
cce-c-device-type-directive-name-ice.c:13:48: note: to match this '('
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                ^
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
"cce-c-device-type-directive-name-ice.c", line 13: error: invalid text in pragma
  #pragma omp declare target enter(f) device_type(declare target: any)
                             ^
"cce-c-device-type-directive-name-ice.c", line 13: error: extra text after expected end of preprocessing directive
  #pragma omp declare target enter(f) device_type(declare target: any)
                             ^
2 errors detected in the compilation of "cce-c-device-type-directive-name-ice.c".
fails another wayGCC 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
cce-c-device-type-directive-name-ice.c:13:49: error: expected ‘host’, ‘nohost’ or ‘any’ before ‘declare’
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                 ^~~~~~~

Reproduce

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 -fopenmp-version=60 -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 -fopenmp-version=60 -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 -fopenmp-version=60 -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 -fopenmp-version=60 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (63 lines)
// # Draft finding: omp60-c-clause-device_type-directive_name on cce19
//
// - compiler: cce19
// - toolchain: cce19; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
// - program: catalog omp60-c-clause-device_type-directive_name (c, version 60, sha256 fd0a4a751c810695)
// - expected: None (None; )
// - actual: ice  (ice: PLEASE submit a bug report to HPE at https://support.hpe.com/ and include the crash backtrace, preprocessed source, and associated run script.)
// - verdict: compiler_bug by rule R10-compile-ice: an internal compiler error (or the compiler rejecting code it generated) on a legal program: always the compiler's defect
// - reason: 
// - citations: RUL-COMPILE-TIME (rulings.md)
// - legality: legal (legal by construction: offload.engine.gen / c_gen / acc_gen check every program against the catalog rules and the offload scope as it is built (no compiler))
// - witnesses: none
// - withdrawn: none
//
// Generated by compliance.c_gen (OpenMP 6.0, C11): the C port (offload.engine.f2c) of omp60-clause-device_type-directive_name. Do not edit.
// id: omp60-c-clause-device_type-directive_name
// primary atom: omp.clause.device_type.directive_name
// legal: yes
// observable: no (f is implicitly declare target without the directive (a procedure referenced in a target construct, 5.2 §13.8 p.285, 6.0 §15.8 p.461), so the clause has no checked effect)
// ran_on_host: inside the target region of interest
// evidence: construct
// needs: none
// std: c11
#include <stdio.h>
#include <stdbool.h>
#include <omp.h>

enum { n = 64 };
int dv = 1;
int dw = 1;
int f(int x) {
  int r_;
  r_ = 2 * x + 1;
  return r_;
}
#pragma omp declare target enter(f) device_type(declare target: any)

int main(void) {
  int a[n];
  int b[n];
  int ref[n];
  int host_flag;
  bool ok;
  for (int i = 1; i <= n; i++) {
    a[i - 1] = i;
    b[i - 1] = 0;
    ref[i - 1] = 2 * i + 1;
  }
  host_flag = 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] = f(a[i - 1]);
    }
  }
  bool t1_ = true;
  for (int k2_ = 0; k2_ < n; k2_++)
    t1_ = t1_ && (b[k2_] == ref[k2_]);
  ok = t1_;
  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

Observed where it behaves incorrectly

cce-c-device-type-directive-name-ice.c:13:57: error: expected ')'
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                         ^
cce-c-device-type-directive-name-ice.c:13:48: note: to match this '('
   13 | #pragma omp declare target enter(f) device_type(declare target: any)
      |                                                ^
Unexpected device_type
UNREACHABLE executed at /workspace/clang/lib/Parse/ParseOpenMP.cpp:1938!

What the specification requires

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

OpenMP 5.2 §13.8 p.285

OpenMP 6.0 §15.8 p.461

Evidence

Same compiler, one change

  • device_type(any) without the directive-name 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 <stdbool.h>
    #include <omp.h>
    
    enum { n = 64 };
    int dv = 1;
    int dw = 1;
    int f(int x) {
      int r_;
      r_ = 2 * x + 1;
      return r_;
    }
    #pragma omp declare target enter(f) device_type(any)
    
    int main(void) {
      int a[n];
      int b[n];
      int ref[n];
      int host_flag;
      bool ok;
      for (int i = 1; i <= n; i++) {
        a[i - 1] = i;
        b[i - 1] = 0;
        ref[i - 1] = 2 * i + 1;
      }
      host_flag = 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] = f(a[i - 1]);
        }
      }
      bool t1_ = true;
      for (int k2_ = 0; k2_ < n; k2_++)
        t1_ = t1_ && (b[k2_] == ref[k2_]);
      ok = t1_;
      printf("RESULT ran_on_host=%d check=%s\n", host_flag, ok ? "pass" : "fail");
      return 0;
    }