OffTarget

Observed issues › nvhpc-c-parallel-for-firstprivate-in-target

Appears to behave incorrectlyCompiler crash · C · OpenMP · Open

nvc -mp=gpu: "Compiler failed to translate OpenMP region" for firstprivate on a parallel for in a target region

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.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
show
NVC++-F-0155-Compiler failed to translate OpenMP region  (nvhpc-c-parallel-for-firstprivate-in-target.c: 7)
NVC++/x86-64 Linux 25.11-0: compilation aborted
behaves incorrectlyNVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVC++-F-0155-Compiler failed to translate OpenMP region  (nvhpc-c-parallel-for-firstprivate-in-target.c: 7)
NVC++/x86-64 Linux 26.9-0: compilation aborted

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 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (55 lines)
// NVHPC 25.11, NVIDIA A100 80GB PCIe (wingtip, sm_80), both memory
// modes: nvc stops with "NVC++-F-0155-Compiler failed to translate OpenMP
// region" on a parallel for with firstprivate nested in a target region
// (the catalog's lastprivate program fails the same way; its
// schedule(monotonic: dynamic) program fails because it has
// firstprivate(mine), not because of the schedule).
// Spec: firstprivate on a worksharing-loop construct: each new list item
// "is initialized from the original list item that exists before the
// construct" (5.2 §5.4.4 p.112); the program is legal.
// Vendor: "The private, firstprivate, and collapse clauses are supported"
// (worksharing-loop) and "The num_threads, default, private,
// firstprivate, and shared clauses are supported" (parallel), HPC
// Compilers User's Guide 25.11 §7.4, 2.9.2 and 2.6. The guide's §2.20
// sentence "nested teams or parallel regions in a target region are not
// supported" is read as a parallel region nested in another parallel (or
// teams) region inside a target region; here the parallel region is the
// only one in the target region, the shape §7.4's parallel entry covers.
// Expected: "c=1 every b[i] % 100 == 1: yes", exit 0. Each thread's copy
// of c starts at 1 and grows by 100 per iteration it runs, so b[i] is
// 1 + 100k (k = iterations its thread ran before i; the schedule is
// implementation defined, so k is not known); the host's c is unchanged.
// Observed (2026-10-24, nvc 25.11-0, -O2; this check rerun the same day,
// separate and managed memory): compile exit status 2,
// "NVC++-F-0155-Compiler failed to translate OpenMP region (b1.c: 7)".
// The same with private(c) (c set in the loop) compiles and is correct;
// nvfortran compiles the Fortran form of the catalog program; gcc
// (host fallback) prints the expected line.
// Found by the catalog (omp52/60-c-clause-firstprivate, -lastprivate,
// -schedule-monotonic: confirmer R10-compile-ice); reduced by hand.
// NVHPC 26.9 (26.9-0, the latest release; rerun 2026-10-24 on wingtip with
// the same flags): still present -- the same: "NVC++-F-0155-Compiler failed to translate OpenMP region", both modes.
// Fix (2026-10-24): rerun on 25.11 and 26.9 in both memory modes,
// each with its own runtime libraries (LD_LIBRARY_PATH = the release's
// compilers/lib; the first 26.9 runs had loaded 25.11's): still present
// on both releases, the same output.
// NVHPC: nvc -mp=gpu -gpu=cc80 -gpu=mem:separate -O2
// Run:   OMP_TARGET_OFFLOAD=mandatory ./a.out
#include <stdio.h>
int main(void) {
  int b[64];
  int c = 1;
  #pragma omp target map(from: b) map(tofrom: c)
  {
    #pragma omp parallel for default(none) shared(b) firstprivate(c)
    for (int i = 0; i < 64; i++) {
      b[i] = c;
      c = c + 100;
    }
  }
  int ok = (c == 1);
  for (int i = 0; i < 64; i++)
    ok = ok && (b[i] % 100 == 1);
  printf("c=%d every b[i] %% 100 == 1: %s\n", c, ok ? "yes" : "no");
  return ok ? 0 : 1;
}

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

NVC++-F-0155-Compiler failed to translate OpenMP region  (nvhpc-c-parallel-for-firstprivate-in-target.c: 7)
NVC++/x86-64 Linux 25.11-0: compilation aborted

What the specification requires

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

OpenMP 5.2 §5.4.4 p.112

is initialized from the original list item that exists before the construct

Evidence

Same compiler, one change

  • private(c) with c set to 1 in each iteration instead of firstprivate(c): 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>
    int main(void) {
      int b[64];
      int c = 1;
      #pragma omp target map(from: b) map(tofrom: c)
      {
        #pragma omp parallel for default(none) shared(b) private(c)
        for (int i = 0; i < 64; i++) {
          c = 1;
          b[i] = c;
          c = c + 100;
        }
      }
      int ok = (c == 1);
      for (int i = 0; i < 64; i++)
        ok = ok && (b[i] % 100 == 1);
      printf("c=%d every b[i] %% 100 == 1: %s\n", c, ok ? "yes" : "no");
      return ok ? 0 : 1;
    }
    

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