[flang-commits] [flang] [flang][OpenMP][RFC] Add support for COPYPRIVATE (PR #73128)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Mon Nov 27 15:33:53 PST 2023


kiranchandramohan wrote:

> Would `copy_x1` and `copy_x2` be internal generated functions that perform a copy between 2 memory locations, as required by `kmpc_copyprivate`'s `cpy_func`? I'm not familiar with OpenMP reduction implementation.

Yes, they would be generated function like operations that perform copies. There will probably be as many versions as the various types, kinds etc. This will have to be modified to whatever `cpy_func` expects.
```
copy_integer_declare {
  ^bb0(%arg0: !fir.ref<i32>, %arg1: !fir.ref<i32>):
    %0 = fir.load %arg0 : !fir.ref<i32>
    fir.store %0 to %arg1 : !fir.ref<i32>
    omp.terminator
  }
```  

> In this case, would it be possible, or desirable, to have a runtime function that could perform a copy between any 2 variables? 

There already a runtime Assign function but I think this operates on descriptors (https://github.com/llvm/llvm-project/blob/fea023b129190edeb503dbe947034f925bbda666/flang/runtime/assign.cpp#L253). So I guess the disadvantage here might be that we will always need descriptors.

> This could eliminate the need to have several generated copy functions.
We would either be generating code that inlines the copy or creating function-like operations that does them. If there are a lot of copy-private members of the same type then they could all just point to the same copy declare operation.



https://github.com/llvm/llvm-project/pull/73128


More information about the flang-commits mailing list