forked from OSchip/llvm-project
[OPENMP 4.5] Parsing/sema for 'num_tasks' clause.
OpenMP 4.5 adds directives 'taskloop' and 'taskloop simd'. These directives support clause 'num_tasks'. Patch adds parsing/semantic analysis for this clause. llvm-svn: 255008
This commit is contained in:
parent
a520e9b30c
commit
382967a2e4
|
@ -2976,6 +2976,58 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/// \brief This represents 'num_tasks' clause in the '#pragma omp ...'
|
||||
/// directive.
|
||||
///
|
||||
/// \code
|
||||
/// #pragma omp taskloop num_tasks(4)
|
||||
/// \endcode
|
||||
/// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
|
||||
/// with single expression '4'.
|
||||
///
|
||||
class OMPNumTasksClause : public OMPClause {
|
||||
friend class OMPClauseReader;
|
||||
/// \brief Location of '('.
|
||||
SourceLocation LParenLoc;
|
||||
/// \brief Safe iteration space distance.
|
||||
Stmt *NumTasks;
|
||||
|
||||
/// \brief Set safelen.
|
||||
void setNumTasks(Expr *Size) { NumTasks = Size; }
|
||||
|
||||
public:
|
||||
/// \brief Build 'num_tasks' clause.
|
||||
///
|
||||
/// \param Size Expression associated with this clause.
|
||||
/// \param StartLoc Starting location of the clause.
|
||||
/// \param EndLoc Ending location of the clause.
|
||||
///
|
||||
OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc, SourceLocation EndLoc)
|
||||
: OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
|
||||
NumTasks(Size) {}
|
||||
|
||||
/// \brief Build an empty clause.
|
||||
///
|
||||
explicit OMPNumTasksClause()
|
||||
: OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
|
||||
LParenLoc(SourceLocation()), NumTasks(nullptr) {}
|
||||
|
||||
/// \brief Sets the location of '('.
|
||||
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
|
||||
/// \brief Returns the location of '('.
|
||||
SourceLocation getLParenLoc() const { return LParenLoc; }
|
||||
|
||||
/// \brief Return safe iteration space distance.
|
||||
Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); }
|
||||
|
||||
static bool classof(const OMPClause *T) {
|
||||
return T->getClauseKind() == OMPC_num_tasks;
|
||||
}
|
||||
|
||||
child_range children() { return child_range(&NumTasks, &NumTasks + 1); }
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H
|
||||
|
|
|
@ -2765,6 +2765,13 @@ bool RecursiveASTVisitor<Derived>::VisitOMPGrainsizeClause(
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::VisitOMPNumTasksClause(
|
||||
OMPNumTasksClause *C) {
|
||||
TRY_TO(TraverseStmt(C->getNumTasks()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: look at the following tricky-seeming exprs to see if we
|
||||
// need to recurse on anything. These are ones that have methods
|
||||
// returning decls or qualtypes or nestednamespecifier -- though I'm
|
||||
|
|
|
@ -7927,6 +7927,10 @@ def err_omp_firstprivate_and_lastprivate_in_distribute : Error<
|
|||
"lastprivate variable cannot be firstprivate in '#pragma omp distribute'">;
|
||||
def err_omp_firstprivate_distribute_in_teams_reduction : Error<
|
||||
"reduction variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'">;
|
||||
def err_omp_grainsize_num_tasks_mutually_exclusive : Error<
|
||||
"'%0' and '%1' clause are mutually exclusive and may not appear on the same directive">;
|
||||
def note_omp_previous_grainsize_num_tasks : Note<
|
||||
"'%0' clause is specified here">;
|
||||
} // end of OpenMP category
|
||||
|
||||
let CategoryName = "Related Result Type Issue" in {
|
||||
|
|
|
@ -167,6 +167,7 @@ OPENMP_CLAUSE(thread_limit, OMPThreadLimitClause)
|
|||
OPENMP_CLAUSE(priority, OMPPriorityClause)
|
||||
OPENMP_CLAUSE(grainsize, OMPGrainsizeClause)
|
||||
OPENMP_CLAUSE(nogroup, OMPNogroupClause)
|
||||
OPENMP_CLAUSE(num_tasks, OMPNumTasksClause)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'parallel'.
|
||||
OPENMP_PARALLEL_CLAUSE(if)
|
||||
|
@ -357,7 +358,6 @@ OPENMP_MAP_KIND(release)
|
|||
OPENMP_MAP_KIND(always)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'taskloop'.
|
||||
// TODO: add next clauses
|
||||
OPENMP_TASKLOOP_CLAUSE(if)
|
||||
OPENMP_TASKLOOP_CLAUSE(shared)
|
||||
OPENMP_TASKLOOP_CLAUSE(private)
|
||||
|
@ -371,9 +371,9 @@ OPENMP_TASKLOOP_CLAUSE(mergeable)
|
|||
OPENMP_TASKLOOP_CLAUSE(priority)
|
||||
OPENMP_TASKLOOP_CLAUSE(grainsize)
|
||||
OPENMP_TASKLOOP_CLAUSE(nogroup)
|
||||
OPENMP_TASKLOOP_CLAUSE(num_tasks)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'taskloop simd'.
|
||||
// TODO: add next clauses
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(if)
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(shared)
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(private)
|
||||
|
@ -391,6 +391,7 @@ OPENMP_TASKLOOP_SIMD_CLAUSE(safelen)
|
|||
OPENMP_TASKLOOP_SIMD_CLAUSE(simdlen)
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(grainsize)
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(nogroup)
|
||||
OPENMP_TASKLOOP_SIMD_CLAUSE(num_tasks)
|
||||
|
||||
// Clauses allowed for OpenMP directive 'distribute'
|
||||
OPENMP_DISTRIBUTE_CLAUSE(private)
|
||||
|
|
|
@ -8012,6 +8012,10 @@ public:
|
|||
OMPClause *ActOnOpenMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc);
|
||||
/// \brief Called on well-formed 'num_tasks' clause.
|
||||
OMPClause *ActOnOpenMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc);
|
||||
|
||||
OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind,
|
||||
unsigned Argument,
|
||||
|
|
|
@ -737,6 +737,12 @@ void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
|
|||
OS << ")";
|
||||
}
|
||||
|
||||
void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
|
||||
OS << "num_tasks(";
|
||||
Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
|
||||
OS << ")";
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
|
||||
for (typename T::varlist_iterator I = Node->varlist_begin(),
|
||||
|
|
|
@ -468,6 +468,9 @@ void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
|
|||
void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
|
||||
Profiler->VisitStmt(C->getGrainsize());
|
||||
}
|
||||
void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
|
||||
Profiler->VisitStmt(C->getNumTasks());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -140,6 +140,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind,
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
@ -243,6 +244,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
break;
|
||||
}
|
||||
llvm_unreachable("Invalid OpenMP simple clause kind");
|
||||
|
|
|
@ -2488,6 +2488,7 @@ static void EmitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
llvm_unreachable("Clause is not allowed in 'omp atomic'.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind,
|
|||
/// update-clause | capture-clause | seq_cst-clause | device-clause |
|
||||
/// simdlen-clause | threads-clause | simd-clause | num_teams-clause |
|
||||
/// thread_limit-clause | priority-clause | grainsize-clause |
|
||||
/// nogroup-clause
|
||||
/// nogroup-clause | num_tasks-clause
|
||||
///
|
||||
OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
||||
OpenMPClauseKind CKind, bool FirstClause) {
|
||||
|
@ -429,6 +429,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
case OMPC_thread_limit:
|
||||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_num_tasks:
|
||||
// OpenMP [2.5, Restrictions]
|
||||
// At most one num_threads clause can appear on the directive.
|
||||
// OpenMP [2.8.1, simd construct, Restrictions]
|
||||
|
@ -447,6 +448,8 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
// At most one priority clause can appear on the directive.
|
||||
// OpenMP [2.9.2, taskloop Construct, Restrictions]
|
||||
// At most one grainsize clause can appear on the directive.
|
||||
// OpenMP [2.9.2, taskloop Construct, Restrictions]
|
||||
// At most one num_tasks clause can appear on the directive.
|
||||
if (!FirstClause) {
|
||||
Diag(Tok, diag::err_omp_more_one_clause)
|
||||
<< getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
|
||||
|
@ -538,7 +541,7 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
|
||||
/// \brief Parsing of OpenMP clauses with single expressions like 'final',
|
||||
/// 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams',
|
||||
/// 'thread_limit', 'simdlen', 'priority' or 'grainsize'.
|
||||
/// 'thread_limit', 'simdlen', 'priority', 'grainsize' or 'num_tasks'.
|
||||
///
|
||||
/// final-clause:
|
||||
/// 'final' '(' expression ')'
|
||||
|
@ -561,6 +564,9 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
|
|||
/// grainsize-clause:
|
||||
/// 'grainsize' '(' expression ')'
|
||||
///
|
||||
/// num_tasks-clause:
|
||||
/// 'num_tasks' '(' expression ')'
|
||||
///
|
||||
OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind) {
|
||||
SourceLocation Loc = ConsumeToken();
|
||||
|
||||
|
|
|
@ -5367,6 +5367,30 @@ StmtResult Sema::ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses,
|
|||
CancelRegion);
|
||||
}
|
||||
|
||||
static bool checkGrainsizeNumTasksClauses(Sema &S,
|
||||
ArrayRef<OMPClause *> Clauses) {
|
||||
OMPClause *PrevClause = nullptr;
|
||||
bool ErrorFound = false;
|
||||
for (auto *C : Clauses) {
|
||||
if (C->getClauseKind() == OMPC_grainsize ||
|
||||
C->getClauseKind() == OMPC_num_tasks) {
|
||||
if (!PrevClause)
|
||||
PrevClause = C;
|
||||
else if (PrevClause->getClauseKind() != C->getClauseKind()) {
|
||||
S.Diag(C->getLocStart(),
|
||||
diag::err_omp_grainsize_num_tasks_mutually_exclusive)
|
||||
<< getOpenMPClauseName(C->getClauseKind())
|
||||
<< getOpenMPClauseName(PrevClause->getClauseKind());
|
||||
S.Diag(PrevClause->getLocStart(),
|
||||
diag::note_omp_previous_grainsize_num_tasks)
|
||||
<< getOpenMPClauseName(PrevClause->getClauseKind());
|
||||
ErrorFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ErrorFound;
|
||||
}
|
||||
|
||||
StmtResult Sema::ActOnOpenMPTaskLoopDirective(
|
||||
ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
|
||||
SourceLocation EndLoc,
|
||||
|
@ -5388,6 +5412,12 @@ StmtResult Sema::ActOnOpenMPTaskLoopDirective(
|
|||
assert((CurContext->isDependentContext() || B.builtAll()) &&
|
||||
"omp for loop exprs were not built");
|
||||
|
||||
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
|
||||
// The grainsize clause and num_tasks clause are mutually exclusive and may
|
||||
// not appear on the same taskloop directive.
|
||||
if (checkGrainsizeNumTasksClauses(*this, Clauses))
|
||||
return StmtError();
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
return OMPTaskLoopDirective::Create(Context, StartLoc, EndLoc,
|
||||
NestedLoopCount, Clauses, AStmt, B);
|
||||
|
@ -5414,6 +5444,12 @@ StmtResult Sema::ActOnOpenMPTaskLoopSimdDirective(
|
|||
assert((CurContext->isDependentContext() || B.builtAll()) &&
|
||||
"omp for loop exprs were not built");
|
||||
|
||||
// OpenMP, [2.9.2 taskloop Construct, Restrictions]
|
||||
// The grainsize clause and num_tasks clause are mutually exclusive and may
|
||||
// not appear on the same taskloop directive.
|
||||
if (checkGrainsizeNumTasksClauses(*this, Clauses))
|
||||
return StmtError();
|
||||
|
||||
getCurFunction()->setHasBranchProtectedScope();
|
||||
return OMPTaskLoopSimdDirective::Create(Context, StartLoc, EndLoc,
|
||||
NestedLoopCount, Clauses, AStmt, B);
|
||||
|
@ -5484,6 +5520,9 @@ OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
|
|||
case OMPC_grainsize:
|
||||
Res = ActOnOpenMPGrainsizeClause(Expr, StartLoc, LParenLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_num_tasks:
|
||||
Res = ActOnOpenMPNumTasksClause(Expr, StartLoc, LParenLoc, EndLoc);
|
||||
break;
|
||||
case OMPC_if:
|
||||
case OMPC_default:
|
||||
case OMPC_proc_bind:
|
||||
|
@ -5790,6 +5829,7 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
case OMPC_unknown:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
|
@ -5925,6 +5965,7 @@ OMPClause *Sema::ActOnOpenMPSingleExprWithArgClause(
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
case OMPC_unknown:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
|
@ -6064,6 +6105,7 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
|
|||
case OMPC_thread_limit:
|
||||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_num_tasks:
|
||||
case OMPC_unknown:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
|
@ -6203,6 +6245,7 @@ OMPClause *Sema::ActOnOpenMPVarListClause(
|
|||
case OMPC_priority:
|
||||
case OMPC_grainsize:
|
||||
case OMPC_nogroup:
|
||||
case OMPC_num_tasks:
|
||||
case OMPC_unknown:
|
||||
llvm_unreachable("Clause is not allowed.");
|
||||
}
|
||||
|
@ -8184,3 +8227,20 @@ OMPClause *Sema::ActOnOpenMPGrainsizeClause(Expr *Grainsize,
|
|||
|
||||
return new (Context) OMPGrainsizeClause(ValExpr, StartLoc, LParenLoc, EndLoc);
|
||||
}
|
||||
|
||||
OMPClause *Sema::ActOnOpenMPNumTasksClause(Expr *NumTasks,
|
||||
SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc) {
|
||||
Expr *ValExpr = NumTasks;
|
||||
|
||||
// OpenMP [2.9.2, taskloop Constrcut]
|
||||
// The parameter of the num_tasks clause must be a positive integer
|
||||
// expression.
|
||||
if (!IsNonNegativeIntegerValue(ValExpr, *this, OMPC_num_tasks,
|
||||
/*StrictlyPositive=*/true))
|
||||
return nullptr;
|
||||
|
||||
return new (Context) OMPNumTasksClause(ValExpr, StartLoc, LParenLoc, EndLoc);
|
||||
}
|
||||
|
||||
|
|
|
@ -1711,6 +1711,17 @@ public:
|
|||
EndLoc);
|
||||
}
|
||||
|
||||
/// \brief Build a new OpenMP 'num_tasks' clause.
|
||||
///
|
||||
/// By default, performs semantic analysis to build the new statement.
|
||||
/// Subclasses may override this routine to provide different behavior.
|
||||
OMPClause *RebuildOMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc,
|
||||
SourceLocation LParenLoc,
|
||||
SourceLocation EndLoc) {
|
||||
return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc,
|
||||
EndLoc);
|
||||
}
|
||||
|
||||
/// \brief Rebuild the operand to an Objective-C \@synchronized statement.
|
||||
///
|
||||
/// By default, performs semantic analysis to build the new statement.
|
||||
|
@ -7822,6 +7833,16 @@ TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) {
|
|||
E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
OMPClause *
|
||||
TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *C) {
|
||||
ExprResult E = getDerived().TransformExpr(C->getNumTasks());
|
||||
if (E.isInvalid())
|
||||
return nullptr;
|
||||
return getDerived().RebuildOMPNumTasksClause(
|
||||
E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Expression transformation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -1865,6 +1865,9 @@ OMPClause *OMPClauseReader::readClause() {
|
|||
case OMPC_grainsize:
|
||||
C = new (Context) OMPGrainsizeClause();
|
||||
break;
|
||||
case OMPC_num_tasks:
|
||||
C = new (Context) OMPNumTasksClause();
|
||||
break;
|
||||
}
|
||||
Visit(C);
|
||||
C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
|
||||
|
@ -2211,6 +2214,11 @@ void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
|
|||
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
|
||||
}
|
||||
|
||||
void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
|
||||
C->setNumTasks(Reader->Reader.ReadSubExpr());
|
||||
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// OpenMP Directives.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -2023,6 +2023,11 @@ void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
|
|||
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
|
||||
}
|
||||
|
||||
void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
|
||||
Writer->Writer.AddStmt(C->getNumTasks());
|
||||
Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// OpenMP Directives.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -20,7 +20,7 @@ T tmain(T argc) {
|
|||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
// CHECK-NEXT: a = 2;
|
||||
#pragma omp parallel
|
||||
#pragma omp taskloop private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup
|
||||
#pragma omp taskloop private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) nogroup num_tasks(N)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
|
@ -33,7 +33,7 @@ T tmain(T argc) {
|
|||
for (int j = 0; j < 2; ++j)
|
||||
foo();
|
||||
// CHECK-NEXT: #pragma omp parallel
|
||||
// CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) nogroup
|
||||
// CHECK-NEXT: #pragma omp taskloop private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) nogroup num_tasks(N)
|
||||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
// CHECK-NEXT: for (int j = 0; j < 2; ++j)
|
||||
// CHECK-NEXT: for (int j = 0; j < 2; ++j)
|
||||
|
@ -52,8 +52,8 @@ int main(int argc, char **argv) {
|
|||
int b = argc, c, d, e, f, g;
|
||||
static int a;
|
||||
// CHECK: static int a;
|
||||
#pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) nogroup
|
||||
// CHECK-NEXT: #pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) nogroup
|
||||
#pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) nogroup num_tasks(argc)
|
||||
// CHECK-NEXT: #pragma omp taskloop if(taskloop: a) default(none) shared(a) final(b) priority(5) nogroup num_tasks(argc)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
a = 2;
|
||||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
|
|
|
@ -42,6 +42,9 @@ int tmain(T argc, S **argv) {
|
|||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
|
@ -86,6 +89,9 @@ int main(int argc, char **argv) {
|
|||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
|
||||
|
||||
void foo() {
|
||||
}
|
||||
|
||||
bool foobool(int argc) {
|
||||
return argc;
|
||||
}
|
||||
|
||||
struct S1; // expected-note {{declared here}}
|
||||
|
||||
template <class T, class S> // expected-note {{declared here}}
|
||||
int tmain(T argc, S **argv) {
|
||||
#pragma omp taskloop num_tasks // expected-error {{expected '(' after 'num_tasks'}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks () // expected-error {{expected expression}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc > 0 ? argv[1][0] : argv[2][argc])
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (foobool(argc)), num_tasks (true) // expected-error {{directive '#pragma omp taskloop' cannot contain more than one 'num_tasks' clause}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (S) // expected-error {{'S' does not refer to a value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(0) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(-1) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(argc) grainsize(argc) // expected-error {{'grainsize' and 'num_tasks' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'num_tasks' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp taskloop num_tasks // expected-error {{expected '(' after 'num_tasks'}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks () // expected-error {{expected expression}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc > 0 ? argv[1][0] : argv[2][argc])
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (foobool(argc)), num_tasks (true) // expected-error {{directive '#pragma omp taskloop' cannot contain more than one 'num_tasks' clause}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (S1) // expected-error {{'S1' does not refer to a value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(0) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(-1) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop num_tasks(argc) grainsize(argc) // expected-error {{'grainsize' and 'num_tasks' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'num_tasks' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
return tmain(argc, argv);
|
||||
}
|
|
@ -21,7 +21,7 @@ T tmain(T argc) {
|
|||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
// CHECK-NEXT: a = 2;
|
||||
#pragma omp parallel
|
||||
#pragma omp taskloop simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) simdlen(N) nogroup
|
||||
#pragma omp taskloop simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int j = 0; j < 2; ++j)
|
||||
|
@ -34,7 +34,7 @@ T tmain(T argc) {
|
|||
for (int j = 0; j < 2; ++j)
|
||||
foo();
|
||||
// CHECK-NEXT: #pragma omp parallel
|
||||
// CHECK-NEXT: #pragma omp taskloop simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) simdlen(N) nogroup
|
||||
// CHECK-NEXT: #pragma omp taskloop simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
|
||||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
// CHECK-NEXT: for (int j = 0; j < 2; ++j)
|
||||
// CHECK-NEXT: for (int j = 0; j < 2; ++j)
|
||||
|
@ -53,8 +53,8 @@ int main(int argc, char **argv) {
|
|||
int b = argc, c, d, e, f, g;
|
||||
static int a;
|
||||
// CHECK: static int a;
|
||||
#pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b), aligned(argv) nogroup
|
||||
// CHECK-NEXT: #pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b) aligned(argv) nogroup
|
||||
#pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b), aligned(argv) nogroup num_tasks(argc)
|
||||
// CHECK-NEXT: #pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b) aligned(argv) nogroup num_tasks(argc)
|
||||
for (int i = 0; i < 2; ++i)
|
||||
a = 2;
|
||||
// CHECK-NEXT: for (int i = 0; i < 2; ++i)
|
||||
|
|
|
@ -42,6 +42,9 @@ int tmain(T argc, S **argv) {
|
|||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
|
@ -86,6 +89,9 @@ int main(int argc, char **argv) {
|
|||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
|
||||
|
||||
void foo() {
|
||||
}
|
||||
|
||||
bool foobool(int argc) {
|
||||
return argc;
|
||||
}
|
||||
|
||||
struct S1; // expected-note {{declared here}}
|
||||
|
||||
template <class T, class S> // expected-note {{declared here}}
|
||||
int tmain(T argc, S **argv) {
|
||||
#pragma omp taskloop simd num_tasks // expected-error {{expected '(' after 'num_tasks'}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks () // expected-error {{expected expression}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc > 0 ? argv[1][0] : argv[2][argc])
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (foobool(argc)), num_tasks (true) // expected-error {{directive '#pragma omp taskloop simd' cannot contain more than one 'num_tasks' clause}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (S) // expected-error {{'S' does not refer to a value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(0) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(-1) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(argc) grainsize(argc) // expected-error {{'grainsize' and 'num_tasks' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'num_tasks' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#pragma omp taskloop simd num_tasks // expected-error {{expected '(' after 'num_tasks'}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks () // expected-error {{expected expression}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc > 0 ? argv[1][0] : argv[2][argc])
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (foobool(argc)), num_tasks (true) // expected-error {{directive '#pragma omp taskloop simd' cannot contain more than one 'num_tasks' clause}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (S1) // expected-error {{'S1' does not refer to a value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(0) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(-1) // expected-error {{argument to 'num_tasks' clause must be a strictly positive integer value}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
#pragma omp taskloop simd num_tasks(argc) grainsize(argc) // expected-error {{'grainsize' and 'num_tasks' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'num_tasks' clause is specified here}}
|
||||
for (int i = 0; i < 10; ++i)
|
||||
foo();
|
||||
|
||||
return tmain(argc, argv);
|
||||
}
|
|
@ -2096,6 +2096,10 @@ void OMPClauseEnqueue::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
|
|||
Visitor->AddStmt(C->getGrainsize());
|
||||
}
|
||||
|
||||
void OMPClauseEnqueue::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
|
||||
Visitor->AddStmt(C->getNumTasks());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
|
||||
for (const auto *I : Node->varlists()) {
|
||||
|
|
Loading…
Reference in New Issue