Observed issues › clang-c-declare-target-to-omp52
Appears not to supportRefused at compile time · C · OpenMP · Open
Declare target to(f) rejected ("unexpected 'to' clause, use 'enter' instead")
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
Affected variants
| Compiler | MI300A 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.0 | not supported | not supported | not supported | not supported | not supported | n/a | n/a |
| CCE 19.0.0 | not supported | not supported | not supported | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | not supported | not supported | not supported | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | not supported | not supported | not supported | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | not supported | not supported | not supported | unknown not run | unknown not run | n/a | n/a |
| NVHPC 25.11 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| GCC 16.2.0 | correct | correct | correct | correct | correct | correct | n/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
| Result | Compiler and GPU | Message |
|---|---|---|
| not supported | AFAR 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 | showclang-c-declare-target-to-omp52.c:5:28: error: unexpected 'to' clause, use 'enter' instead
5 | #pragma omp declare target to(f) device_type(any)
| ^
clang-c-declare-target-to-omp52.c:5:21: error: expected at least one 'enter', 'link' or 'indirect' clause
5 | #pragma omp declare target to(f) device_type(any)
| ^
2 errors generated. |
Reproduce
AFAR 24.3.0, MI300A unified
$AFAR/bin/amdclang -fopenmp --offload-arch=gfx942 -fopenmp-version=52 -fopenmp-version=52 -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 -fopenmp-version=52 -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=52 -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=52 -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=52 -O2 repro.c -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
NVHPC 25.11, A100 separate (runs correctly)
export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib nvc -mp=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.c -o repro OMP_TARGET_OFFLOAD=mandatory ./repro
Program (46 lines)
/* Finding (C): at -fopenmp-version=52 both clang C front ends
reject the deprecated but normative `to` clause of declare target.
Legal OpenMP 5.2 C. "The clause-name to may be used as a synonym for the
clause-name enter. This use has been deprecated." (5.2 §5.8.4 p.158; also
Appendix B.1 p.625), and "deprecated"
is "the property that it is normative in the current specification but
is considered obsolescent and will be removed in the future" (5.2
§1.2.7 p.20); 6.0 removes it (the catalog's 6.0 programs use enter).
Expected: "RESULT ran_on_host=0 check=pass".
Observed (tuolumne, MI300A, HSA_XNACK=1, -O2, 2026-10-22,
data/evidence/triage_probe/dt_to.c, results/t27b/probes.jsonl): AFAR amdclang
24.0.0git and CCE craycc 19.0.0, 20.0.2, 21.0.3 at -fopenmp-version=52:
"error: unexpected 'to' clause, use 'enter' instead"; without the flag
(their default, OpenMP 5.1) all four compile and run it correctly. The
catalog's omp52-c-clause-device_type, -device_type-any, -device_type-
nohost programs were rejected on every compiler because of it; since
Those C ports use enter(f), so they measure
device_type.
Legality rests on the quoted spec text only: there is no independent
compiler witness (cited gcc 13.3.1 -fopenmp; gfortran/gcc -fopenmp
are withdrawn as offload legality witnesses, data/reports/rulings.md).
amdclang -fopenmp --offload-arch=gfx942 -fopenmp-version=52 -O2
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942
-fopenmp-version=52 -O2 */
#include <stdio.h>
#include <omp.h>
enum { n = 64 };
int f(int x) { return 2 * x + 1; }
#pragma omp declare target to(f) device_type(any)
int main(void) {
int a[n], b[n], bad = 0, host_flag = 1;
for (int i = 0; i < n; i++) { a[i] = i + 1; b[i] = 0; }
#pragma omp target map(to: a) map(from: b) map(tofrom: host_flag)
{
host_flag = omp_is_initial_device() ? 1 : 0;
for (int i = 0; i < n; i++) b[i] = f(a[i]);
}
for (int i = 0; i < n; i++) bad += b[i] != 2 * (i + 1) + 1;
printf("RESULT ran_on_host=%d check=%s\n", host_flag, bad ? "fail" : "pass");
return 0;
}
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-declare-target-to-omp52.c:5:28: error: unexpected 'to' clause, use 'enter' instead
5 | #pragma omp declare target to(f) device_type(any)
| ^
clang-c-declare-target-to-omp52.c:5:21: error: expected at least one 'enter', 'link' or 'indirect' clause
5 | #pragma omp declare target to(f) device_type(any)
| ^
2 errors generated.What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §5.8.4 p.158
The clause-name to may be used as a synonym for the clause-name enter. This use has been deprecated.
OpenMP 5.2 §1.2.7 p.20
the property that it is normative in the current specification but is considered obsolescent and will be removed in the future
Evidence
Same compiler, one change
- enter(f) instead of to(f): 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 = 64 }; int f(int x) { return 2 * x + 1; } #pragma omp declare target enter(f) device_type(any) int main(void) { int a[n], b[n], bad = 0, host_flag = 1; for (int i = 0; i < n; i++) { a[i] = i + 1; b[i] = 0; } #pragma omp target map(to: a) map(from: b) map(tofrom: host_flag) { host_flag = omp_is_initial_device() ? 1 : 0; for (int i = 0; i < n; i++) b[i] = f(a[i]); } for (int i = 0; i < n; i++) bad += b[i] != 2 * (i + 1) + 1; printf("RESULT ran_on_host=%d check=%s\n", host_flag, bad ? "fail" : "pass"); return 0; }
Other compilers run it correctly
NVHPC 25.11, NVHPC 26.9, GCC 16.2.0