OffTarget

Observed issues › nvhpc-c-acc-atomic-update-sum-ice

Appears to behave incorrectlyCompiler crash · C · OpenACC · Open

nvc/nvfortran -acc: atomic update x = x + v + 1 rejected, then internal compiler error (nvc) or fort2 crash (nvfortran)

Legality: not independently confirmed. Independent readings are uncertain: The statement x = x + v + 1 parses as (x + v) + 1, so it does not match x = x binop expr with x as the left operand of the top-level operator. The spec requires only that x binop expr be mathematically equivalent to x binop (expr), and the precedence condition is given as a sufficient case. For integer addition, x + (v + 1) is equivalent, so the form can be read as admitted. 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.0n/an/an/an/an/an/an/a
CCE 19.0.0n/an/aunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2n/an/aunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3n/an/aunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4n/an/aunknown
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.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/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++-S-0155-Invalid atomic update expression  (nvhpc-c-acc-atomic-update-sum-ice.c: 7)
NVC++-F-0000-Internal compiler error. invalid ILM atomic region       0  (nvhpc-c-acc-atomic-update-sum-ice.c: 7)
NVC++/x86-64 Linux 25.11-0: compilation aborted
behaves incorrectlyNVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVC++-S-0155-Invalid atomic update expression  (nvhpc-c-acc-atomic-update-sum-ice.c: 7)
NVC++-F-0000-Internal compiler error. invalid ILM atomic region       0  (nvhpc-c-acc-atomic-update-sum-ice.c: 7)
NVC++/x86-64 Linux 26.9-0: compilation aborted
fails another wayGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
GCC 16.2.0, MI250X
GCC 16.2.0, MI300X
GCC 16.2.0, MI350X
GCC 16.2.0, A100 separate
show
nvhpc-c-acc-atomic-update-sum-ice.c: In function ‘main’:
nvhpc-c-acc-atomic-update-sum-ice.c:7:18: error: invalid form of ‘#pragma omp atomic’ before ‘;’ token
    7 |     x = x + v + 1;
      |                  ^

Reproduce

NVHPC 25.11, A100 separate

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

NVHPC 26.9, A100 separate

export LD_LIBRARY_PATH=$NVHPC_26_9/compilers/lib
nvc -acc=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.c -o repro
./repro
Program (38 lines)
// NVHPC 25.11 and 26.9 (nvc), NVIDIA A100 80GB PCIe
// (wingtip, sm_80). nvc rejects the OpenACC atomic update x = x + v + 1
// ("NVC++-S-0155-Invalid atomic update expression") and then stops with an
// internal compiler error ("NVC++-F-0000-Internal compiler error. invalid ILM
// atomic region"), at -O0 and -O2, for -acc=gpu and -acc=multicore.
// Spec: one C form of an atomic update is "x = x binop expr", and "The
// expression x binop expr must be mathematically equivalent to x binop
// (expr). This requirement is satisfied if the operators in expr have
// precedence greater than binop, or by using parentheses around expr or
// subexpressions of expr" (OpenACC 3.4 §2.12, p.77-78). C parses the
// statement as (x + v) + 1, which is x + (v + 1) for int: the precedence and
// parentheses forms are sufficient, not necessary, so the statement is a
// legal update. The same update written x = x + (v + 1) or x += v + 1
// compiles and gives 2080.
// Fortran: nvfortran fails the same form the same way and, in a gang loop,
// its front end crashes (nvhpc-acc-atomic-update-sum-fort2-crash.f90).
// Expected: "x=2080" (a diagnostic would at least not be an internal error).
// Observed (2026-10-24, rerun 2026-10-25, nvc 25.11-0 and 26.9-0, the flags
// below, -O0 and -acc=multicore): compile exit status 2 with the two
// messages above, on both releases; the two other spellings print x=2080
// (log: data/evidence/acc_c_probe/atomic/run.log, sum.c, sum_paren.c,
// sum_compound.c).
// Found by the catalog: the C port of acc34-clause-gang, acc34-clause-gang-dim
// and acc34-directive-loop writes b[i - 1] = b[i - 1] + 2 * a[i - 1] + 1
// (the -binop programs: acc34-c-clause-gang-binop, acc34-c-clause-gang-dim-
// binop, acc34-c-directive-loop-binop); reduced by hand.
// NVHPC: nvc -acc=gpu -gpu=cc80 -gpu=mem:separate -O2
#include <stdio.h>
int main(void) {
  int x = 0;
  #pragma acc parallel loop copy(x)
  for (int v = 0; v < 64; v++) {
    #pragma acc atomic update
    x = x + v + 1;
  }
  printf("x=%d\n", x);
  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

NVC++-S-0155-Invalid atomic update expression  (nvhpc-c-acc-atomic-update-sum-ice.c: 7)
NVC++-F-0000-Internal compiler error. invalid ILM atomic region       0  (nvhpc-c-acc-atomic-update-sum-ice.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.

OpenACC 3.4 §2.12 p.77-78

The expression x binop expr must be mathematically equivalent to x binop (expr). This requirement is satisfied if the operators in expr have precedence greater than binop, or by using parentheses around expr or subexpressions of expr

Evidence

Same compiler, one change

  • x = x + (v + 1), the right-hand side in parentheses: NVHPC 25.11: correct; NVHPC 26.9: correct
    Control program
    #include <stdio.h>
    int main(void) {
      int x = 0;
      #pragma acc parallel loop copy(x)
      for (int v = 0; v < 64; v++) {
        #pragma acc atomic update
        x = x + (v + 1);
      }
      printf("x=%d\n", x);
      return 0;
    }
    

Reproducers of this issue