OffTarget

Observed issues › catalog/nvhpc-c-static-local-kernel-missing

Appears to behave incorrectlyRun-time error · C · OpenMP · Open

nvc/nvfortran -mp=gpu: compile succeeds but the kernel is missing at run time ("Failed to find device function") for function pointers, static locals, VLAs, long double, type-bound calls

Legality: not independently confirmed. no independent review yet How this is checked

Same issue as catalog/nvhpc-c-function-pointer-kernel-missing; this program is another reproducer of it.

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.0correctcorrectunknown
not run
correctcorrectn/an/a
CCE 19.0.0correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/abehaves incorrectlybehaves incorrectly
NVHPC 26.9n/an/an/an/an/abehaves incorrectlybehaves incorrectly
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
behaves incorrectlyNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
Accelerator Fatal Error: Failed to find device function 'nvkernel_main_F1L24_2'! File was compiled with: -gpu=cc80
Rebuild this file with -gpu=cc80 to use NVIDIA Tesla GPU 0
 File: <dir>/nvhpc-c-static-local-kernel-missing.c
 Function: main:15
 Line: 24

Reproduce

NVHPC 25.11, A100 separate

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvc -mp=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.c -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro

NVHPC 26.9, A100 separate

export LD_LIBRARY_PATH=$NVHPC_26_9/compilers/lib
nvc -mp=gpu -gpu=cc80 -gpu=mem:separate -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 -fopenmp-version=52 -fopenmp-version=52 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (64 lines)
// # Draft finding: omp52-c-w-save-local-routine on nvhpc
//
// - compiler: nvhpc
// - toolchain: nvhpc; arch: sm_80; machine: wingtip; memory mode: copy; opt: -O2
// - program: catalog omp52-c-w-save-local-routine (c, version 52, sha256 867d9b2fcaa9ad8f)
// - expected: check=pass (trusted; elision + model)
// - actual: run_error  (exit_status: 1; without mandatory: exit_status: 1) [the confirmer's class run_error; the matrix's class of the same run is wrong_answer: a run that fails]
// - observed: nvc warns "NVC++-W-1053-External and Static variables are not supported in acc routine - cnt" and still compiles; the run ends with "Accelerator Fatal Error: Failed to find device function 'nvkernel_main_...'" (25.11 and 26.9, both memory modes). A warning, then no kernel: the program is legal (OpenMP 5.2 §7.8, p.204), so the target region should either run or the compile should 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/copy, cce19/gfx942/copy, cce20/gfx942/copy, cce21/gfx942/copy, elision, nvhpc/sm_80/copy (port:omp52-w-save-local-routine), nvhpc269/sm_80/copy (p ...
// - 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/copy, cce19/gfx942/copy, cce20/gfx942/copy, cce21/gfx942/copy, elision, nvhpc/sm_80/copy (port:omp52-w-save-local-routine), nvhpc269/sm_80/copy (port:omp52-w-save-local-routine)
// - withdrawn: none
//
// Generated by compliance.widen (OpenMP 5.2, C11; catalog widening). Do not edit.
// id: omp52-c-w-save-local-routine
// primary atom: base.device.save_local
// atoms: base.device.save_local
// legal: yes
// observable: yes
// ran_on_host: inside the target region of interest
// evidence: construct
// needs: none
// std: c11
// feature: a static local variable of a declare target function, updated by sequential calls in one target region
// spec: OpenMP 5.2 §7.8, p.204: a variable with static storage duration declared in a device routine is treated as if it appeared in an enter clause on a declare target directive
#include <stdio.h>
#include <stdbool.h>
#include <omp.h>

enum { n = 64 };

#pragma omp declare target
int bump(void) {
  static int cnt = 0;
  cnt = cnt + 1;
  return cnt;
}
#pragma omp end declare target

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 ? i + 1 : 0;
  }
  #pragma omp target map(tofrom: b, host_flag)
  {
    host_flag = omp_is_initial_device();
    b[0] = bump();
    b[1] = bump();
    b[2] = bump();
  }
  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;
}

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

Expected

check=pass

Observed where it behaves incorrectly

Accelerator Fatal Error: Failed to find device function 'nvkernel_main_F1L24_2'! File was compiled with: -gpu=cc80
Rebuild this file with -gpu=cc80 to use NVIDIA Tesla GPU 0
 File: <dir>/nvhpc-c-static-local-kernel-missing.c
 Function: main:15
 Line: 24

What the specification requires

The specification text this program relies on and the compiler is expected to support.

OpenMP 5.2 §7.8 p.204

OpenMP 5.2 §7.8 p.204

Evidence

Same compiler, one change

  • cnt a file-scope variable inside the declare target region instead of a static local: 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; NVHPC 25.11: correct; NVHPC 26.9: correct
    Control program
    #include <stdio.h>
    #include <stdbool.h>
    #include <omp.h>
    
    enum { n = 64 };
    
    #pragma omp declare target
    int cnt = 0;
    int bump(void) {
      cnt = cnt + 1;
      return cnt;
    }
    #pragma omp end declare target
    
    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 ? i + 1 : 0;
      }
      #pragma omp target map(tofrom: b, host_flag)
      {
        host_flag = omp_is_initial_device();
        b[0] = bump();
        b[1] = bump();
        b[2] = bump();
      }
      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;
    }
    

Other compilers run it correctly

AFAR 24.3.0, CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, GCC 16.2.0