OffTarget

Observed issues › nested/afar-cce-c-update-struct-and-member-rejected

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

target update with a structure and a member array in one clause rejected

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

AFAR and CCE reject a target update clause naming a structure and the array its pointer member points to.

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 supportedunknown
not run
not supportednot supportedn/an/a
CCE 19.0.0not supportednot supportedunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2not supportednot supportedunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3not supportednot supportedunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4not supportednot supportedunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/afails another waycorrect
NVHPC 26.9n/an/an/an/an/afails another waycorrect
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
CCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
site-nested--afar-cce-c-update-struct-and-member-rejected.c:57:40: error: same pointer dereferenced in multiple different ways in map clause expressions
   57 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                        ^
site-nested--afar-cce-c-update-struct-and-member-rejected.c:57:32: note: used here
   57 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                ^~~~~~
1 error generated.
not supportedAFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
show
site-nested--afar-cce-c-update-struct-and-member-rejected.c:76:40: error: same pointer dereferenced in multiple different ways in map clause expressions
   76 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                        ^
site-nested--afar-cce-c-update-struct-and-member-rejected.c:76:32: note: used here
   76 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                ^~~~~~
1 error generated.
fails another wayNVHPC 25.11, A100 separate
NVHPC 26.9, A100 separate
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>
 Function: main:48
 Line: 61

Reproduce

AFAR 24.3.0, MI300A unified

$AFAR/bin/amdclang -fopenmp --offload-arch=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 19.0.0, MI300A unified

module load cce/19.0.0 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 20.0.2, MI300A unified

module load cce/20.0.2 craype-accel-amd-gfx942 rocm/6.4.3
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.3, MI300A unified

module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.4, MI300A unified

module load cce/21.0.4 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 repro.c -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

NVHPC 25.11, A100 managed (runs correctly)

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvc -mp=gpu -gpu=cc80 -gpu=mem:managed -O2 repro.c -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro
Program (84 lines)
// # Finding (nested-data): AFAR and CCE (clang front end) reject target update with a structure and one of its pointer members'
// # arrays in one clause
//
// - toolchains and modes that fail: afar (AFAR 24.3.0), cce19 (CCE 19.0.0), cce20 (CCE 20.0.2), cce21 (CCE 21.0.3), cce21_4 (CCE
//   21.0.4); modes: unified, copy; -O2
// - build: amdclang -fopenmp --offload-arch=gfx942 -O2 (afar); craycc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa
//   -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx942 -O2 (cce19, cce20, cce21, cce21_4)
// - failure: rejected
// - observed: `site-nested--afar-cce-c-update-struct-and-member-rejected.c:57:40: error: same pointer dereferenced in multiple
//   different ways in map clause expressio`; identical signature on 10 of 10 failing cells
// - expected: compiles and prints `tot= 105` with `check=pass`
// - rule: the list items of a data-motion clause are locators; "The list items that appear in a map clause may include
//   array sections and structure elements" (5.2 §5.8.3 p.151 l.13) and a to or from clause on target update names list
//   items the same way (§5.9 p.165 l.7-14); the restrictions of data-motion clauses are only "Each list item clause must
//   have a mappable type." (5.2 §5.9 p.166 l.13-14); the target update construct has no restriction on two list items
//   with one base variable (§13.9 p.289)
// - same-compiler control: controls/u3-ctl-update-member-only.c (one change from this file; correct on afar (AFAR 24.3.0), cce19
//   (CCE 19.0.0), cce20 (CCE 20.0.2), cce21 (CCE 21.0.3), cce21_4 (CCE 21.0.4); rows results/nested/red/red7.jsonl,
//   results/nested/red/tuo1.jsonl, results/nested/red/wgs.jsonl, results/nested/red/wnv.jsonl); controls/u4-ctl-two-updates.c (one
//   change from this file; correct on afar (AFAR 24.3.0), cce19 (CCE 19.0.0), cce20 (CCE 20.0.2), cce21 (CCE 21.0.3), cce21_4 (CCE
//   21.0.4); rows results/nested/red/red7.jsonl, results/nested/red/tuo1.jsonl, results/nested/red/wgs.jsonl,
//   results/nested/red/wnv.jsonl); controls/u5-ctl-same-list-in-map.c (one change from this file; correct on afar (AFAR 24.3.0),
//   cce19 (CCE 19.0.0), cce20 (CCE 20.0.2), cce21 (CCE 21.0.3), cce21_4 (CCE 21.0.4); rows results/nested/red/red7.jsonl,
//   results/nested/red/tuo1.jsonl, results/nested/red/wgs.jsonl, results/nested/red/wnv.jsonl)
// - other families: nvhpc (NVHPC 25.11), nvhpc269 (NVHPC 26.9), gcc_g90 (GCC 16.2.0), gcc_sm80 (GCC 16.2.0) run the file correctly
//   in managed mode (rows results/nested/red/red7.jsonl, results/nested/red/wgs.jsonl, results/nested/red/wnv.jsonl, site rows,
//   check case site-nested--afar-cce-c-update-struct-and-member-rejected); nvhpc (NVHPC 25.11), nvhpc269 (NVHPC 26.9) fail it
//   another way in copy mode, e.g. `Failing in Thread:1`
// - gate and confirmer: campaign gate of the programs below: 590 cells, 590 confirmed in the four environments (a-d; (c) on another
//   node or GPU; rows results/nested/big/gate_reruns.part.<host>.3222831.jsonl,
//   results/nested/big/gate_reruns.part.<host>.1040717.jsonl, results/nested/big/gate_reruns.part.<host>.1284552.jsonl,
//   results/nested/big/gate_reruns.part.<host>.1251749.jsonl, results/nested/big/gate_reruns.part.<host>.1517583.jsonl,
//   results/nested/big/gate_reruns.part.<host>.1434668.jsonl, results/nested/big/rows.part.<host>.1956389.jsonl,
//   results/nested/big/rows.part.<host>.1523848.jsonl, results/nested/big/rows.part.<host>.1239313.jsonl,
//   results/nested/big/rows.part.<host>.1197409.jsonl, results/nested/big/rows.part.<host>.1146311.jsonl,
//   results/nested/main/gate_reruns.part.<host>.961942.jsonl, results/nested/main/gate_reruns.part.<host>.919396.jsonl,
//   results/nested/main/gate_reruns.part.<host>.3910568.jsonl,
//   results/nested/main/gate_reruns.part.<host>.4072524.jsonl, results/nested/main/rows.part.<host>.994167.jsonl)
// - programs (59): nd-c-omp-update-alias-d2-332dddeb, nd-c-omp-update-alias-d2-684cb0b8, nd-c-omp-update-alias-d2-7e63bd9c,
//   nd-c-omp-update-aliassub-d2-7f474889, nd-c-omp-update-aliassub-d2-94cac870, nd-c-omp-update-aliassub-d2-c7c56309,
//   nd-c-omp-update-chain-d1-7fac5787, nd-c-omp-update-chain-d1-a679e114, nd-c-omp-update-chain-d2-114e1ffc,
//   nd-c-omp-update-chain-d2-1585f8af, nd-c-omp-update-chain-d2-15c71a46, nd-c-omp-update-chain-d2-1f314a7c,
//   nd-c-omp-update-chain-d2-1fcc5e18, nd-c-omp-update-chain-d2-2b8c33ae, nd-c-omp-update-chain-d2-2d0d559e,
//   nd-c-omp-update-chain-d2-44c37206, nd-c-omp-update-chain-d2-60aec85d, nd-c-omp-update-chain-d2-61da37e6,
//   nd-c-omp-update-chain-d2-6af5c7e2, nd-c-omp-update-chain-d2-7f8add9c, nd-c-omp-update-chain-d2-86fbbf97,
//   nd-c-omp-update-chain-d2-a3703a98, nd-c-omp-update-chain-d2-b6fcbb9f, nd-c-omp-update-chain-d2-b7041f75,
//   nd-c-omp-update-chain-d2-bd065bcd, nd-c-omp-update-chain-d2-cca853ce, nd-c-omp-update-chain-d2-db6ed5e2,
//   nd-c-omp-update-chain-d3-05025df3, nd-c-omp-update-chain-d3-0c64953c, nd-c-omp-update-chain-d3-0f5b4780,
//   nd-c-omp-update-chain-d3-1f5ebce9, nd-c-omp-update-chain-d3-2620c220, nd-c-omp-update-chain-d3-2be3a628,
//   nd-c-omp-update-chain-d3-4643770f, nd-c-omp-update-chain-d3-5648fa65, nd-c-omp-update-chain-d3-65936503,
//   nd-c-omp-update-chain-d3-6bc24e3c, nd-c-omp-update-chain-d3-6f0b33d0, nd-c-omp-update-chain-d3-700e7c94,
//   nd-c-omp-update-chain-d3-70128cef, nd-c-omp-update-chain-d3-8b59135d, nd-c-omp-update-chain-d3-8ba10689,
//   nd-c-omp-update-chain-d3-8f2a97eb, nd-c-omp-update-chain-d3-97a31dfc, nd-c-omp-update-chain-d3-a29029aa,
//   nd-c-omp-update-chain-d3-a9134361, nd-c-omp-update-chain-d3-b91a32d4, nd-c-omp-update-chain-d3-c5604bb2,
//   nd-c-omp-update-chain-d4-19f9f60a, nd-c-omp-update-diamond-d3-3f65ce61, nd-c-omp-update-diamond-d3-41a1f708,
//   nd-c-omp-update-diamond-d3-5b90e213, nd-c-omp-update-list-d2-58efae8c, nd-c-omp-update-list-d3-842299a3,
//   nd-c-omp-update-tree-d2-5148e00e, nd-c-omp-update-tree-d2-78bc7f0b, nd-c-omp-update-tree-d2-bf7639b6,
//   nd-c-omp-update-tree-d3-725ebde6, nd-c-omp-update-tree-d3-ca80229f
// - legality: the rules (offload.engine.rules) accept it; GCC compiles and runs it (GCC is no legality witness); the
//   AFAR/CCE C front ends reject it with a diagnostic, so the only other front end is NVHPC nvc, which accepted the
//   campaign's update programs of this form where it ran at all (results/nested/main/witness*.jsonl)
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
struct s { int v; int *a; };
int main(void)
{
  int hf = 1, i, tot = 0, ok;
  struct s *r = malloc(sizeof *r);
  r->v = 5; r->a = malloc(4 * sizeof(int));
  for (i = 0; i < 4; i++) r->a[i] = i + 1;
  #pragma omp target map(from: hf)
  hf = omp_is_initial_device() ? 1 : 0;
  #pragma omp target enter data map(to: r[0:1]) map(to: r->a[0:4])
  for (i = 0; i < 4; i++) r->a[i] = 10 * (i + 1);
  #pragma omp target update to(r[0:1], r->a[0:4])
  #pragma omp target map(tofrom: tot)
  { tot = r->v; for (int q = 0; q < 4; q++) tot += r->a[q]; }
  #pragma omp target exit data map(release: r->a[0:4]) map(release: r[0:1])
  ok = tot == 105;
  printf("tot= %d\n", tot);
  printf("RESULT ran_on_host=%d check=%s\n", hf, 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

site-nested--afar-cce-c-update-struct-and-member-rejected.c:57:40: error: same pointer dereferenced in multiple different ways in map clause expressions
   57 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                        ^
site-nested--afar-cce-c-update-struct-and-member-rejected.c:57:32: note: used here
   57 |   #pragma omp target update to(r[0:1], r->a[0:4])
      |                                ^~~~~~
1 error generated.

What the specification requires

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

OpenMP 5.2 §5.8.3 p.151 l.13

The list items that appear in a map clause may include array sections and structure elements

OpenMP 5.2 §5.9 p.165 l.7-14

OpenMP 5.2 §5.9 p.166 l.13-14

Each list item clause must have a mappable type.

OpenMP 5.2 §13.9 p.289

Evidence

Same compiler, one change

  • one change from the finding; correct on afar, cce19, cce20, cce21, cce21_4: not run yet
    Control program
    // control: only the member array in the update (v stays)
    #include <stdio.h>
    #include <stdlib.h>
    #include <omp.h>
    struct s { int v; int *a; };
    int main(void)
    {
      int hf = 1, i, tot = 0, ok;
      struct s *r = malloc(sizeof *r);
      r->v = 5; r->a = malloc(4 * sizeof(int));
      for (i = 0; i < 4; i++) r->a[i] = i + 1;
      #pragma omp target map(from: hf)
      hf = omp_is_initial_device() ? 1 : 0;
      #pragma omp target enter data map(to: r[0:1]) map(to: r->a[0:4])
      for (i = 0; i < 4; i++) r->a[i] = 10 * (i + 1);
      #pragma omp target update to(r->a[0:4])
      #pragma omp target map(tofrom: tot)
      { tot = r->v; for (int q = 0; q < 4; q++) tot += r->a[q]; }
      #pragma omp target exit data map(release: r->a[0:4]) map(release: r[0:1])
      ok = tot == 105;
      printf("tot= %d\n", tot);
      printf("RESULT ran_on_host=%d check=%s\n", hf, ok ? "pass" : "fail");
      return 0;
    }
    
  • one change from the finding; correct on afar, cce19, cce20, cce21, cce21_4: not run yet
    Control program
    // control: the same two list items in two update directives
    #include <stdio.h>
    #include <stdlib.h>
    #include <omp.h>
    struct s { int v; int *a; };
    int main(void)
    {
      int hf = 1, i, tot = 0, ok;
      struct s *r = malloc(sizeof *r);
      r->v = 5; r->a = malloc(4 * sizeof(int));
      for (i = 0; i < 4; i++) r->a[i] = i + 1;
      #pragma omp target map(from: hf)
      hf = omp_is_initial_device() ? 1 : 0;
      #pragma omp target enter data map(to: r[0:1]) map(to: r->a[0:4])
      for (i = 0; i < 4; i++) r->a[i] = 10 * (i + 1);
      #pragma omp target update to(r[0:1])
      #pragma omp target update to(r->a[0:4])
      #pragma omp target map(tofrom: tot)
      { tot = r->v; for (int q = 0; q < 4; q++) tot += r->a[q]; }
      #pragma omp target exit data map(release: r->a[0:4]) map(release: r[0:1])
      ok = tot == 105;
      printf("tot= %d\n", tot);
      printf("RESULT ran_on_host=%d check=%s\n", hf, ok ? "pass" : "fail");
      return 0;
    }
    
  • one change from the finding; correct on afar, cce19, cce20, cce21, cce21_4: not run yet
    Control program
    // control: the structure's scalar member and the array in two separate update directives
    #include <stdio.h>
    #include <stdlib.h>
    #include <omp.h>
    struct s { int v; int *a; };
    int main(void)
    {
      int hf = 1, i, tot = 0, ok;
      struct s *r = malloc(sizeof *r);
      r->v = 5; r->a = malloc(4 * sizeof(int));
      for (i = 0; i < 4; i++) r->a[i] = i + 1;
      #pragma omp target map(from: hf)
      hf = omp_is_initial_device() ? 1 : 0;
      #pragma omp target enter data map(to: r[0:1]) map(to: r->a[0:4])
      for (i = 0; i < 4; i++) r->a[i] = 10 * (i + 1);
      #pragma omp target update to(r->v)
      #pragma omp target update to(r->a[0:4])
      #pragma omp target map(tofrom: tot)
      { tot = r->v; for (int q = 0; q < 4; q++) tot += r->a[q]; }
      #pragma omp target exit data map(release: r->a[0:4]) map(release: r[0:1])
      ok = tot == 105;
      printf("tot= %d\n", tot);
      printf("RESULT ran_on_host=%d check=%s\n", hf, ok ? "pass" : "fail");
      return 0;
    }
    

Other compilers run it correctly

NVHPC 25.11, NVHPC 26.9, GCC 16.2.0