Observed issues › catalog/afar-c-reduction-task-link
Appears not to supportRefused at link time · C · OpenMP · Open
amdclang: reduction(task, +: s) on a worksharing loop in a target region fails at the device link (__kmpc_taskred_modifier_init 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 | not supported | not supported | not supported | not supported | not supported | 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 | fails another way | fails another way | fails another way | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | fails another way | fails another way | fails another way | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | fails another way | fails another way | fails another way | 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 | AFAR 24.3.0, MI300A unified AFAR 24.3.0, MI300A copy | showld.lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) ld.lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) clang: error: ld.lld command failed with exit code 1 (use -v to see invocation) $AFAR/lib/llvm/bin/clang-linker-wrapper: error: 'clang' failed |
| not supported | AFAR 24.3.0, MI250X | showld.lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-1f19aa.img.lto.o:(__omp_offloading_14_3791e35a_main_l26) >>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-1f19aa.img.lto.o:(__omp_offloading_14_3791e35a_main_l26) ld.lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini >>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-1f19aa.img.lto.o:(__omp_offloading_14_3791e35a_main_l26) >>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-1f19aa.img.lto.o:(__omp_offloading_14_3791e35a_main_l26) clang: error: ld.lld command failed with exit code 1 (use -v to see invocation) $AFAR/lib/llvm/bin/clang-linker-wrapper: error: 'clang' failed |
| not supported | AFAR 24.3.0, MI300X | showld.lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>:(__omp_offloading_fc10_60c7222_main_l26) >>> referenced by <dir>:(__omp_offloading_fc10_60c7222_main_l26) ld.lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini >>> referenced by <dir>:(__omp_offloading_fc10_60c7222_main_l26) >>> referenced by <dir>:(__omp_offloading_fc10_60c7222_main_l26) clang: error: ld.lld command failed with exit code 1 (use -v to see invocation) $AFAR/lib/llvm/bin/clang-linker-wrapper: error: 'clang' failed |
| not supported | AFAR 24.3.0, MI350X | showld.lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>:(__omp_offloading_fc10_402042c_main_l26) >>> referenced by <dir>:(__omp_offloading_fc10_402042c_main_l26) ld.lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini >>> referenced by <dir>:(__omp_offloading_fc10_402042c_main_l26) >>> referenced by <dir>:(__omp_offloading_fc10_402042c_main_l26) clang: error: ld.lld command failed with exit code 1 (use -v to see invocation) $AFAR/lib/llvm/bin/clang-linker-wrapper: error: 'clang' failed |
| fails another way | CCE 19.0.0, MI300A unified CCE 19.0.0, MI300A copy | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-aq8nA6/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_1c6ecd31_main_l26) >>> referenced by <dir>/cooltmpdir-aq8nA6/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_1c6ecd31_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 19.0.0, MI250X | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-QEnAO2/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_3792b3d8_main_l26) >>> referenced by <dir>/cooltmpdir-QEnAO2/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_3792b3d8_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 20.0.2, MI300A unified CCE 20.0.2, MI300A copy | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-nrzZXc/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7de133_main_l26) >>> referenced by <dir>/cooltmpdir-nrzZXc/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7de133_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 20.0.2, MI250X | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-BfLozA/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378d1e82_main_l26) >>> referenced by <dir>/cooltmpdir-BfLozA/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378d1e82_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-Gi3LBR/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c76fe7b_main_l26) >>> referenced by <dir>/cooltmpdir-Gi3LBR/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c76fe7b_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 21.0.3, MI250X | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-nAdMmg/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378f7e33_main_l26) >>> referenced by <dir>/cooltmpdir-nAdMmg/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378f7e33_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-W0kXby/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c78b509_main_l26) >>> referenced by <dir>/cooltmpdir-W0kXby/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c78b509_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | CCE 21.0.4, MI250X | showUnknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini Unknown KMPC: __kmpc_taskred_modifier_init Unknown KMPC: __kmpc_task_reduction_modifier_fini lld: error: undefined symbol: __kmpc_taskred_modifier_init >>> referenced by <dir>/cooltmpdir-gaeOJu/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378efe1c_main_l26) >>> referenced by <dir>/cooltmpdir-gaeOJu/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378efe1c_main_l26) lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini |
| fails another way | NVHPC 25.11, A100 separate NVHPC 25.11, A100 managed NVHPC 26.9, A100 separate NVHPC 26.9, A100 managed | show"afar-c-reduction-task-link.c", line 31: error: invalid text in pragma
#pragma omp for reduction(task, +: s)
^
"afar-c-reduction-task-link.c", line 31: error: identifier "task" is undefined
#pragma omp for reduction(task, +: s)
^
"afar-c-reduction-task-link.c", line 31: error: invalid text in pragma
#pragma omp for reduction(task, +: s) |
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
GCC 16.2.0, MI300A unified (runs correctly)
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
Program (76 lines)
// # Draft finding: omp52-c-clause-reduction-task on afar
//
// - compiler: afar
// - toolchain: afar; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
// - program: catalog omp52-c-clause-reduction-task (c, version 52, sha256 54be3b72d697c751)
// - expected: None (None; )
// - actual: rejected (link_undefined_symbol: ld.lld: error: undefined symbol: __kmpc_taskred_modifier_init)
// - 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-reduction-task. Do not edit.
// id: omp52-c-clause-reduction-task
// primary atom: omp.clause.reduction.task
// legal: yes
// observable: yes
// 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 main(void) {
int a[n];
int b[n];
int ref[n];
int host_flag;
bool ok;
int s;
int sref;
for (int i = 1; i <= n; i++) {
a[i - 1] = i;
b[i - 1] = 0;
ref[i - 1] = 2 * i + 1;
}
host_flag = 1;
s = 0;
sref = 0;
for (int i = 1; i <= n; i++) {
sref = sref + a[i - 1];
}
#pragma omp target map(to: a) map(from: b) map(tofrom: host_flag) map(tofrom: s)
{
host_flag = (omp_is_initial_device() ? 1 : 0);
#pragma omp parallel default(none) shared(a, b, s)
{
#pragma omp for reduction(task, +: s)
for (int i = 1; i <= n; i++) {
b[i - 1] = 2 * a[i - 1] + 1;
s = s + a[i - 1];
}
}
}
bool t1_ = true;
for (int k2_ = 0; k2_ < n; k2_++)
t1_ = t1_ && (b[k2_] == ref[k2_]);
ok = t1_ && (s == sref);
printf("RESULT ran_on_host=%d check=%s\n", host_flag, ok ? "pass" : "fail");
return 0;
}
// spec (requirement): The task reduction-modifier on a reduction clause of a parallel or worksharing construct
// privatizes the list item and supports task reductions.
// "If the task reduction-modifier is present for a parallel or worksharing construct, then each list item is
// privatized according to the description and restrictions in Section 5.3" (5.2 §5.5.8 p.135 l.16-18)
// spec (requirement): After the region the original list item contains the result of the reduction.
// "After the end of the region, the original list item contains the result of the reduction." (5.2 §5.5.8 p.135
// l.21-22)
// spec (this program): reduction(task, +: s) on a worksharing loop inside a parallel region in a target region must
// leave the sum of a in s; amdclang fails at the device link (__kmpc_taskred_modifier_init 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_taskred_modifier_init >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) ld.lld: error: undefined symbol: __kmpc_task_reduction_modifier_fini >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) >>> referenced by <dir>/repro.amdgpu9.42.gfx942-836dd5.img.lto.o:(__omp_offloading_14_1c7816b1_main_l26) clang: error: ld.lld command failed with exit code 1 (use -v to see invocation) $AFAR/lib/llvm/bin/clang-linker-wrapper: error: 'clang' failed
What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §5.5.8 p.135 l.16-18
If the task reduction-modifier is present for a parallel or worksharing construct, then each list item is privatized according to the description and restrictions in Section 5.3
OpenMP 5.2 §5.5.8 p.135 l.21-22
After the end of the region, the original list item contains the result of the reduction.
Evidence
Same compiler, one change
- reduction(+: s) without the task 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 s; int sref; for (int i = 1; i <= n; i++) { a[i - 1] = i; b[i - 1] = 0; ref[i - 1] = 2 * i + 1; } host_flag = 1; s = 0; sref = 0; for (int i = 1; i <= n; i++) { sref = sref + a[i - 1]; } #pragma omp target map(to: a) map(from: b) map(tofrom: host_flag) map(tofrom: s) { host_flag = (omp_is_initial_device() ? 1 : 0); #pragma omp parallel default(none) shared(a, b, s) { #pragma omp for reduction(+: s) for (int i = 1; i <= n; i++) { b[i - 1] = 2 * a[i - 1] + 1; s = s + a[i - 1]; } } } bool t1_ = true; for (int k2_ = 0; k2_ < n; k2_++) t1_ = t1_ && (b[k2_] == ref[k2_]); ok = t1_ && (s == sref); printf("RESULT ran_on_host=%d check=%s\n", host_flag, ok ? "pass" : "fail"); return 0; }
Other compilers run it correctly
GCC 16.2.0