Observed issues › catalog/cce-c-lastprivate-parallel-in-seq-loop-wrong
craycc: lastprivate and linear on a parallel for in a target region do not return the final value
Legality: not independently confirmed. no independent review yet How this is checked
Same issue as cce-c-parallel-for-in-target; this program is another reproducer of it.
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 | correct | correct | correct | correct | correct | n/a | n/a |
| CCE 19.0.0 | behaves incorrectly | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | behaves incorrectly | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | behaves incorrectly | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | behaves incorrectly | behaves incorrectly | behaves incorrectly | 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 |
|---|---|---|
| behaves incorrectly | 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 | showRESULT ran_on_host=0 check=fail |
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=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
AFAR 24.3.0, MI300A unified (runs correctly)
$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
Program (60 lines)
// # Draft finding: omp52-c-w-lastprivate-parallel-in-seq-loop on cce19
//
// - compiler: cce19
// - toolchain: cce19; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
// - program: catalog omp52-c-w-lastprivate-parallel-in-seq-loop (c, version 52, sha256 26a32d8bcc61408e)
// - expected: check=pass (trusted; elision + model)
// - actual: wrong_answer check=fail (check_fail: ran_on_host=0 check=fail)
// - verdict: compiler_bug by rule R20-runtime-bug: a legal program fails at run time, deterministically, against an expected value from two or more independent sources with an executed witness, and another toolchain, mode, arch or the elision gives the expected value
// - reason: expected trusted check=pass (elision + model): stored main verdict: elision + model agree; witnesses: afar/gfx942/unified, afar/gfx942/unified (port:omp52-w-lastprivate-parallel-in-seq-loop), elision
// - citations: RUL-DERIVED-NEEDS-EXECUTION (rulings.md); RUL-WITNESS-PER-MODE (rulings.md); RUL-SAME-COMPILER-RUNS (rulings.md); RUL-PRESENCE-WITNESS (rulings.md); RUL-METAMORPHIC-OTHER-FAMILY (rulings.md)
// - legality: legal: offload.engine.prerun.check accepts it (rerun: offload.engine.rules with the
// race rule and the restriction checks, and the AFAR clang front end, not under test here); no
// compiler under test, gfortran or gcc is a legality witness
// - witnesses: afar/gfx942/unified, afar/gfx942/unified (port:omp52-w-lastprivate-parallel-in-seq-loop), elision
// - withdrawn: none
//
// Generated by compliance.widen (OpenMP 5.2, C11; catalog widening). Do not edit.
// id: omp52-c-w-lastprivate-parallel-in-seq-loop
// primary atom: pair.omp.clause.lastprivate+base.device.parallel_in_seq_loop
// atoms: pair.omp.clause.lastprivate+base.device.parallel_in_seq_loop, omp.clause.lastprivate, base.device.parallel_in_seq_loop
// legal: yes
// observable: yes
// ran_on_host: inside the target region of interest
// evidence: construct
// needs: none
// std: c11
// feature: lastprivate on a parallel for nested in a sequential loop of a target region
// spec: the parts' own programs
// pair of: omp.clause.lastprivate + base.device.parallel_in_seq_loop (each has a program of its own)
#include <stdio.h>
#include <stdbool.h>
#include <omp.h>
enum { n = 64 };
int main(void) {
int a[n], b[n], ref[n];
int host_flag = 1;
for (int i = 0; i < n; i++) {
a[i] = i + 1;
b[i] = 0;
ref[i] = i < 3 ? n + i : 0;
}
#pragma omp target map(to: a) map(tofrom: b, host_flag)
{
host_flag = omp_is_initial_device();
for (int k = 0; k < 3; k++) {
int last = 0;
#pragma omp parallel for lastprivate(last)
for (int i = 0; i < n; i++)
last = a[i] + k;
b[k] = last;
}
}
bool ok = true;
for (int i = 0; i < n; i++)
ok = ok && (b[i] == ref[i]);
printf("RESULT ran_on_host=%d check=%s\n", host_flag, ok ? "pass" : "fail");
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
check=pass
Observed where it behaves incorrectly
RESULT ran_on_host=0 check=fail
What the specification requires
The specification text this program relies on and the compiler is expected to support.
The same requirement as the issue cce-c-parallel-for-in-target.
OpenMP 5.2 §11.5
OpenMP 5.2 §5.4.5
OpenMP 5.2 §5.4.6
Evidence
Other compilers run it correctly
AFAR 24.3.0, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0