@@ -568,6 +568,9 @@ class ClauseProcessor {
568
568
bool processDevice (Fortran::lower::StatementContext &stmtCtx,
569
569
mlir::Value &result) const ;
570
570
bool processDeviceType (mlir::omp::DeclareTargetDeviceType &result) const ;
571
+ bool processDistSchedule (Fortran::lower::StatementContext &stmtCtx,
572
+ mlir::UnitAttr &scheduleStatic,
573
+ mlir::Value &chunkSize) const ;
571
574
bool processFinal (Fortran::lower::StatementContext &stmtCtx,
572
575
mlir::Value &result) const ;
573
576
bool processHint (mlir::IntegerAttr &result) const ;
@@ -1493,6 +1496,19 @@ bool ClauseProcessor::processDeviceType(
1493
1496
return false ;
1494
1497
}
1495
1498
1499
+ bool ClauseProcessor::processDistSchedule (
1500
+ Fortran::lower::StatementContext &stmtCtx, mlir::UnitAttr &scheduleStatic,
1501
+ mlir::Value &chunkSize) const {
1502
+ if (auto *distScheduleClause = findUniqueClause<ClauseTy::DistSchedule>()) {
1503
+ scheduleStatic = converter.getFirOpBuilder ().getUnitAttr ();
1504
+ if (const auto *expr = Fortran::semantics::GetExpr (distScheduleClause->v )) {
1505
+ chunkSize = fir::getBase (converter.genExprValue (*expr, stmtCtx));
1506
+ }
1507
+ return true ;
1508
+ }
1509
+ return false ;
1510
+ }
1511
+
1496
1512
bool ClauseProcessor::processFinal (Fortran::lower::StatementContext &stmtCtx,
1497
1513
mlir::Value &result) const {
1498
1514
const Fortran::parser::CharBlock *source = nullptr ;
@@ -3003,6 +3019,27 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
3003
3019
reductionDeclSymbols));
3004
3020
}
3005
3021
3022
+ static mlir::omp::DistributeOp
3023
+ genDistributeOp (Fortran::lower::AbstractConverter &converter,
3024
+ Fortran::lower::pft::Evaluation &eval, bool genNested,
3025
+ mlir::Location currentLocation,
3026
+ const Fortran::parser::OmpClauseList &clauseList,
3027
+ bool outerCombined = false ) {
3028
+ Fortran::lower::StatementContext stmtCtx;
3029
+ mlir::UnitAttr scheduleStatic;
3030
+ mlir::Value chunkSize;
3031
+ llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
3032
+
3033
+ ClauseProcessor cp (converter, clauseList);
3034
+ cp.processDistSchedule (stmtCtx, scheduleStatic, chunkSize);
3035
+ cp.processAllocate (allocatorOperands, allocateOperands);
3036
+
3037
+ return genOpWithBody<mlir::omp::DistributeOp>(
3038
+ converter, eval, genNested, currentLocation, outerCombined, &clauseList,
3039
+ scheduleStatic, chunkSize, allocateOperands, allocatorOperands,
3040
+ /* order_val=*/ nullptr );
3041
+ }
3042
+
3006
3043
// / Extract the list of function and variable symbols affected by the given
3007
3044
// / 'declare target' directive and return the intended device type for them.
3008
3045
static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo (
@@ -3387,7 +3424,9 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
3387
3424
}
3388
3425
if (llvm::omp::allDistributeSet.test (ompDirective)) {
3389
3426
validDirective = true ;
3390
- TODO (currentLocation, " Distribute construct" );
3427
+ bool outerCombined = llvm::omp::topDistributeSet.test (ompDirective);
3428
+ genDistributeOp (converter, eval, /* genNested=*/ false , currentLocation,
3429
+ loopOpClauseList, outerCombined);
3391
3430
}
3392
3431
if ((llvm::omp::allParallelSet & llvm::omp::loopConstructSet)
3393
3432
.test (ompDirective)) {
0 commit comments