OffTarget

Observed issues › gcc/gcc-acc-c-gang-dim-rejected

Appears not to supportRefused at compile time · C · OpenACC · Open

OpenACC 3.3 gang(dim:) is rejected (C)

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

Same issue as gcc/gcc-acc-gang-dim-collapse-force-rejected; this program is another reproducer of it.

GCC 16.2 rejects the dim argument of the gang clause in C ("'dim' undeclared"), an OpenACC 3.3 form; GCC documents OpenACC 2.6. NVHPC compiles and runs the program. (The C collapse(force:) program is rejected by every compiler under test, so it is not part of this finding.)

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/acorrectcorrect
NVHPC 26.9n/an/an/an/an/acorrectcorrect
GCC 16.2.0not supportednot supportednot supportednot supportednot supportednot supportedn/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 supportedGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
GCC 16.2.0, MI300X
GCC 16.2.0, MI350X
show
site-gcc--gcc-acc-c-gang-dim-rejected.c: In function ‘main’:
site-gcc--gcc-acc-c-gang-dim-rejected.c:59:27: error: ‘dim’ undeclared (first use in this function)
   59 |     #pragma acc loop gang(dim: 1)
      |                           ^~~
site-gcc--gcc-acc-c-gang-dim-rejected.c:59:27: note: each undeclared identifier is reported only once for each function it appears in
not supportedGCC 16.2.0, MI250X
GCC 16.2.0, A100 separate
show
site-gcc--gcc-acc-c-gang-dim-rejected.c: In function ‘main’:
site-gcc--gcc-acc-c-gang-dim-rejected.c:57:27: error: ‘dim’ undeclared (first use in this function)
   57 |     #pragma acc loop gang(dim: 1)
      |                           ^~~
site-gcc--gcc-acc-c-gang-dim-rejected.c:57:27: note: each undeclared identifier is reported only once for each function it appears in

Reproduce

GCC 16.2.0, MI300A unified

export LD_LIBRARY_PATH=$GCC_16_2/lib64:/opt/rocm-7.2.1/lib
$GCC_16_2/bin/gcc -fopenacc -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 ./repro

GCC 16.2.0, A100 separate

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=$GCC_16_2/lib64
$GCC_16_2/bin/gcc -fopenacc -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.c -o repro
./repro

NVHPC 25.11, A100 separate (runs correctly)

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvc -acc=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.c -o repro
./repro
Program (72 lines)
// # Finding (GCC 16.2): the OpenACC 3.3 gang(dim:) argument is rejected (C); the reproducer is the catalog program
//   acc34-c-clause-gang-dim
//
// - toolchains: gcc_g90 (GCC 16.2.0, AMD Instinct MI250X gfx90a, Tioga) and gcc_sm80 (GCC 16.2.0,
//   NVIDIA A100 sm_80, wingtip); separate memory only; -O2; OMP_TARGET_OFFLOAD=mandatory
// - build: gcc -fopenacc -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx90a -O2 (gcc_g90); -foffload=nvptx-none
//   -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 (gcc_sm80)
// - failure: rejected
// - observed: `error: 'dim' undeclared (first use in this function)` on both GPUs.
// - expected: compiles; `RESULT ran_on_host=0 check=pass`
// - spec: the dim argument of gang (OpenACC 3.4 §2.9.2 l.2371; added in 3.3, "Changes from Version 3.2 to 3.3", margin line 800).
// - GCC 16.2 documentation (libgomp.texi "Enabling OpenACC"): "A complete description of all OpenACC directives accepted may be
//   found in the OpenACC Application Programming Interface manual, version 2.6"; _OPENACC is 201711 (2.6). No list of OpenACC gaps
//   is documented.
// - other families: NVHPC 25.11/26.9 compile and run it correctly.
// - gate and confirmer: 4 cells (2 gcc_g90, 2 gcc_sm80), each confirmed in the gate's four environments (a-d;
//   results/gcc/gate-tioga/ and gate-wingtip/ verdicts.jsonl); confirmer verdicts (results/gcc/confirm/batch.gcc_*.jsonl):
//   compiler_bug (R11-compile-rejection) 2, needs_human (R12b-compile-undecided) 2
// - catalog programs (2): acc34-c-clause-gang-dim, acc34-c-clause-gang-dim-binop
// - legality: the catalog programs are legal by construction (offload.engine.gen, c_gen and acc_gen
//   check every program against the catalog rules and the offload scope as it is built; no
//   compiler). GCC is a compiler under test only: never a legality witness, here or for another
//   family's case (catalog/machines.yaml under_test_only).
// Generated by compliance.acc_c_gen (OpenACC 3.4, C11): the C port (offload.engine.f2c) of acc34-clause-gang-dim. Do not edit.
// id: acc34-c-clause-gang-dim
// primary atom: acc.clause.gang.dim
// legal: yes
// observable: yes
// ran_on_host: inside the compute region of interest (acc_on_device)
// evidence: equivalent_default
// needs: none
// std: c11
// oracle: without the loop construct every gang of the parallel region executes every iteration (gang-redundant mode), and the
// atomic update adds the value once per gang
// no oracle (equivalent_default): dimension one is the gang clause's dimension without dim
// basis: OpenACC 3.4 §2.9.2, p.66: "The associated dimension is the value of the dim argument, if it appears, or is dimension one."
// C: the atomic update is written x += expr; the port's x = x + e1 + e2 is also a legal 3.4 §2.12 form (mathematically equivalent
// to x + (e1 + e2)) and is kept as acc34-c-clause-gang-dim-binop
#include <stdio.h>
#include <stdbool.h>
#include <openacc.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 acc parallel num_gangs(4) copyin(a) copy(b) copy(host_flag)
  {
    #pragma acc loop gang(dim: 1)
    for (int i = 1; i <= n; i++) {
      if (i == 1) host_flag = (acc_on_device(acc_device_host) ? 1 : 0);
      #pragma acc atomic update
      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

Expected

check=pass

Observed where it behaves incorrectly

site-gcc--gcc-acc-c-gang-dim-rejected.c: In function ‘main’:
site-gcc--gcc-acc-c-gang-dim-rejected.c:59:27: error: ‘dim’ undeclared (first use in this function)
   59 |     #pragma acc loop gang(dim: 1)
      |                           ^~~
site-gcc--gcc-acc-c-gang-dim-rejected.c:59:27: note: each undeclared identifier is reported only once for each function it appears in

What the specification requires

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

OpenACC 3.4 §2.9.2

OpenACC 3.4 §2.9.2 p.66

The associated dimension is the value of the dim argument, if it appears, or is dimension one.

OpenACC 3.4 §2.12

Evidence

Other compilers run it correctly

NVHPC 25.11, NVHPC 26.9