[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 16 08:46:40 PDT 2021


ABataev added a comment.

In D108132#2947053 <https://reviews.llvm.org/D108132#2947053>, @jyu2 wrote:

> Hi ABataev,
> Thanks for  reviedw.
>
> In D108132#2946927 <https://reviews.llvm.org/D108132#2946927>, @ABataev wrote:
>
>> Why it can not be performed in codegen?
>
> I am not sure I can do that.  Do you mean when generate map adding coding code to look though reduction clause and generate map for it?

Yes, exactly.

> Here is the runtime test, I am trying to find way on how to add runtime test in clang.  But in my added test reduction_implicit_map.cpp, I did checked IR for this.

Add it to libomptarget.

> The command line: without may change:
> cmplrllvm-25845>clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu o.cpp -g
> cmplrllvm-25845>./a.out
> Segmentation fault (core dumped)
> with may change:
> cmplrllvm-25845> ./a.out
> Result=5050
>
> test
> ----
>
> extern "C" int printf(const char *,...);
> void sum(int* input, int size, int* output)
> {
>
>   #pragma omp target teams distribute parallel for reduction(+:output[0]) map(to:input[0:size]) //map(output[0])
>   for(int i=0; i<size; i++)
>       output[0] += input[i];
>
> }
> int main()
> {
>
>   const int size = 100;
>   int *array = new int[size];
>   int result = 0;
>   for (int i = 0; i < size; i++)
>       array[i] = i + 1;
>   sum(array, size, &result);
>   printf("Result=%d\n", result);
>   delete[] array;
>   return 0;
>
> }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132



More information about the cfe-commits mailing list