Skip to content

Commit ca0cc44

Browse files
committed
[OpenMP] Fixes for coexecute definitions
1 parent 7ecec06 commit ca0cc44

File tree

4 files changed

+83
-23
lines changed

4 files changed

+83
-23
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static const OmpDirectiveSet topTeamsSet{
173173
Directive::OMPD_teams_distribute_parallel_do_simd,
174174
Directive::OMPD_teams_distribute_simd,
175175
Directive::OMPD_teams_loop,
176+
Directive::OMPD_teams_coexecute,
176177
};
177178

178179
static const OmpDirectiveSet bottomTeamsSet{

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,12 +2671,13 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
26712671
}
26722672

26732673
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) {
2674+
genCoexecuteOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
2675+
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2676+
mlir::Location loc, const ConstructQueue &queue,
2677+
ConstructQueue::const_iterator item) {
26782678
return genOpWithBody<mlir::omp::CoexecuteOp>(
2679-
converter, eval, currentLocation, /*outerCombined=*/false, &clauseList);
2679+
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
2680+
llvm::omp::Directive::OMPD_coexecute), queue, item);
26802681
}
26812682

26822683
//===----------------------------------------------------------------------===//
@@ -3939,7 +3940,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
39393940
item);
39403941
break;
39413942
case llvm::omp::Directive::OMPD_coexecute:
3942-
newOp = genCoexecuteOp(converter, eval, currentLocation, beginClauseList);
3943+
newOp = genCoexecuteOp(converter, symTable, semaCtx, eval, loc, queue, item);
39433944
break;
39443945
case llvm::omp::Directive::OMPD_tile:
39453946
case llvm::omp::Directive::OMPD_unroll: {

flang/test/Lower/OpenMP/coexecute.f90

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
2+
3+
! CHECK-LABEL: func @_QPtarget_teams_coexecute
4+
subroutine target_teams_coexecute()
5+
! CHECK: omp.target
6+
! CHECK: omp.teams
7+
! CHECK: omp.coexecute
8+
!$omp target teams coexecute
9+
! CHECK: fir.call
10+
call f1()
11+
! CHECK: omp.terminator
12+
! CHECK: omp.terminator
13+
! CHECK: omp.terminator
14+
!$omp end target teams coexecute
15+
end subroutine target_teams_coexecute
16+
17+
! CHECK-LABEL: func @_QPteams_coexecute
18+
subroutine teams_coexecute()
19+
! CHECK: omp.teams
20+
! CHECK: omp.coexecute
21+
!$omp teams coexecute
22+
! CHECK: fir.call
23+
call f1()
24+
! CHECK: omp.terminator
25+
! CHECK: omp.terminator
26+
!$omp end teams coexecute
27+
end subroutine teams_coexecute
28+
29+
! CHECK-LABEL: func @_QPtarget_teams_coexecute_m
30+
subroutine target_teams_coexecute_m()
31+
! CHECK: omp.target
32+
! CHECK: omp.teams
33+
! CHECK: omp.coexecute
34+
!$omp target
35+
!$omp teams
36+
!$omp coexecute
37+
! CHECK: fir.call
38+
call f1()
39+
! CHECK: omp.terminator
40+
! CHECK: omp.terminator
41+
! CHECK: omp.terminator
42+
!$omp end coexecute
43+
!$omp end teams
44+
!$omp end target
45+
end subroutine target_teams_coexecute_m
46+
47+
! CHECK-LABEL: func @_QPteams_coexecute_m
48+
subroutine teams_coexecute_m()
49+
! CHECK: omp.teams
50+
! CHECK: omp.coexecute
51+
!$omp teams
52+
!$omp coexecute
53+
! CHECK: fir.call
54+
call f1()
55+
! CHECK: omp.terminator
56+
! CHECK: omp.terminator
57+
!$omp end coexecute
58+
!$omp end teams
59+
end subroutine teams_coexecute_m

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,29 +2209,28 @@ def OMP_TargetTeams : Directive<"target teams"> {
22092209
}
22102210
def OMP_TargetTeamsCoexecute : Directive<"target teams coexecute"> {
22112211
let allowedClauses = [
2212-
VersionedClause<OMPC_If>,
2213-
VersionedClause<OMPC_Map>,
2214-
VersionedClause<OMPC_Private>,
2212+
VersionedClause<OMPC_Allocate>,
22152213
VersionedClause<OMPC_Depend>,
22162214
VersionedClause<OMPC_FirstPrivate>,
2217-
VersionedClause<OMPC_IsDevicePtr>,
22182215
VersionedClause<OMPC_HasDeviceAddr, 51>,
2216+
VersionedClause<OMPC_If>,
2217+
VersionedClause<OMPC_IsDevicePtr>,
2218+
VersionedClause<OMPC_Map>,
2219+
VersionedClause<OMPC_OMPX_Attribute>,
2220+
VersionedClause<OMPC_Private>,
22192221
VersionedClause<OMPC_Reduction>,
2220-
VersionedClause<OMPC_Allocate>,
2221-
VersionedClause<OMPC_UsesAllocators, 50>,
22222222
VersionedClause<OMPC_Shared>,
2223-
VersionedClause<OMPC_OMPX_Attribute>,
2223+
VersionedClause<OMPC_UsesAllocators, 50>,
22242224
];
2225-
22262225
let allowedOnceClauses = [
2226+
VersionedClause<OMPC_Default>,
2227+
VersionedClause<OMPC_DefaultMap>,
22272228
VersionedClause<OMPC_Device>,
22282229
VersionedClause<OMPC_NoWait>,
2229-
VersionedClause<OMPC_DefaultMap>,
2230-
VersionedClause<OMPC_Default>,
22312230
VersionedClause<OMPC_NumTeams>,
2232-
VersionedClause<OMPC_ThreadLimit>,
22332231
VersionedClause<OMPC_OMPX_DynCGroupMem>,
22342232
VersionedClause<OMPC_OMPX_Bare>,
2233+
VersionedClause<OMPC_ThreadLimit>,
22352234
];
22362235
let leafConstructs = [OMP_Target, OMP_Teams, OMP_Coexecute];
22372236
let category = CA_Executable;
@@ -2524,20 +2523,20 @@ def OMP_TaskLoopSimd : Directive<"taskloop simd"> {
25242523
}
25252524
def OMP_TeamsCoexecute : Directive<"teams coexecute"> {
25262525
let allowedClauses = [
2527-
VersionedClause<OMPC_Private>,
2528-
VersionedClause<OMPC_FirstPrivate>,
2529-
VersionedClause<OMPC_Shared>,
2530-
VersionedClause<OMPC_Reduction>,
25312526
VersionedClause<OMPC_Allocate>,
2527+
VersionedClause<OMPC_FirstPrivate>,
25322528
VersionedClause<OMPC_OMPX_Attribute>,
2529+
VersionedClause<OMPC_Private>,
2530+
VersionedClause<OMPC_Reduction>,
2531+
VersionedClause<OMPC_Shared>,
25332532
];
25342533
let allowedOnceClauses = [
25352534
VersionedClause<OMPC_Default>,
25362535
VersionedClause<OMPC_If, 52>,
25372536
VersionedClause<OMPC_NumTeams>,
2538-
VersionedClause<OMPC_ThreadLimit>
2537+
VersionedClause<OMPC_ThreadLimit>,
25392538
];
2540-
let leafConstructs = [OMP_Target, OMP_Teams];
2539+
let leafConstructs = [OMP_Teams, OMP_Coexecute];
25412540
let category = CA_Executable;
25422541
}
25432542
def OMP_TeamsDistribute : Directive<"teams distribute"> {

0 commit comments

Comments
 (0)