Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flang/include/flang/Lower/OpenMP/Clauses.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ using Read = tomp::clause::ReadT<TypeTy, IdTy, ExprTy>;
using Reduction = tomp::clause::ReductionT<TypeTy, IdTy, ExprTy>;
using Relaxed = tomp::clause::RelaxedT<TypeTy, IdTy, ExprTy>;
using Release = tomp::clause::ReleaseT<TypeTy, IdTy, ExprTy>;
using Replayable = tomp::clause::ReplayableT<TypeTy, IdTy, ExprTy>;
using ReverseOffload = tomp::clause::ReverseOffloadT<TypeTy, IdTy, ExprTy>;
using Safelen = tomp::clause::SafelenT<TypeTy, IdTy, ExprTy>;
using Schedule = tomp::clause::ScheduleT<TypeTy, IdTy, ExprTy>;
Expand All @@ -290,6 +291,7 @@ using Permutation = tomp::clause::PermutationT<TypeTy, IdTy, ExprTy>;
using TaskReduction = tomp::clause::TaskReductionT<TypeTy, IdTy, ExprTy>;
using ThreadLimit = tomp::clause::ThreadLimitT<TypeTy, IdTy, ExprTy>;
using Threads = tomp::clause::ThreadsT<TypeTy, IdTy, ExprTy>;
using Transparent = tomp::clause::TransparentT<TypeTy, IdTy, ExprTy>;
using To = tomp::clause::ToT<TypeTy, IdTy, ExprTy>;
using UnifiedAddress = tomp::clause::UnifiedAddressT<TypeTy, IdTy, ExprTy>;
using UnifiedSharedMemory =
Expand Down
2 changes: 2 additions & 0 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ class ParseTreeDumper {
NODE(parser, OmpReductionSpecifier)
NODE(parser, OmpRefModifier)
NODE_ENUM(OmpRefModifier, Value)
NODE(parser, OmpReplayableClause)
NODE(parser, OmpScheduleClause)
NODE(OmpScheduleClause, Modifier)
NODE_ENUM(OmpScheduleClause, Kind)
Expand Down Expand Up @@ -686,6 +687,7 @@ class ParseTreeDumper {
NODE(parser, OmpTraitSetSelector)
NODE(parser, OmpTraitSetSelectorName)
NODE_ENUM(OmpTraitSetSelectorName, Value)
NODE(parser, OmpTransparentClause)
NODE(parser, OmpTypeNameList)
NODE(parser, OmpTypeSpecifier)
NODE(parser, OmpUpdateClause)
Expand Down
16 changes: 16 additions & 0 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4643,6 +4643,14 @@ struct OmpReductionClause {
std::tuple<MODIFIERS(), OmpObjectList> t;
};

// Ref: [6.0:440:441]
//
// replayable-clause ->
// REPLAYABLE[(replayable-expression)] // since 6.0
struct OmpReplayableClause {
WRAPPER_CLASS_BOILERPLATE(OmpReplayableClause, Scalar<Logical<ConstantExpr>>);
};

// Ref: [4.5:56-63], [5.0:101-109], [5.1:126-133], [5.2:252-254]
//
// schedule-clause ->
Expand Down Expand Up @@ -4692,6 +4700,14 @@ struct OmpToClause {
std::tuple<MODIFIERS(), OmpObjectList, /*CommaSeparated=*/bool> t;
};

// Ref: [6.0:510-511]
//
// transparent-clause ->
// TRANSPARENT[(impex-type)] // since 6.0
struct OmpTransparentClause {
WRAPPER_CLASS_BOILERPLATE(OmpTransparentClause, ScalarIntExpr);
};

// Ref: [5.0:254-255], [5.1:287-288], [5.2:321-322]
//
// In ATOMIC construct
Expand Down
4 changes: 3 additions & 1 deletion flang/lib/Lower/OpenMP/Clauses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ MAKE_EMPTY_CLASS(Relaxed, Relaxed);
MAKE_EMPTY_CLASS(Release, Release);
MAKE_EMPTY_CLASS(ReverseOffload, ReverseOffload);
MAKE_EMPTY_CLASS(SeqCst, SeqCst);
MAKE_EMPTY_CLASS(SelfMaps, SelfMaps);
MAKE_EMPTY_CLASS(Simd, Simd);
MAKE_EMPTY_CLASS(Threads, Threads);
MAKE_EMPTY_CLASS(UnifiedAddress, UnifiedAddress);
MAKE_EMPTY_CLASS(UnifiedSharedMemory, UnifiedSharedMemory);
MAKE_EMPTY_CLASS(SelfMaps, SelfMaps);
MAKE_EMPTY_CLASS(Unknown, Unknown);
MAKE_EMPTY_CLASS(Untied, Untied);
MAKE_EMPTY_CLASS(Weak, Weak);
Expand All @@ -257,6 +257,8 @@ MAKE_EMPTY_CLASS(Threadprivate, Threadprivate);

MAKE_INCOMPLETE_CLASS(AdjustArgs, AdjustArgs);
MAKE_INCOMPLETE_CLASS(AppendArgs, AppendArgs);
MAKE_INCOMPLETE_CLASS(Replayable, Replayable);
MAKE_INCOMPLETE_CLASS(Transparent, Transparent);

List<IteratorSpecifier>
makeIteratorSpecifiers(const parser::OmpIteratorSpecifier &inp,
Expand Down
12 changes: 12 additions & 0 deletions flang/lib/Parser/openmp-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ namespace Fortran::parser {
constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok;
constexpr auto endOmpLine = space >> endOfLine;

constexpr auto logicalConstantExpr{logical(constantExpr)};
constexpr auto scalarLogicalConstantExpr{scalar(logicalConstantExpr)};

// Given a parser for a single element, and a parser for a list of elements
// of the same type, create a parser that constructs the entire list by having
// the single element be the head of the list, and the rest be the tail.
Expand Down Expand Up @@ -868,6 +871,8 @@ TYPE_PARSER(construct<OmpReductionClause>(
maybe(nonemptyList(Parser<OmpReductionClause::Modifier>{}) / ":"),
Parser<OmpObjectList>{}))

TYPE_PARSER(construct<OmpReplayableClause>(scalarLogicalConstantExpr))

// OMP 5.0 2.19.5.6 IN_REDUCTION (reduction-identifier: variable-name-list)
TYPE_PARSER(construct<OmpInReductionClause>(
maybe(nonemptyList(Parser<OmpInReductionClause::Modifier>{}) / ":"),
Expand All @@ -877,6 +882,8 @@ TYPE_PARSER(construct<OmpTaskReductionClause>(
maybe(nonemptyList(Parser<OmpTaskReductionClause::Modifier>{}) / ":"),
Parser<OmpObjectList>{}))

TYPE_PARSER(construct<OmpTransparentClause>(scalarIntExpr))

// OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
// OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier
// [, allocate-modifier] :]
Expand Down Expand Up @@ -1192,6 +1199,8 @@ TYPE_PARSER( //
"READ" >> construct<OmpClause>(construct<OmpClause::Read>()) ||
"RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) ||
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
"REPLAYABLE" >> construct<OmpClause>(construct<OmpClause::Replayable>(
maybe(parenthesized(Parser<OmpReplayableClause>{})))) ||
"REVERSE_OFFLOAD" >>
construct<OmpClause>(construct<OmpClause::ReverseOffload>()) ||
"SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>(
Expand All @@ -1215,6 +1224,9 @@ TYPE_PARSER( //
parenthesized(scalarIntExpr))) ||
"TO" >> construct<OmpClause>(construct<OmpClause::To>(
parenthesized(Parser<OmpToClause>{}))) ||
"TRANSPARENT" >>
construct<OmpClause>(construct<OmpClause::Transparent>(
maybe(parenthesized(Parser<OmpTransparentClause>{})))) ||
"USE" >> construct<OmpClause>(construct<OmpClause::Use>(
parenthesized(Parser<OmpObject>{}))) ||
"USE_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::UseDevicePtr>(
Expand Down
2 changes: 2 additions & 0 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,8 @@ CHECK_SIMPLE_CLAUSE(AcqRel, OMPC_acq_rel)
CHECK_SIMPLE_CLAUSE(Acquire, OMPC_acquire)
CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed)
CHECK_SIMPLE_CLAUSE(Release, OMPC_release)
CHECK_SIMPLE_CLAUSE(Replayable, OMPC_replayable)
CHECK_SIMPLE_CLAUSE(Transparent, OMPC_transparent)
CHECK_SIMPLE_CLAUSE(SeqCst, OMPC_seq_cst)
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)

Expand Down
60 changes: 60 additions & 0 deletions flang/test/Parser/OpenMP/replayable-clause.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s

subroutine f00
!$omp task replayable
block
end block
end

!UNPARSE: SUBROUTINE f00
!UNPARSE: !$OMP TASK REPLAYABLE
!UNPARSE: BLOCK
!UNPARSE: END BLOCK
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct
!PARSE-TREE: | OmpBeginDirective
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = task
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Replayable ->
!PARSE-TREE: | | Flags = None
!PARSE-TREE: | Block


subroutine f01(x)
implicit none
integer :: x
!$omp target_update to(x) replayable(.true.)
end

!UNPARSE: SUBROUTINE f01 (x)
!UNPARSE: IMPLICIT NONE
!UNPARSE: INTEGER x
!UNPARSE: !$OMP TARGET_UPDATE TO(x) REPLAYABLE(.true._4)
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target update
!PARSE-TREE: | OmpClauseList -> OmpClause -> To -> OmpToClause
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'
!PARSE-TREE: | OmpClause -> Replayable -> OmpReplayableClause -> Scalar -> Logical -> Constant -> Expr = '.true._4'
!PARSE-TREE: | | LiteralConstant -> LogicalLiteralConstant
!PARSE-TREE: | | | bool = 'true'
!PARSE-TREE: | Flags = None


subroutine f02
!$omp taskwait replayable(.false.)
end

!UNPARSE: SUBROUTINE f02
!UNPARSE: !$OMP TASKWAIT REPLAYABLE(.false._4)
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskwait
!PARSE-TREE: | OmpClauseList -> OmpClause -> Replayable -> OmpReplayableClause -> Scalar -> Logical -> Constant -> Expr = '.false._4'
!PARSE-TREE: | | LiteralConstant -> LogicalLiteralConstant
!PARSE-TREE: | | | bool = 'false'
!PARSE-TREE: | Flags = None
76 changes: 76 additions & 0 deletions flang/test/Parser/OpenMP/transparent-clause.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s

subroutine f00(x)
implicit none
integer :: x
!$omp target_data map(to: x) transparent
block
end block
end

!UNPARSE: SUBROUTINE f00 (x)
!UNPARSE: IMPLICIT NONE
!UNPARSE: INTEGER x
!UNPARSE: !$OMP TARGET_DATA MAP(TO: x) TRANSPARENT
!UNPARSE: BLOCK
!UNPARSE: END BLOCK
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct
!PARSE-TREE: | OmpBeginDirective
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = target data
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | | Modifier -> OmpMapType -> Value = To
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | | bool = 'true'
!PARSE-TREE: | | OmpClause -> Transparent ->
!PARSE-TREE: | | Flags = None
!PARSE-TREE: | Block


subroutine f01
!$omp task transparent(0)
!$omp end task
end

!UNPARSE: SUBROUTINE f01
!UNPARSE: !$OMP TASK TRANSPARENT(0_4)
!UNPARSE: !$OMP END TASK
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct
!PARSE-TREE: | OmpBeginDirective
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = task
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Transparent -> OmpTransparentClause -> Scalar -> Integer -> Expr = '0_4'
!PARSE-TREE: | | | LiteralConstant -> IntLiteralConstant = '0'
!PARSE-TREE: | | Flags = None
!PARSE-TREE: | Block
!PARSE-TREE: | OmpEndDirective
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = task
!PARSE-TREE: | | OmpClauseList ->
!PARSE-TREE: | | Flags = None


subroutine f02
implicit none
integer :: i
!$omp taskloop transparent(2)
do i = 1, 10
end do
end

!UNPARSE: SUBROUTINE f02
!UNPARSE: IMPLICIT NONE
!UNPARSE: INTEGER i
!UNPARSE: !$OMP TASKLOOP TRANSPARENT(2_4)
!UNPARSE: DO i=1_4,10_4
!UNPARSE: END DO
!UNPARSE: END SUBROUTINE

!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
!PARSE-TREE: | OmpBeginLoopDirective
!PARSE-TREE: | | OmpLoopDirective -> llvm::omp::Directive = taskloop
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Transparent -> OmpTransparentClause -> Scalar -> Integer -> Expr = '2_4'
!PARSE-TREE: | | | LiteralConstant -> IntLiteralConstant = '2'
!PARSE-TREE: | DoConstruct
22 changes: 22 additions & 0 deletions flang/test/Semantics/OpenMP/replayable-clause.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60

subroutine f00(x)
implicit none
logical :: x
!ERROR: Must be a constant value
!$omp task replayable(x)
!$omp end task
end

subroutine f01
!ERROR: Must have LOGICAL type, but is INTEGER(4)
!$omp task replayable(7)
!$omp end task
end

subroutine f02
!No diagnostic expected
!$omp task replayable
!$omp end task
end

19 changes: 19 additions & 0 deletions flang/test/Semantics/OpenMP/transparent-clause.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60

subroutine f00(x)
integer :: x(10)
!ERROR: Must be a scalar value, but is a rank-1 array
!$omp task transparent(x)
!$omp end task
end

subroutine f01
implicit none
integer :: i
!ERROR: Must have INTEGER type, but is CHARACTER(KIND=1,LEN=5_8)
!$omp taskloop transparent("hello")
do i = 1, 10
end do
!$omp end taskloop
end

15 changes: 14 additions & 1 deletion llvm/include/llvm/Frontend/OpenMP/ClauseT.h
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,12 @@ struct ReleaseT {
using EmptyTrait = std::true_type;
};

// [6.0:440-441] `replayable` clause
template <typename T, typename I, typename E> //
struct ReplayableT {
using IncompleteTrait = std::true_type;
};

// V5.2: [8.2.1] `requirement` clauses
template <typename T, typename I, typename E> //
struct ReverseOffloadT {
Expand Down Expand Up @@ -1153,6 +1159,12 @@ struct ToT {
std::tuple<OPT(Expectation), OPT(Mappers), OPT(Iterator), LocatorList> t;
};

// [6.0:440-441] `transparent` clause
template <typename T, typename I, typename E> //
struct TransparentT {
using IncompleteTrait = std::true_type;
};

// V5.2: [8.2.1] `requirement` clauses
template <typename T, typename I, typename E> //
struct UnifiedAddressT {
Expand Down Expand Up @@ -1279,7 +1291,8 @@ using EmptyClausesT = std::variant<
template <typename T, typename I, typename E>
using IncompleteClausesT =
std::variant<AdjustArgsT<T, I, E>, AppendArgsT<T, I, E>, MatchT<T, I, E>,
OtherwiseT<T, I, E>, WhenT<T, I, E>>;
OtherwiseT<T, I, E>, ReplayableT<T, I, E>,
TransparentT<T, I, E>, WhenT<T, I, E>>;

template <typename T, typename I, typename E>
using TupleClausesT =
Expand Down
Loading