[Openmp-commits] [PATCH] D145093: Add map info for dereference pointer.

Alexey Bataev via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Mar 7 07:53:20 PST 2023


ABataev added inline comments.


================
Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7489-7493
+      if (UO && UO->getOpcode() == UO_Deref)
+        if (isa<OMPArraySectionExpr>(Last->getAssociatedExpression()) ||
+            isa<OMPArrayShapingExpr>(Last->getAssociatedExpression()) ||
+            isa<ArraySubscriptExpr>(Last->getAssociatedExpression()))
+          IsVarDerefAssoWithArray = true;
----------------
jyu2 wrote:
> ABataev wrote:
> > jyu2 wrote:
> > > ABataev wrote:
> > > > jyu2 wrote:
> > > > > ABataev wrote:
> > > > > > What if we have something like:
> > > > > > ```
> > > > > > typedef int (T)[3];
> > > > > > 
> > > > > > T** p;
> > > > > > map(**p)
> > > > > > ```
> > > > > > ? Shall it work? I.e. mapping of the whole array by dereferening the pointer to the array.
> > > > > No, it is not work currently.  What about *(*(p+a)+b)...
> > > > My question - shall it work? Mapping  (**a)[:3] should result in the same in the same code for **a if a is
> > > > ```
> > > > typedef int(T)[3];
> > > > T** a;
> > > > ```
> > > Oh, that should work.  I add additional test for that.
> > > 
> > > ```
> > > typedef int(T)[3];
> > > void bar()
> > > {
> > > 
> > > T** a;
> > > int b[2][3];
> > > int (*p)[3] = b;
> > > a =  &p;
> > > printf("%p %p p %p\n", &a, b, *p);
> > > for (int i = 0; i< 3; i++) {
> > >   (**a)[1] = i;
> > > }
> > > #pragma omp target map((**a)[:3])
> > > {
> > >  (**a)[1]=5;
> > >   // CHECK: 5
> > >   printf("a = %d\n", (**a)[1]);
> > > }
> > > }
> > > ```
> > > 
> > No, I meant different thing:
> > ```
> > T **a;
> > .. map (**a)
> > ```
> Yes, that is not working currently.  That is something need to be fixed include *(*(a+i)+j) .... 
Not sure need to implement such complex expression, but would be good to support (**a) (for arrays, array sections, just a regular scalars, etc.) here 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093



More information about the Openmp-commits mailing list