[Openmp-commits] [flang] [openmp] [flang][OpenMP] Add support for `target ... private` (PR #78968)
Kiran Chandramohan via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jan 23 05:20:26 PST 2024
kiranchandramohan 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 @privatization_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.
https://github.com/llvm/llvm-project/pull/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
https://github.com/llvm/llvm-project/pull/78968
More information about the Openmp-commits
mailing list