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

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Mon Nov 27 06:59:56 PST 2023


luporl wrote:

>     2. Model it like the OpenMP reduction/OpenACC reduction + privatisation with a declare/recipe function that can later be used to generate the copy function that is needed in the kmpc_copyprivate runtime call.
> 
> 
> ```
> omp.single copyprivate(x1:copy_x1,x2:copy_x2) {
>  x1 = bval1
>  x2 = bval2
> }
> ```
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.

In this case, would it be possible, or desirable, to have a runtime function that could perform a copy between any 2 variables? This could eliminate the need of having several generated copy functions.

If  `Assign` can do this already, then it would be a matter creating a wrapper that would obtain the missing arguments somehow and call it. An idea would be to pass the data to be copied (`cpy_data`) as a pointer inside a struct, that would then hold the arguments in the other fields, but this could introduce some inefficiencies. If `kmpc_copyprivate`'s `cpy_func` could be modified to accept an extra "context" argument, it would be better.

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


More information about the flang-commits mailing list