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