Observed issues › catalog/cce-c-allocate-align-link
Appears not to supportRefused at link time · C · OpenMP · Open
craycc: allocate(allocator(...), align(8): t) in a target region fails at the device link (__kmpc_aligned_alloc undefined)
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 | correct | correct | correct | correct | correct | n/a | n/a |
| CCE 19.0.0 | fails another way | fails another way | fails another way | 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 | fails another way | fails another way |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | fails another way | fails another way |
| 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 | CCE 20.0.2, MI300A unified CCE 20.0.2, MI300A copy | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-159e9a.o:(__omp_offloading_14_1c67bc45_main_l20_cray$mt$p0002) clang: error: linker command failed with exit code 1 (use -v to see invocation) |
| not supported | CCE 20.0.2, MI250X | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-84496a.o:(__omp_offloading_14_37846f69_main_l20_cray$mt$p0002) clang: error: linker command failed with exit code 1 (use -v to see invocation) |
| not supported | CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-1aa00d.o:(__omp_offloading_14_1c712e2d_main_l20_cray$mt$p0002) craycc: error: linker command failed with exit code 1 (use -v to see invocation) |
| not supported | CCE 21.0.3, MI250X | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-aeebab.o:(__omp_offloading_14_37909b98_main_l20_cray$mt$p0002) craycc: error: linker command failed with exit code 1 (use -v to see invocation) |
| not supported | CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-9574b6.o:(__omp_offloading_14_1c73a5f8_main_l20_cray$mt$p0002) craycc: error: linker command failed with exit code 1 (use -v to see invocation) |
| not supported | CCE 21.0.4, MI250X | showld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-29de90.o:(__omp_offloading_14_3790b6c6_main_l20_cray$mt$p0002) craycc: error: linker command failed with exit code 1 (use -v to see invocation) |
| fails another way | CCE 19.0.0, MI300A unified CCE 19.0.0, MI300A copy CCE 19.0.0, MI250X | showcce-c-allocate-align-link.c:25:18: error: call to undeclared function 'allocator'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
25 | allocate(allocator(omp_default_mem_alloc), align(8): t)
| ^
cce-c-allocate-align-link.c:25:18: note: did you mean 'alloca'?
/usr/include/alloca.h:32:14: note: 'alloca' declared here
32 | extern void *alloca (size_t __size) __THROW;
| ^
cce-c-allocate-align-link.c:25:52: error: call to undeclared function 'align'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] |
| fails another way | NVHPC 25.11, A100 separate NVHPC 25.11, A100 managed NVHPC 26.9, A100 separate NVHPC 26.9, A100 managed | show"cce-c-allocate-align-link.c", line 21: error: invalid text in pragma
uses_allocators(omp_default_mem_alloc)
^
"cce-c-allocate-align-link.c", line 21: error: extra text after expected end of preprocessing directive
uses_allocators(omp_default_mem_alloc)
^
"cce-c-allocate-align-link.c", line 25: error: invalid text in pragma
allocate(allocator(omp_default_mem_alloc), align(8): t) |
Reproduce
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 (77 lines)
// # Draft finding: omp52-c-clause-allocate-align on cce20
//
// - compiler: cce20
// - toolchain: cce20; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
// - program: catalog omp52-c-clause-allocate-align (c, version 52, sha256 f07c5cb195c9a71b)
// - expected: None (None; )
// - actual: rejected (link_undefined_symbol: ld.lld: error: undefined symbol: __kmpc_aligned_alloc)
// - verdict: compiler_bug by rule R10b-own-link-or-hang: a link failure on symbols the compiler's own generated code needs, or a compile that does not finish, on a legal program: the compiler's defect (never a rejection)
// - 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 5.2, C11): the C port (offload.engine.f2c) of omp52-clause-allocate-align. Do not edit.
// id: omp52-c-clause-allocate-align
// primary atom: omp.clause.allocate.align
// legal: yes
// observable: no (unverified: the check covers the device kernel, not the atom)
// ran_on_host: inside the target region of interest
// evidence: unverified
// needs: none
// std: c11
// unverified (oracle_not_written): the program does not check the private copy's address: a check of its address modulo an alignment larger than any default (e.g. align(4096)) would fail without the modifier (C mutant survived on AFAR)
#include <stdio.h>
#include <stdbool.h>
#include <omp.h>
enum { n = 64 };
int main(void) {
int a[n];
int b[n];
int ref[n];
int host_flag;
bool ok;
int t;
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) \
uses_allocators(omp_default_mem_alloc)
{
host_flag = (omp_is_initial_device() ? 1 : 0);
#pragma omp parallel for default(none) shared(a, b) private(t) \
allocate(allocator(omp_default_mem_alloc), align(8): t)
for (int i = 1; i <= n; i++) {
t = 2 * a[i - 1];
b[i - 1] = t + 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;
}
// spec (requirement): The allocate clause accepts the allocator and align modifiers with the syntax and semantics of
// the allocate directive's allocator and align clauses.
// "The allocator-complex-modifier and align-modifier have the same syntax and semantics for the allocate clause as
// the allocator and align clauses have for the allocate directive." (5.2 §6.6 p.178 l.16-18)
// spec (requirement): The align modifier makes every allocation at least as aligned as its value.
// "each allocation is byte aligned to at least the maximum of the value to which alignment evaluates, the alignment
// trait of the allocator being used for the allocation, and the alignment required by the base language for the
// type of the variable that is allocated." (5.2 §6.3 p.175 l.3-6)
// spec (requirement): On a target construct and in its region an allocate clause must name its allocator, which the
// program does, with uses_allocators for the predefined allocator.
// "allocate clauses that appear on a target construct or on constructs in a target region must specify an
// allocator-simple-modifier or allocator-complex-modifier unless a requires directive with the dynamic_allocators
// clause is present in the same compilation unit." (5.2 §6.6 p.179 l.8-10)
// spec (this program): allocate(allocator(omp_default_mem_alloc), align(8): t) on a parallel for in a target region
// is a legal allocate clause with both modifiers; craycc fails at the device link because __kmpc_aligned_alloc is
// undefined.
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
ld.lld: error: undefined symbol: __kmpc_aligned_alloc >>> referenced by cce-c-allocate-align-link.c >>> <dir>/cce-c-allocate-align-link-159e9a.o:(__omp_offloading_14_1c67bc45_main_l20_cray$mt$p0002) clang: error: linker command failed with exit code 1 (use -v to see invocation)
What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §6.6 p.178 l.16-18
The allocator-complex-modifier and align-modifier have the same syntax and semantics for the allocate clause as the allocator and align clauses have for the allocate directive.
OpenMP 5.2 §6.3 p.175 l.3-6
each allocation is byte aligned to at least the maximum of the value to which alignment evaluates, the alignment trait of the allocator being used for the allocation, and the alignment required by the base language for the type of the variable that is allocated.
OpenMP 5.2 §6.6 p.179 l.8-10
allocate clauses that appear on a target construct or on constructs in a target region must specify an allocator-simple-modifier or allocator-complex-modifier unless a requires directive with the dynamic_allocators clause is present in the same compilation unit.
Evidence
Same compiler, one change
- allocate(omp_default_mem_alloc: t) without the align 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 main(void) { int a[n]; int b[n]; int ref[n]; int host_flag; bool ok; int t; 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) \ uses_allocators(omp_default_mem_alloc) { host_flag = (omp_is_initial_device() ? 1 : 0); #pragma omp parallel for default(none) shared(a, b) private(t) \ allocate(omp_default_mem_alloc: t) for (int i = 1; i <= n; i++) { t = 2 * a[i - 1]; b[i - 1] = t + 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; }
Other compilers run it correctly
AFAR 24.3.0, GCC 16.2.0