From 117352af511705b4acc5e92e48e51e7bf9beb5b6 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Mon, 14 Oct 2019 17:17:41 +0000 Subject: [OPENMP50]Add support for 'parallel master taskloop' construct. Added parsing/sema/codegen support for 'parallel master taskloop' constructs. Some of the clauses, like 'grainsize', 'num_tasks', 'final' and 'priority' are not supported in full, only constant expressions can be used currently in these clauses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374791 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 5 ++- include/clang/AST/RecursiveASTVisitor.h | 3 ++ include/clang/AST/StmtOpenMP.h | 71 +++++++++++++++++++++++++++++++ include/clang/Basic/OpenMPKinds.def | 26 +++++++++++ include/clang/Basic/StmtNodes.td | 1 + include/clang/Sema/Sema.h | 5 +++ include/clang/Serialization/ASTBitCodes.h | 1 + 7 files changed, 111 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 5cbcc3b7f5..4917ba5fb5 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -2559,8 +2559,11 @@ enum CXCursorKind { */ CXCursor_OMPMasterTaskLoopDirective = 281, + /** OpenMP parallel master taskloop directive. + */ + CXCursor_OMPParallelMasterTaskLoopDirective = 282, - CXCursor_LastStmt = CXCursor_OMPMasterTaskLoopDirective, + CXCursor_LastStmt = CXCursor_OMPParallelMasterTaskLoopDirective, /** * Cursor that represents the translation unit itself. diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 20b298093c..cfeaec46c7 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -2791,6 +2791,9 @@ DEF_TRAVERSE_STMT(OMPTaskLoopSimdDirective, DEF_TRAVERSE_STMT(OMPMasterTaskLoopDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPParallelMasterTaskLoopDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPDistributeDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index 90eb541a9c..d8a550a703 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -1165,6 +1165,7 @@ public: T->getStmtClass() == OMPTaskLoopDirectiveClass || T->getStmtClass() == OMPTaskLoopSimdDirectiveClass || T->getStmtClass() == OMPMasterTaskLoopDirectiveClass || + T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass || T->getStmtClass() == OMPDistributeDirectiveClass || T->getStmtClass() == OMPTargetParallelForDirectiveClass || T->getStmtClass() == OMPDistributeParallelForDirectiveClass || @@ -3188,6 +3189,76 @@ public: } }; +/// This represents '#pragma omp parallel master taskloop' directive. +/// +/// \code +/// #pragma omp parallel master taskloop private(a,b) grainsize(val) +/// num_tasks(num) +/// \endcode +/// In this example directive '#pragma omp parallel master taskloop' has clauses +/// 'private' with the variables 'a' and 'b', 'grainsize' with expression 'val' +/// and 'num_tasks' with expression 'num'. +/// +class OMPParallelMasterTaskLoopDirective : public OMPLoopDirective { + friend class ASTStmtReader; + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPParallelMasterTaskLoopDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass, + OMPD_parallel_master_taskloop, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPParallelMasterTaskLoopDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPParallelMasterTaskLoopDirectiveClass, + OMPD_parallel_master_taskloop, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPParallelMasterTaskLoopDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place + /// for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPParallelMasterTaskLoopDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass; + } +}; + /// This represents '#pragma omp distribute' directive. /// /// \code diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index 6f9067d698..9c592251c6 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -95,6 +95,9 @@ #ifndef OPENMP_MASTER_TASKLOOP_CLAUSE # define OPENMP_MASTER_TASKLOOP_CLAUSE(Name) #endif +#ifndef OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE +# define OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(Name) +#endif #ifndef OPENMP_CRITICAL_CLAUSE # define OPENMP_CRITICAL_CLAUSE(Name) #endif @@ -262,6 +265,7 @@ OPENMP_DIRECTIVE_EXT(target_teams_distribute_simd, "target teams distribute simd OPENMP_DIRECTIVE(allocate) OPENMP_DIRECTIVE_EXT(declare_variant, "declare variant") OPENMP_DIRECTIVE_EXT(master_taskloop, "master taskloop") +OPENMP_DIRECTIVE_EXT(parallel_master_taskloop, "parallel master taskloop") // OpenMP clauses. OPENMP_CLAUSE(allocator, OMPAllocatorClause) @@ -689,6 +693,27 @@ OPENMP_MASTER_TASKLOOP_CLAUSE(reduction) OPENMP_MASTER_TASKLOOP_CLAUSE(in_reduction) OPENMP_MASTER_TASKLOOP_CLAUSE(allocate) +// Clauses allowed for OpenMP directive 'parallel master taskloop'. +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(if) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(shared) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(private) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(firstprivate) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(lastprivate) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(default) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(collapse) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(final) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(untied) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(mergeable) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(priority) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(grainsize) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(nogroup) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(num_tasks) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(reduction) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(allocate) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(num_threads) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(proc_bind) +OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE(copyin) + // Clauses allowed for OpenMP directive 'critical'. OPENMP_CRITICAL_CLAUSE(hint) @@ -1001,6 +1026,7 @@ OPENMP_MATCH_KIND(implementation) #undef OPENMP_ALLOCATE_CLAUSE #undef OPENMP_DECLARE_MAPPER_CLAUSE #undef OPENMP_TASKGROUP_CLAUSE +#undef OPENMP_PARALLEL_MASTER_TASKLOOP_CLAUSE #undef OPENMP_MASTER_TASKLOOP_CLAUSE #undef OPENMP_TASKLOOP_SIMD_CLAUSE #undef OPENMP_TASKLOOP_CLAUSE diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td index eb5af6f415..1cef89f371 100644 --- a/include/clang/Basic/StmtNodes.td +++ b/include/clang/Basic/StmtNodes.td @@ -243,6 +243,7 @@ def OMPCancelDirective : DStmt; def OMPTaskLoopDirective : DStmt; def OMPTaskLoopSimdDirective : DStmt; def OMPMasterTaskLoopDirective : DStmt; +def OMPParallelMasterTaskLoopDirective : DStmt; def OMPDistributeDirective : DStmt; def OMPDistributeParallelForDirective : DStmt; def OMPDistributeParallelForSimdDirective : DStmt; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 212098e02b..b8b59fdf93 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -9474,6 +9474,11 @@ public: StmtResult ActOnOpenMPMasterTaskLoopDirective( ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); + /// Called on well-formed '\#pragma omp parallel master taskloop' after + /// parsing of the associated statement. + StmtResult ActOnOpenMPParallelMasterTaskLoopDirective( + ArrayRef Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); /// Called on well-formed '\#pragma omp distribute' after parsing /// of the associated statement. StmtResult diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 0a535f9f0e..94721f9fd3 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -1962,6 +1962,7 @@ namespace serialization { STMT_OMP_TASKLOOP_DIRECTIVE, STMT_OMP_TASKLOOP_SIMD_DIRECTIVE, STMT_OMP_MASTER_TASKLOOP_DIRECTIVE, + STMT_OMP_PARALLEL_MASTER_TASKLOOP_DIRECTIVE, STMT_OMP_DISTRIBUTE_DIRECTIVE, STMT_OMP_TARGET_UPDATE_DIRECTIVE, STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE, -- cgit v1.2.1