Observed issues › harvest/gcc-c-target-data-two-maps-ice
The same variable in two map clauses of a target data construct: internal compiler error
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
OpenMP 5.2 allows a list item in more than one map clause of one directive. GCC 16.2 stops with an internal compiler error (install_var_field, omplower) on a target data construct with map(alloc: x) map(from: x), for both offload targets. With the variable in one map clause the same program compiles and runs correctly. AFAR runs the harvested programs correctly.
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 | unknown not run | correct | correct | n/a | n/a |
| CCE 19.0.0 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | fails another way | fails another way | unknown not run | 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 | behaves incorrectly | behaves incorrectly | behaves incorrectly | behaves incorrectly | behaves incorrectly | behaves incorrectly | 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 | GCC 16.2.0, MI300A unified GCC 16.2.0, MI300A copy | showduring GIMPLE pass: omplower
site-harvest--gcc-c-target-data-two-maps-ice.c: In function ‘main’:
site-harvest--gcc-c-target-data-two-maps-ice.c:30:9: internal compiler error: in install_var_field, at omp-low.cc:806
30 | #pragma omp target data map(alloc: x) map(from: x)
| ^~~
0x1fb617d internal_error(char const*, ...)
<dir>:787
0x7c3513 fancy_abort(char const*, int, char const*) |
| behaves incorrectly | GCC 16.2.0, MI250X | showduring GIMPLE pass: omplower
site-harvest--gcc-c-target-data-two-maps-ice.c: In function ‘main’:
site-harvest--gcc-c-target-data-two-maps-ice.c:27:9: internal compiler error: in install_var_field, at omp-low.cc:806
27 | #pragma omp target data map(alloc: x) map(from: x)
| ^~~
0x1fb617d internal_error(char const*, ...)
<dir><host>-gcc-src/gcc-16.2.0/gcc/diagnostic-global-context.cc:787
0x7c3513 fancy_abort(char const*, int, char const*) |
| behaves incorrectly | GCC 16.2.0, MI300X GCC 16.2.0, MI350X | showduring GIMPLE pass: omplower
site-harvest--gcc-c-target-data-two-maps-ice.c: In function ‘main’:
site-harvest--gcc-c-target-data-two-maps-ice.c:30:9: internal compiler error: in install_var_field, at omp-low.cc:806
30 | #pragma omp target data map(alloc: x) map(from: x)
| ^~~
0x1fc4d9d internal_error(char const*, ...)
<home>/<user>/gcc-work/gcc-16.2.0/gcc/diagnostic-global-context.cc:787
0x7b9dae fancy_abort(char const*, int, char const*) |
| behaves incorrectly | GCC 16.2.0, A100 separate | showduring GIMPLE pass: omplower
site-harvest--gcc-c-target-data-two-maps-ice.c: In function ‘main’:
site-harvest--gcc-c-target-data-two-maps-ice.c:27:9: internal compiler error: in install_var_field, at omp-low.cc:806
27 | #pragma omp target data map(alloc: x) map(from: x)
| ^~~
0x208693b internal_error(char const*, ...)
<home>/gcc-build/gcc-16.2.0/gcc/diagnostic-global-context.cc:787
0x7c5659 fancy_abort(char const*, int, char const*) |
| fails another way | CCE 19.0.0, MI300A unified CCE 19.0.0, MI300A copy | showrepro: libcrayacc/acc_clang_wrapper.c:761: void TransferList::validate_clang_flags(int64_t): Assertion `clang_flags == 0' failed. |
| fails another way | CCE 20.0.2, MI300A unified CCE 20.0.2, MI300A copy CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showrepro: libcrayacc/acc_clang_wrapper.c:1009: void TransferList::validate_clang_flags(int64_t): Assertion `clang_flags == 0' failed. |
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 (41 lines)
// # Finding (GCC 16.2, LLVM/AOMP harvest): the same variable in two map clauses of a target data construct: internal compiler
// error in install_var_field
//
// - 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
// - 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: ice: internal compiler error: in install_var_field
// - observed: `internal compiler error: in install_var_field, at omp-low.cc:806` ("during GIMPLE pass: omplower") at the target
// data directive, on both targets (the host compiler fails before any offload code is made)
// - expected: compiles; prints `x= 222` and `RESULT ran_on_host=0 check=pass`
// - rule: "A list item may appear more than once in the map clauses that are specified on the same directive" (5.2 §5.8.3 p.151
// l.14-15).
// - same-compiler control (compiles; correct, gcc_sm80: mandatory pass 5 of 5; unset pass 5 of 5; gcc_g90: mandatory pass 5 of 5;
// unset pass 5 of 5 (results/parity/<machine>/<tc>/probes.jsonl)): the variable in one map clause, map(from: x)
// (controls/gcc-c-target-data-two-maps-control.c).
// - other families: AFAR runs the harvested programs correctly (copy mode, MI300A and MI250X); CCE 19/20/21 and NVHPC 25.11/26.9
// fail them differently (results/harvest/main). The site's finding matrix runs this file on every compiler.
// - harvested programs (8 cells (4 gcc_g90, 4 gcc_sm80); gate: confirmed 8; confirmer: compiler_bug (R10-compile-ice)
// 8): h2-gomp-ccc-target-map-multi-4, hv-llvm-mapping-map-ordering-tgt-data-alloc-from,
// hv-llvm-mapping-map-ordering-tgt-data-alloc-to-from, hv-llvm-mapping-map-ordering-tgt-exit-data-delete-from
// - legality: the pre-run check (offload.engine.prerun.check: the rules and AFAR's front end, two witnesses) accepts the harvested
// programs; this file is read against the rule above. GCC is a compiler under test only and never a legality witness.
#include <stdio.h>
#include <omp.h>
int main(void) {
int x = 111, host_flag = 1;
/* the same list item in two map clauses of one target data construct */
#pragma omp target data map(alloc: x) map(from: x)
{
#pragma omp target map(present, alloc: x) map(tofrom: host_flag)
{
host_flag = omp_is_initial_device();
x = 222;
}
}
printf("x= %d\n", x);
printf("RESULT ran_on_host=%d check=%s\n", host_flag, x == 222 ? "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
during GIMPLE pass: omplower
site-harvest--gcc-c-target-data-two-maps-ice.c: In function ‘main’:
site-harvest--gcc-c-target-data-two-maps-ice.c:30:9: internal compiler error: in install_var_field, at omp-low.cc:806
30 | #pragma omp target data map(alloc: x) map(from: x)
| ^~~
0x1fb617d internal_error(char const*, ...)
<dir>:787
0x7c3513 fancy_abort(char const*, int, char const*)What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §5.8.3 p.151 l.14-15
A list item may appear more than once in the map clauses that are specified on the same directive
Evidence
Same compiler, one change
- the variable in one map clause, map(from: x): not run yet
Control program
// Control of harvest/gcc-c-target-data-two-maps-ice.c: the variable in one map clause (compiles; correct on gcc_g90 and // gcc_sm80). #include <stdio.h> #include <omp.h> int main(void) { int x = 111, host_flag = 1; /* control: the list item in one map clause */ #pragma omp target data map(from: x) { #pragma omp target map(present, alloc: x) map(tofrom: host_flag) { host_flag = omp_is_initial_device(); x = 222; } } printf("x= %d\n", x); printf("RESULT ran_on_host=%d check=%s\n", host_flag, x == 222 ? "pass" : "fail"); return 0; }
Other compilers run it correctly
AFAR 24.3.0, NVHPC 25.11, NVHPC 26.9