[flang-commits] [flang] [mlir] [MLIR][OpenMP] Support basic materialization for `omp.private` ops (PR #81715)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Feb 15 09:10:39 PST 2024
================
@@ -1000,6 +1000,26 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
return success();
}
+/// Replace the region arguments of the parallel op (which correspond to private
+/// variables) with the actual private varibles they correspond to. This
+/// prepares the parallel op so that it matches what is expected by the
+/// OMPIRBuilder.
+static void prepareOmpParallelForPrivatization(omp::ParallelOp opInst) {
----------------
skatrak wrote:
Could you elaborate on why this is necessary to match what the OMPIRBuilder expects? My understanding is that this would make the following transformation:
```mlir
// Before.
%x = ...
omp.parallel private(@x.privatizer %x -> %arg0 : !llvm.ptr) {
^bb0(%arg0: !llvm.ptr):
%0 = llvm.load %arg0 : !llvm.ptr -> i32
omp.terminator
}
// After.
%x = ...
omp.parallel private(@x.privatizer %x -> %??? : !llvm.ptr) {
^bb0():
%0 = llvm.load %x : !llvm.ptr -> i32
omp.terminator
}
```
If that's the case, it also seems like it is making the `omp.parallel` operation invalid, since the number of block arguments wouldn't match the number of private variables. Is there a chance that the `bodyGenCB` callback could be tweaked to address the problems that this function solves by making changes to the original operation?
Maybe I'm just not understanding how this function works, so some clarification in that case would be much appreciated.
https://github.com/llvm/llvm-project/pull/81715
More information about the flang-commits
mailing list