[llvm-branch-commits] [flang] [Flang][OpenMP] DISTRIBUTE PARALLEL DO lowering (PR #106207)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 27 05:46:11 PDT 2024
================
@@ -2052,8 +2074,69 @@ static void genCompositeDistributeParallelDo(
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
mlir::Location loc, const ConstructQueue &queue,
ConstructQueue::const_iterator item) {
+ lower::StatementContext stmtCtx;
+
assert(std::distance(item, queue.end()) == 3 && "Invalid leaf constructs");
- TODO(loc, "Composite DISTRIBUTE PARALLEL DO");
+ ConstructQueue::const_iterator distributeItem = item;
+ ConstructQueue::const_iterator parallelItem = std::next(distributeItem);
+ ConstructQueue::const_iterator doItem = std::next(parallelItem);
+
+ // Create parent omp.parallel first.
+ mlir::omp::ParallelOperands parallelClauseOps;
+ llvm::SmallVector<const semantics::Symbol *> parallelReductionSyms;
+ llvm::SmallVector<mlir::Type> parallelReductionTypes;
+ genParallelClauses(converter, semaCtx, stmtCtx, parallelItem->clauses, loc,
+ parallelClauseOps, parallelReductionTypes,
+ parallelReductionSyms);
+
+ DataSharingProcessor dsp(converter, semaCtx, doItem->clauses, eval,
+ /*shouldCollectPreDeterminedSymbols=*/true,
+ /*useDelayedPrivatization=*/true, &symTable);
+ dsp.processStep1(¶llelClauseOps);
+
+ genParallelOp(converter, symTable, semaCtx, eval, loc, queue, parallelItem,
+ parallelClauseOps, parallelReductionSyms,
+ parallelReductionTypes, &dsp, /*isComposite=*/true);
+
+ // Clause processing.
+ mlir::omp::DistributeOperands distributeClauseOps;
+ genDistributeClauses(converter, semaCtx, stmtCtx, distributeItem->clauses,
+ loc, distributeClauseOps);
+
+ mlir::omp::WsloopOperands wsloopClauseOps;
+ llvm::SmallVector<const semantics::Symbol *> wsloopReductionSyms;
+ llvm::SmallVector<mlir::Type> wsloopReductionTypes;
+ genWsloopClauses(converter, semaCtx, stmtCtx, doItem->clauses, loc,
+ wsloopClauseOps, wsloopReductionTypes, wsloopReductionSyms);
+
+ mlir::omp::LoopNestOperands loopNestClauseOps;
+ llvm::SmallVector<const semantics::Symbol *> iv;
+ genLoopNestClauses(converter, semaCtx, eval, doItem->clauses, loc,
+ loopNestClauseOps, iv);
+
+ // Operation creation.
+ // TODO: Populate entry block arguments with private variables.
----------------
skatrak wrote:
At the moment delayed privatization for most operations is not supported, but I think the expected behavior is not that the compiler asserts if `enableDelayedPrivatization=true` when creating these operations but rather that this would be the preferred approach if both delayed and early privatization are supported for the operation.
The TODO here is more to keep in mind that, whenever delayed privatization for `omp.distribute` is supported, the associated fields of the `distributeClauseOps` structure will be populated (at the moment no privatization at all would be attempted for `omp.distribute` in this case, as everything is done at the `omp.parallel` level) and at that point the `blockArgTypes` will have to be set accordingly. Same situation for `omp.wsloop` below and `omp.simd` instances in other composite op gen functions.
Not sure if that addresses your concerns, let me know.
https://github.com/llvm/llvm-project/pull/106207
More information about the llvm-branch-commits
mailing list