OffTarget

Observed issues › catalog/afar-c-ordered-doacross-link

Appears not to supportRefused at link time · C · OpenMP · Open

amdclang: ordered(1) on a parallel for in a target region fails at the device link (__kmpc_doacross_init undefined)

Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked

Affected variants

CompilerMI300A 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.0not supportednot supportednot supportednot supportednot supportedn/an/a
CCE 19.0.0fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 20.0.2fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 21.0.3fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 21.0.4fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/afails another wayfails another way
NVHPC 26.9n/an/an/an/an/afails another wayfails another way
GCC 16.2.0correctcorrectcorrectcorrectcorrectcorrectn/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

ResultCompiler and GPUMessage
not supportedAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
show
ld.lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
ld.lld: error: undefined symbol: __kmpc_doacross_fini
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
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 supportedAFAR 24.3.0, MI250X
show
ld.lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-5822c8.img.lto.o:(__omp_offloading_14_3793297f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-5822c8.img.lto.o:(__omp_offloading_14_3793297f_main_l19)
ld.lld: error: undefined symbol: __kmpc_doacross_fini
>>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-5822c8.img.lto.o:(__omp_offloading_14_3793297f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.0a.gfx90a-5822c8.img.lto.o:(__omp_offloading_14_3793297f_main_l19)
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 supportedAFAR 24.3.0, MI300X
show
ld.lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>:(__omp_offloading_fc10_20002e5_main_l19)
>>> referenced by <dir>:(__omp_offloading_fc10_20002e5_main_l19)
ld.lld: error: undefined symbol: __kmpc_doacross_fini
>>> referenced by <dir>:(__omp_offloading_fc10_20002e5_main_l19)
>>> referenced by <dir>:(__omp_offloading_fc10_20002e5_main_l19)
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 supportedAFAR 24.3.0, MI350X
show
ld.lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>:(__omp_offloading_fc10_a4_main_l19)
>>> referenced by <dir>:(__omp_offloading_fc10_a4_main_l19)
ld.lld: error: undefined symbol: __kmpc_doacross_fini
>>> referenced by <dir>:(__omp_offloading_fc10_a4_main_l19)
>>> referenced by <dir>:(__omp_offloading_fc10_a4_main_l19)
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 wayCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-itrS5B/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_1c78d114_main_l19)
>>> referenced by <dir>/cooltmpdir-itrS5B/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_1c78d114_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 19.0.0, MI250X
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-HCGmBw/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_37938d2e_main_l19)
>>> referenced by <dir>/cooltmpdir-HCGmBw/repro-cce-openmp__llc.amdgpu:(__omp_offloading_14_37938d2e_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-0Sus9n/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7a16fc_main_l19)
>>> referenced by <dir>/cooltmpdir-0Sus9n/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7a16fc_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 20.0.2, MI250X
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-8ira9B/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_37901935_main_l19)
>>> referenced by <dir>/cooltmpdir-8ira9B/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_37901935_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-uCRFuS/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c79c012_main_l19)
>>> referenced by <dir>/cooltmpdir-uCRFuS/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c79c012_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 21.0.3, MI250X
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-Txwjz2/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_3792a990_main_l19)
>>> referenced by <dir>/cooltmpdir-Txwjz2/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_3792a990_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-8CgrJ1/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7333b2_main_l19)
>>> referenced by <dir>/cooltmpdir-8CgrJ1/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_1c7333b2_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayCCE 21.0.4, MI250X
show
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
Unknown KMPC: __kmpc_doacross_init
Unknown KMPC: __kmpc_doacross_fini
lld: error: undefined symbol: __kmpc_doacross_init
>>> referenced by <dir>/cooltmpdir-EKLN1Q/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378ac6e8_main_l19)
>>> referenced by <dir>/cooltmpdir-EKLN1Q/repro-cce-openmppost_lld.amdgpu.lto.o:(__omp_offloading_14_378ac6e8_main_l19)
lld: error: undefined symbol: __kmpc_doacross_fini
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
Failing in Thread:1
Accelerator Fatal Error: call to cuMemcpyDtoHAsync returned error 700 (CUDA_ERROR_ILLEGAL_ADDRESS): Illegal address during kernel execution
 File: <dir>/afar-c-ordered-doacross-link.c
 Function: main:7
 Line: 27

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 (58 lines)
// # Draft finding: omp52-c-clause-ordered-n on afar
//
// - compiler: afar
// - toolchain: afar; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
// - program: catalog omp52-c-clause-ordered-n (c, version 52, sha256 872526bfa6d022e4)
// - expected: None (None; )
// - actual: rejected  (link_undefined_symbol: ld.lld: error: undefined symbol: __kmpc_doacross_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-ordered-n. Do not edit.
// id: omp52-c-clause-ordered-n
// primary atom: omp.clause.ordered.n
// legal: yes
// observable: no (equivalent_default: the check covers the device kernel, not the atom)
// ran_on_host: inside the target region of interest
// evidence: equivalent_default
// needs: none
// std: c11
// no oracle (equivalent_default): re-categorised (was implementation_defined): without n the ordered clause behaves as if n were the collapse value, here 1, so ordered(1) on this one-loop nest is the ordered clause without its argument, with or without doacross constructs
// basis: OpenMP 5.2 §4.4.4, p.94: "If n is not specified then the behavior is as if n is specified with the same value as is specified for the collapse clause on the construct."
#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;
  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)
  {
    host_flag = (omp_is_initial_device() ? 1 : 0);
    #pragma omp parallel for default(none) shared(a, b) ordered(1)
    for (int i = 1; i <= n; i++) {
      b[i - 1] = 2 * a[i - 1] + 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;
}

Source in the repository

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_doacross_init
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
ld.lld: error: undefined symbol: __kmpc_doacross_fini
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
>>> referenced by <dir>/repro.amdgpu9.42.gfx942-62835a.img.lto.o:(__omp_offloading_14_1c73934f_main_l19)
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 §4.4.4 p.94

If n is not specified then the behavior is as if n is specified with the same value as is specified for the collapse clause on the construct.

Evidence

Same compiler, one change

  • the ordered(1) clause removed: 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;
      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)
      {
        host_flag = (omp_is_initial_device() ? 1 : 0);
        #pragma omp parallel for default(none) shared(a, b)
        for (int i = 1; i <= n; i++) {
          b[i - 1] = 2 * a[i - 1] + 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

GCC 16.2.0