Skip to content

Commit d0ae1a2

Browse files
ivanradanovskc7
authored andcommitted
Initial frontend support for coexecute
1 parent 5241156 commit d0ae1a2

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

flang/include/flang/Semantics/openmp-directive-sets.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static const OmpDirectiveSet topTargetSet{
143143
Directive::OMPD_target_teams_distribute_parallel_do_simd,
144144
Directive::OMPD_target_teams_distribute_simd,
145145
Directive::OMPD_target_teams_loop,
146+
Directive::OMPD_target_teams_coexecute,
146147
};
147148

148149
static const OmpDirectiveSet allTargetSet{topTargetSet};
@@ -187,9 +188,16 @@ static const OmpDirectiveSet allTeamsSet{
187188
Directive::OMPD_target_teams_distribute_parallel_do_simd,
188189
Directive::OMPD_target_teams_distribute_simd,
189190
Directive::OMPD_target_teams_loop,
191+
Directive::OMPD_target_teams_coexecute,
190192
} | topTeamsSet,
191193
};
192194

195+
static const OmpDirectiveSet allCoexecuteSet{
196+
Directive::OMPD_coexecute,
197+
Directive::OMPD_teams_coexecute,
198+
Directive::OMPD_target_teams_coexecute,
199+
};
200+
193201
//===----------------------------------------------------------------------===//
194202
// Directive sets for groups of multiple directives
195203
//===----------------------------------------------------------------------===//
@@ -230,6 +238,9 @@ static const OmpDirectiveSet blockConstructSet{
230238
Directive::OMPD_taskgroup,
231239
Directive::OMPD_teams,
232240
Directive::OMPD_workshare,
241+
Directive::OMPD_target_teams_coexecute,
242+
Directive::OMPD_teams_coexecute,
243+
Directive::OMPD_coexecute,
233244
};
234245

235246
static const OmpDirectiveSet loopConstructSet{
@@ -294,6 +305,7 @@ static const OmpDirectiveSet workShareSet{
294305
Directive::OMPD_scope,
295306
Directive::OMPD_sections,
296307
Directive::OMPD_single,
308+
Directive::OMPD_coexecute,
297309
} | allDoSet,
298310
};
299311

@@ -376,6 +388,7 @@ static const OmpDirectiveSet nestedReduceWorkshareAllowedSet{
376388
};
377389

378390
static const OmpDirectiveSet nestedTeamsAllowedSet{
391+
Directive::OMPD_coexecute,
379392
Directive::OMPD_distribute,
380393
Directive::OMPD_distribute_parallel_do,
381394
Directive::OMPD_distribute_parallel_do_simd,

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,15 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
25922592
queue, item, clauseOps);
25932593
}
25942594

2595+
static mlir::omp::CoexecuteOp
2596+
genCoexecuteOp(Fortran::lower::AbstractConverter &converter,
2597+
Fortran::lower::pft::Evaluation &eval,
2598+
mlir::Location currentLocation,
2599+
const Fortran::parser::OmpClauseList &clauseList) {
2600+
return genOpWithBody<mlir::omp::CoexecuteOp>(
2601+
converter, eval, currentLocation, /*outerCombined=*/false, &clauseList);
2602+
}
2603+
25952604
//===----------------------------------------------------------------------===//
25962605
// Code generation for atomic operations
25972606
//===----------------------------------------------------------------------===//
@@ -3753,6 +3762,9 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
37533762
newOp = genTeamsOp(converter, symTable, stmtCtx, semaCtx, eval, loc, queue,
37543763
item);
37553764
break;
3765+
case llvm::omp::Directive::OMPD_coexecute:
3766+
newOp = genCoexecuteOp(converter, eval, currentLocation, beginClauseList);
3767+
break;
37563768
case llvm::omp::Directive::OMPD_tile:
37573769
case llvm::omp::Directive::OMPD_unroll:
37583770
TODO(loc, "Unhandled loop directive (" +

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,12 +1350,15 @@ TYPE_PARSER(
13501350
"SINGLE" >> pure(llvm::omp::Directive::OMPD_single),
13511351
"TARGET DATA" >> pure(llvm::omp::Directive::OMPD_target_data),
13521352
"TARGET PARALLEL" >> pure(llvm::omp::Directive::OMPD_target_parallel),
1353+
"TARGET TEAMS COEXECUTE" >> pure(llvm::omp::Directive::OMPD_target_teams_coexecute),
13531354
"TARGET TEAMS" >> pure(llvm::omp::Directive::OMPD_target_teams),
13541355
"TARGET" >> pure(llvm::omp::Directive::OMPD_target),
13551356
"TASK"_id >> pure(llvm::omp::Directive::OMPD_task),
13561357
"TASKGROUP" >> pure(llvm::omp::Directive::OMPD_taskgroup),
1358+
"TEAMS COEXECUTE" >> pure(llvm::omp::Directive::OMPD_teams_coexecute),
13571359
"TEAMS" >> pure(llvm::omp::Directive::OMPD_teams),
1358-
"WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare))))
1360+
"WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare),
1361+
"COEXECUTE" >> pure(llvm::omp::Directive::OMPD_coexecute))))
13591362

13601363
TYPE_PARSER(sourced(construct<OmpBeginBlockDirective>(
13611364
sourced(Parser<OmpBlockDirective>{}), Parser<OmpClauseList>{})))

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,9 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
16071607
case llvm::omp::Directive::OMPD_task:
16081608
case llvm::omp::Directive::OMPD_taskgroup:
16091609
case llvm::omp::Directive::OMPD_teams:
1610+
case llvm::omp::Directive::OMPD_coexecute:
1611+
case llvm::omp::Directive::OMPD_teams_coexecute:
1612+
case llvm::omp::Directive::OMPD_target_teams_coexecute:
16101613
case llvm::omp::Directive::OMPD_workshare:
16111614
case llvm::omp::Directive::OMPD_parallel_workshare:
16121615
case llvm::omp::Directive::OMPD_target_teams:
@@ -1640,6 +1643,9 @@ void OmpAttributeVisitor::Post(const parser::OpenMPBlockConstruct &x) {
16401643
case llvm::omp::Directive::OMPD_target:
16411644
case llvm::omp::Directive::OMPD_task:
16421645
case llvm::omp::Directive::OMPD_teams:
1646+
case llvm::omp::Directive::OMPD_coexecute:
1647+
case llvm::omp::Directive::OMPD_teams_coexecute:
1648+
case llvm::omp::Directive::OMPD_target_teams_coexecute:
16431649
case llvm::omp::Directive::OMPD_parallel_workshare:
16441650
case llvm::omp::Directive::OMPD_target_teams:
16451651
case llvm::omp::Directive::OMPD_target_parallel: {

0 commit comments

Comments
 (0)