Skip to content

Commit 7ecec06

Browse files
ivanradanovskc7
authored andcommitted
Initial frontend support for coexecute
1 parent 9b8d66a commit 7ecec06

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
@@ -2670,6 +2670,15 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
26702670
queue, item, clauseOps);
26712671
}
26722672

2673+
static mlir::omp::CoexecuteOp
2674+
genCoexecuteOp(Fortran::lower::AbstractConverter &converter,
2675+
Fortran::lower::pft::Evaluation &eval,
2676+
mlir::Location currentLocation,
2677+
const Fortran::parser::OmpClauseList &clauseList) {
2678+
return genOpWithBody<mlir::omp::CoexecuteOp>(
2679+
converter, eval, currentLocation, /*outerCombined=*/false, &clauseList);
2680+
}
2681+
26732682
//===----------------------------------------------------------------------===//
26742683
// Code generation for atomic operations
26752684
//===----------------------------------------------------------------------===//
@@ -3929,6 +3938,9 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
39293938
newOp = genTeamsOp(converter, symTable, stmtCtx, semaCtx, eval, loc, queue,
39303939
item);
39313940
break;
3941+
case llvm::omp::Directive::OMPD_coexecute:
3942+
newOp = genCoexecuteOp(converter, eval, currentLocation, beginClauseList);
3943+
break;
39323944
case llvm::omp::Directive::OMPD_tile:
39333945
case llvm::omp::Directive::OMPD_unroll: {
39343946
unsigned version = semaCtx.langOptions().OpenMPVersion;

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,12 +1344,15 @@ TYPE_PARSER(
13441344
"SINGLE" >> pure(llvm::omp::Directive::OMPD_single),
13451345
"TARGET DATA" >> pure(llvm::omp::Directive::OMPD_target_data),
13461346
"TARGET PARALLEL" >> pure(llvm::omp::Directive::OMPD_target_parallel),
1347+
"TARGET TEAMS COEXECUTE" >> pure(llvm::omp::Directive::OMPD_target_teams_coexecute),
13471348
"TARGET TEAMS" >> pure(llvm::omp::Directive::OMPD_target_teams),
13481349
"TARGET" >> pure(llvm::omp::Directive::OMPD_target),
13491350
"TASK"_id >> pure(llvm::omp::Directive::OMPD_task),
13501351
"TASKGROUP" >> pure(llvm::omp::Directive::OMPD_taskgroup),
1352+
"TEAMS COEXECUTE" >> pure(llvm::omp::Directive::OMPD_teams_coexecute),
13511353
"TEAMS" >> pure(llvm::omp::Directive::OMPD_teams),
1352-
"WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare))))
1354+
"WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare),
1355+
"COEXECUTE" >> pure(llvm::omp::Directive::OMPD_coexecute))))
13531356

13541357
TYPE_PARSER(sourced(construct<OmpBeginBlockDirective>(
13551358
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
@@ -1617,6 +1617,9 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
16171617
case llvm::omp::Directive::OMPD_task:
16181618
case llvm::omp::Directive::OMPD_taskgroup:
16191619
case llvm::omp::Directive::OMPD_teams:
1620+
case llvm::omp::Directive::OMPD_coexecute:
1621+
case llvm::omp::Directive::OMPD_teams_coexecute:
1622+
case llvm::omp::Directive::OMPD_target_teams_coexecute:
16201623
case llvm::omp::Directive::OMPD_workshare:
16211624
case llvm::omp::Directive::OMPD_parallel_workshare:
16221625
case llvm::omp::Directive::OMPD_target_teams:
@@ -1650,6 +1653,9 @@ void OmpAttributeVisitor::Post(const parser::OpenMPBlockConstruct &x) {
16501653
case llvm::omp::Directive::OMPD_target:
16511654
case llvm::omp::Directive::OMPD_task:
16521655
case llvm::omp::Directive::OMPD_teams:
1656+
case llvm::omp::Directive::OMPD_coexecute:
1657+
case llvm::omp::Directive::OMPD_teams_coexecute:
1658+
case llvm::omp::Directive::OMPD_target_teams_coexecute:
16531659
case llvm::omp::Directive::OMPD_parallel_workshare:
16541660
case llvm::omp::Directive::OMPD_target_teams:
16551661
case llvm::omp::Directive::OMPD_target_parallel: {

0 commit comments

Comments
 (0)