[flang-commits] [flang] [openmp] [flang][OpenMP] Add support for `target ... private` (PR #78968)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Mon Jan 29 09:01:13 PST 2024


ergawy wrote:

> > omp.target ... private(%x -> %argx: type) {
> > bb0(%argx: type):
> > ... use %argx ...
> > }
> 
> You can augment the `private` with a function like op that declares how to make a clone (with alloca) of this type. Flang will create this with FIR/HLFIR. This will be converted by the current conversion patterns in codegen.cpp to LLVM dialect and then in `OpenMPToLLVMIRTranslation.cpp` you can hopefully just inline this function like op at the correct place.
> 
> ```
>   omp.private.decl @private_decl_i32 : !fir.ref<i32> init {
>   ^bb0(%arg0: !fir.ref<i32>):
>     %0 = fir.alloca i32
>     omp.yield %0 : !fir.ref<i32>
>   }
> ```
> 
> ```
> omp.target ... private(private_decl_i32 %x -> %argx: !fir.ref<i32>) {
> bb0(%argx: !fir.ref<i32>):
>      ... use %argx ...
> }
> ```
> 
> The copyprivate patch reuses some of the copying (needed for firstprivate) from DataSharingProcessor. #73128
> 
> You can hopefully combine what you do and what is there for `copyprivate` to implement `firstprivate` as well.
> 
> Note: You can find similar code in OpenMP reduction declarations and in OpenACC privatisation and reduction recipes

@kiranchandramohan @clementval I created an incomplete WIP for delayed privatization in https://github.com/llvm/llvm-project/pull/79862. In the commit message I explain what is done and is still todo.

I know it is a bit early stage but I wanted to take your input on the current approach at least from a high-level of view. Any comments from anyone is highly appreciated.

I can abandon this PR and we can probably move the discussion to the WIP PR.

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


More information about the flang-commits mailing list