[PATCH] D144569: [Clang][OpenMP] Fix accessing of aligned arrays in offloaded target regions

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 22 09:13:02 PST 2023


doru1004 created this revision.
doru1004 added reviewers: jdoerfert, jhuber6, ronl, carlo.bertolli, arsenm, gregrodgers, ABataev.
doru1004 added a project: OpenMP.
Herald added subscribers: kosarev, kerbowa, guansong, yaxunl, jvesely.
Herald added a project: All.
doru1004 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

This patch fixes a memory error that occurs when we access an aligned array on the device:

  void write_index(int*a, int N) {
      int *aptr __attribute__ ((aligned(64))) = a; // This failed but is fixed by this patch.
      #pragma omp target teams distribute parallel for map(tofrom: aptr[0:N])
      for(int i=0;i<N;i++) {
         aptr[i]=i;
      }
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144569

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144569.499536.patch
Type: text/x-patch
Size: 25548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230222/1481e179/attachment-0001.bin>


More information about the cfe-commits mailing list