@@ -2144,8 +2144,78 @@ static void genCompositeDistributeParallelDoSimd(
2144
2144
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2145
2145
mlir::Location loc, const ConstructQueue &queue,
2146
2146
ConstructQueue::const_iterator item) {
2147
+ lower::StatementContext stmtCtx;
2148
+
2147
2149
assert (std::distance (item, queue.end ()) == 4 && " Invalid leaf constructs" );
2148
- TODO (loc, " Composite DISTRIBUTE PARALLEL DO SIMD" );
2150
+ ConstructQueue::const_iterator distributeItem = item;
2151
+ ConstructQueue::const_iterator parallelItem = std::next (distributeItem);
2152
+ ConstructQueue::const_iterator doItem = std::next (parallelItem);
2153
+ ConstructQueue::const_iterator simdItem = std::next (doItem);
2154
+
2155
+ // Create parent omp.parallel first.
2156
+ mlir::omp::ParallelOperands parallelClauseOps;
2157
+ llvm::SmallVector<const semantics::Symbol *> parallelReductionSyms;
2158
+ llvm::SmallVector<mlir::Type> parallelReductionTypes;
2159
+ genParallelClauses (converter, semaCtx, stmtCtx, parallelItem->clauses , loc,
2160
+ parallelClauseOps, parallelReductionTypes,
2161
+ parallelReductionSyms);
2162
+
2163
+ DataSharingProcessor dsp (converter, semaCtx, simdItem->clauses , eval,
2164
+ /* shouldCollectPreDeterminedSymbols=*/ true ,
2165
+ /* useDelayedPrivatization=*/ true , &symTable);
2166
+ dsp.processStep1 (¶llelClauseOps);
2167
+
2168
+ genParallelOp (converter, symTable, semaCtx, eval, loc, queue, parallelItem,
2169
+ parallelClauseOps, parallelReductionSyms,
2170
+ parallelReductionTypes, &dsp, /* isComposite=*/ true );
2171
+
2172
+ // Clause processing.
2173
+ mlir::omp::DistributeOperands distributeClauseOps;
2174
+ genDistributeClauses (converter, semaCtx, stmtCtx, distributeItem->clauses ,
2175
+ loc, distributeClauseOps);
2176
+
2177
+ mlir::omp::WsloopOperands wsloopClauseOps;
2178
+ llvm::SmallVector<const semantics::Symbol *> wsloopReductionSyms;
2179
+ llvm::SmallVector<mlir::Type> wsloopReductionTypes;
2180
+ genWsloopClauses (converter, semaCtx, stmtCtx, doItem->clauses , loc,
2181
+ wsloopClauseOps, wsloopReductionTypes, wsloopReductionSyms);
2182
+
2183
+ mlir::omp::SimdOperands simdClauseOps;
2184
+ genSimdClauses (converter, semaCtx, simdItem->clauses , loc, simdClauseOps);
2185
+
2186
+ mlir::omp::LoopNestOperands loopNestClauseOps;
2187
+ llvm::SmallVector<const semantics::Symbol *> iv;
2188
+ genLoopNestClauses (converter, semaCtx, eval, simdItem->clauses , loc,
2189
+ loopNestClauseOps, iv);
2190
+
2191
+ // Operation creation.
2192
+ // TODO: Populate entry block arguments with private variables.
2193
+ auto distributeOp = genWrapperOp<mlir::omp::DistributeOp>(
2194
+ converter, loc, distributeClauseOps, /* blockArgTypes=*/ {});
2195
+ distributeOp.setComposite (/* val=*/ true );
2196
+
2197
+ // TODO: Add private variables to entry block arguments.
2198
+ auto wsloopOp = genWrapperOp<mlir::omp::WsloopOp>(
2199
+ converter, loc, wsloopClauseOps, wsloopReductionTypes);
2200
+ wsloopOp.setComposite (/* val=*/ true );
2201
+
2202
+ // TODO: Populate entry block arguments with reduction and private variables.
2203
+ auto simdOp = genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps,
2204
+ /* blockArgTypes=*/ {});
2205
+ simdOp.setComposite (/* val=*/ true );
2206
+
2207
+ // Construct wrapper entry block list and associated symbols. It is important
2208
+ // that the symbol order and the block argument order match, so that the
2209
+ // symbol-value bindings created are correct.
2210
+ auto &wrapperSyms = wsloopReductionSyms;
2211
+
2212
+ auto wrapperArgs = llvm::to_vector (llvm::concat<mlir::BlockArgument>(
2213
+ distributeOp.getRegion ().getArguments (),
2214
+ wsloopOp.getRegion ().getArguments (), simdOp.getRegion ().getArguments ()));
2215
+
2216
+ genLoopNestOp (converter, symTable, semaCtx, eval, loc, queue, simdItem,
2217
+ loopNestClauseOps, iv, wrapperSyms, wrapperArgs,
2218
+ llvm::omp::Directive::OMPD_distribute_parallel_do_simd, dsp);
2149
2219
}
2150
2220
2151
2221
static void genCompositeDistributeSimd (lower::AbstractConverter &converter,
0 commit comments