Skip to content

Commit 483045d

Browse files
committed
[OpenMP] Fixes for coexecute definitions
1 parent d0ae1a2 commit 483045d

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
@@ -2593,12 +2593,13 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
25932593
}
25942594

25952595
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) {
2596+
genCoexecuteOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
2597+
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2598+
mlir::Location loc, const ConstructQueue &queue,
2599+
ConstructQueue::const_iterator item) {
26002600
return genOpWithBody<mlir::omp::CoexecuteOp>(
2601-
converter, eval, currentLocation, /*outerCombined=*/false, &clauseList);
2601+
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
2602+
llvm::omp::Directive::OMPD_coexecute), queue, item);
26022603
}
26032604

26042605
//===----------------------------------------------------------------------===//
@@ -3763,7 +3764,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
37633764
item);
37643765
break;
37653766
case llvm::omp::Directive::OMPD_coexecute:
3766-
newOp = genCoexecuteOp(converter, eval, currentLocation, beginClauseList);
3767+
newOp = genCoexecuteOp(converter, symTable, semaCtx, eval, loc, queue, item);
37673768
break;
37683769
case llvm::omp::Directive::OMPD_tile:
37693770
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
@@ -2179,29 +2179,28 @@ def OMP_TargetTeams : Directive<"target teams"> {
21792179
}
21802180
def OMP_TargetTeamsCoexecute : Directive<"target teams coexecute"> {
21812181
let allowedClauses = [
2182-
VersionedClause<OMPC_If>,
2183-
VersionedClause<OMPC_Map>,
2184-
VersionedClause<OMPC_Private>,
2182+
VersionedClause<OMPC_Allocate>,
21852183
VersionedClause<OMPC_Depend>,
21862184
VersionedClause<OMPC_FirstPrivate>,
2187-
VersionedClause<OMPC_IsDevicePtr>,
21882185
VersionedClause<OMPC_HasDeviceAddr, 51>,
2186+
VersionedClause<OMPC_If>,
2187+
VersionedClause<OMPC_IsDevicePtr>,
2188+
VersionedClause<OMPC_Map>,
2189+
VersionedClause<OMPC_OMPX_Attribute>,
2190+
VersionedClause<OMPC_Private>,
21892191
VersionedClause<OMPC_Reduction>,
2190-
VersionedClause<OMPC_Allocate>,
2191-
VersionedClause<OMPC_UsesAllocators, 50>,
21922192
VersionedClause<OMPC_Shared>,
2193-
VersionedClause<OMPC_OMPX_Attribute>,
2193+
VersionedClause<OMPC_UsesAllocators, 50>,
21942194
];
2195-
21962195
let allowedOnceClauses = [
2196+
VersionedClause<OMPC_Default>,
2197+
VersionedClause<OMPC_DefaultMap>,
21972198
VersionedClause<OMPC_Device>,
21982199
VersionedClause<OMPC_NoWait>,
2199-
VersionedClause<OMPC_DefaultMap>,
2200-
VersionedClause<OMPC_Default>,
22012200
VersionedClause<OMPC_NumTeams>,
2202-
VersionedClause<OMPC_ThreadLimit>,
22032201
VersionedClause<OMPC_OMPX_DynCGroupMem>,
22042202
VersionedClause<OMPC_OMPX_Bare>,
2203+
VersionedClause<OMPC_ThreadLimit>,
22052204
];
22062205
let leafConstructs = [OMP_Target, OMP_Teams, OMP_Coexecute];
22072206
let category = CA_Executable;
@@ -2486,20 +2485,20 @@ def OMP_TaskLoopSimd : Directive<"taskloop simd"> {
24862485
}
24872486
def OMP_TeamsCoexecute : Directive<"teams coexecute"> {
24882487
let allowedClauses = [
2489-
VersionedClause<OMPC_Private>,
2490-
VersionedClause<OMPC_FirstPrivate>,
2491-
VersionedClause<OMPC_Shared>,
2492-
VersionedClause<OMPC_Reduction>,
24932488
VersionedClause<OMPC_Allocate>,
2489+
VersionedClause<OMPC_FirstPrivate>,
24942490
VersionedClause<OMPC_OMPX_Attribute>,
2491+
VersionedClause<OMPC_Private>,
2492+
VersionedClause<OMPC_Reduction>,
2493+
VersionedClause<OMPC_Shared>,
24952494
];
24962495
let allowedOnceClauses = [
24972496
VersionedClause<OMPC_Default>,
24982497
VersionedClause<OMPC_If, 52>,
24992498
VersionedClause<OMPC_NumTeams>,
2500-
VersionedClause<OMPC_ThreadLimit>
2499+
VersionedClause<OMPC_ThreadLimit>,
25012500
];
2502-
let leafConstructs = [OMP_Target, OMP_Teams];
2501+
let leafConstructs = [OMP_Teams, OMP_Coexecute];
25032502
let category = CA_Executable;
25042503
}
25052504
def OMP_TeamsDistribute : Directive<"teams distribute"> {

0 commit comments

Comments
 (0)