[Mlir-commits] [mlir] [MLIR][OpenMP] Support basic materialization for `omp.private` ops (PR #81715)

Kiran Chandramohan llvmlistbot at llvm.org
Sun Feb 18 07:56:42 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) {
----------------
kiranchandramohan wrote:

> The OpenMPIRBuilder::createParallel(...) [collects the inputs and outputs of the parallel region](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp#L1502). The [inputs are then iterated](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp#L1580) to invoke the private/firstprivate/shared callback.
> The input as defined by the CodeExtractor is [any value defined outside the region and used inside it](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/CodeExtractor.cpp#L649).
> Therefore, if OpenMPIRBuilder::createParallel is invoked with the block arguments still used inside the parallel region, the IR builder won't detect these as inputs and won't invoke the PrivCB for private/firstprivate variables.

Wouldn't it still be called for the original variable (`%x` here)? And at that point can't we get (`%arg0`) and do the appropriate processing?

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


More information about the Mlir-commits mailing list