Skip to content

Commit 00c24c4

Browse files
committed
R3: Removing maskedTId changes & adding graceful failure in Lowering
1 parent 553b416 commit 00c24c4

File tree

4 files changed

+74
-26
lines changed

4 files changed

+74
-26
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,15 @@ static const OmpDirectiveSet compositeConstructSet{
205205
};
206206

207207
static const OmpDirectiveSet blockConstructSet{
208+
Directive::OMPD_masked,
209+
Directive::OMPD_masked_taskloop,
210+
Directive::OMPD_masked_taskloop_simd,
208211
Directive::OMPD_master,
209212
Directive::OMPD_ordered,
210213
Directive::OMPD_parallel,
214+
Directive::OMPD_parallel_masked,
215+
Directive::OMPD_parallel_masked_taskloop,
216+
Directive::OMPD_parallel_masked_taskloop_simd,
211217
Directive::OMPD_parallel_workshare,
212218
Directive::OMPD_single,
213219
Directive::OMPD_target,

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1970,10 +1970,12 @@ static void genOMPDispatch(Fortran::lower::AbstractConverter &converter,
19701970
genWsloopOp(converter, symTable, semaCtx, eval, loc, clauses, queue, item);
19711971
break;
19721972
case llvm::omp::Directive::OMPD_loop:
1973-
case llvm::omp::Directive::OMPD_masked:
19741973
TODO(loc, "Unhandled loop directive (" +
19751974
llvm::omp::getOpenMPDirectiveName(dir) + ")");
19761975
break;
1976+
case llvm::omp::Directive::OMPD_masked:
1977+
TODO(loc, "Unhandled directive " +
1978+
llvm::omp::getOpenMPDirectiveName(dir));
19771979
case llvm::omp::Directive::OMPD_master:
19781980
genMasterOp(converter, symTable, semaCtx, eval, loc, clauses, queue, item);
19791981
break;

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
#include "flang/Parser/parse-tree.h"
2020
#include "flang/Parser/tools.h"
2121
#include "flang/Semantics/expression.h"
22-
#include <cstdint>
2322
#include <list>
2423
#include <map>
25-
#include <optional>
2624
#include <sstream>
2725

2826
template <typename T>
@@ -52,7 +50,6 @@ template <typename T> class DirectiveAttributeVisitor {
5250
Symbol::Flag defaultDSA{Symbol::Flag::AccShared}; // TODOACC
5351
std::map<const Symbol *, Symbol::Flag> objectWithDSA;
5452
bool withinConstruct{false};
55-
std::optional<int64_t> maskedTId;
5653
std::int64_t associatedLoopLevel{0};
5754
};
5855

@@ -93,9 +90,6 @@ template <typename T> class DirectiveAttributeVisitor {
9390
void SetContextAssociatedLoopLevel(std::int64_t level) {
9491
GetContext().associatedLoopLevel = level;
9592
}
96-
void SetMaskedTId(std::optional<int64_t> tid) {
97-
GetContext().maskedTId = tid;
98-
}
9993
Symbol &MakeAssocSymbol(const SourceName &name, Symbol &prev, Scope &scope) {
10094
const auto pair{scope.try_emplace(name, Attrs{}, HostAssocDetails{prev})};
10195
return *pair.first->second;
@@ -652,7 +646,6 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
652646

653647
private:
654648
std::int64_t GetAssociatedLoopLevelFromClauses(const parser::OmpClauseList &);
655-
std::optional<int64_t> GetMaskedTId(const parser::OmpClauseList &);
656649

657650
Symbol::Flags dataSharingAttributeFlags{Symbol::Flag::OmpShared,
658651
Symbol::Flag::OmpPrivate, Symbol::Flag::OmpFirstPrivate,
@@ -1505,35 +1498,17 @@ void AccAttributeVisitor::CheckMultipleAppearances(
15051498
AddDataSharingAttributeObject(*target);
15061499
}
15071500
}
1508-
std::optional<int64_t> OmpAttributeVisitor::GetMaskedTId(
1509-
const parser::OmpClauseList &clauseList) {
1510-
for (const auto &clause : clauseList.v) {
1511-
if (const auto *filterClause{
1512-
std::get_if<parser::OmpClause::Filter>(&clause.u)}) {
1513-
if (const auto v{EvaluateInt64(context_, filterClause->v)}) {
1514-
return v;
1515-
}
1516-
}
1517-
}
1518-
// if no thread id is specified in filter clause, the masked thread id should
1519-
// be master's
1520-
return 0;
1521-
}
15221501

15231502
bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
15241503
const auto &beginBlockDir{std::get<parser::OmpBeginBlockDirective>(x.t)};
15251504
const auto &beginDir{std::get<parser::OmpBlockDirective>(beginBlockDir.t)};
1526-
const auto &clauseList{std::get<parser::OmpClauseList>(beginBlockDir.t)};
15271505
switch (beginDir.v) {
15281506
case llvm::omp::Directive::OMPD_masked_taskloop_simd:
15291507
case llvm::omp::Directive::OMPD_masked_taskloop:
15301508
case llvm::omp::Directive::OMPD_masked:
15311509
case llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd:
15321510
case llvm::omp::Directive::OMPD_parallel_masked_taskloop:
15331511
case llvm::omp::Directive::OMPD_parallel_masked:
1534-
PushContext(beginDir.source, beginDir.v);
1535-
SetMaskedTId(GetMaskedTId(clauseList));
1536-
break;
15371512
case llvm::omp::Directive::OMPD_master:
15381513
case llvm::omp::Directive::OMPD_ordered:
15391514
case llvm::omp::Directive::OMPD_parallel:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
! This test checks lowering of OpenMP masked Directive.
3+
4+
// RUN: not flang-new -fc1 -emit-fir -fopenmp %s 2>&1 | FileCheck %s
5+
6+
subroutine test_masked()
7+
integer :: c = 1
8+
// CHECK: not yet implemented: Unhandled Directive masked
9+
!$omp masked
10+
c = c + 1
11+
!$omp end masked
12+
// CHECK: not yet implemented: Unhandled Directive masked
13+
!$omp masked filter(1)
14+
c = c + 2
15+
!$omp end masked
16+
end subroutine
17+
18+
subroutine test_masked_taskloop_simd()
19+
integer :: i, j = 1
20+
// CHECK: not yet implemented: Unhandled Directive masked
21+
!$omp masked taskloop simd
22+
do i=1,10
23+
j = j + 1
24+
end do
25+
!$omp end masked taskloop simd
26+
end subroutine
27+
28+
subroutine test_masked_taskloop
29+
integer :: i, j = 1
30+
// CHECK: not yet implemented: Unhandled Directive masked
31+
!$omp masked taskloop filter(2)
32+
do i=1,10
33+
j = j + 1
34+
end do
35+
!$omp end masked taskloop
36+
end subroutine
37+
38+
subroutine test_parallel_masked
39+
integer, parameter :: i = 1, j = 1
40+
integer :: c = 2
41+
// CHECK: not yet implemented: Unhandled Directive masked
42+
!$omp parallel masked filter(i+j)
43+
c = c + 2
44+
!$omp end parallel masked
45+
end subroutine
46+
47+
subroutine test_parallel_masked_taskloop_simd
48+
integer :: i, j = 1
49+
// CHECK: not yet implemented: Unhandled Directive masked
50+
!$omp parallel masked taskloop simd
51+
do i=1,10
52+
j = j + 1
53+
end do
54+
!$omp end parallel masked taskloop simd
55+
end subroutine
56+
57+
subroutine test_parallel_masked_taskloop
58+
integer :: i, j = 1
59+
// CHECK: not yet implemented: Unhandled Directive masked
60+
!$omp parallel masked taskloop filter(2)
61+
do i=1,10
62+
j = j + 1
63+
end do
64+
!$omp end parallel masked taskloop
65+
end subroutine

0 commit comments

Comments
 (0)