// ordered-clause
// nesting check
- HasInvalidWorksharingNesting(beginDir.source,
- {llvm::omp::Directive::OMPD_do, llvm::omp::Directive::OMPD_sections,
- llvm::omp::Directive::OMPD_single,
- llvm::omp::Directive::OMPD_workshare,
- llvm::omp::Directive::OMPD_task,
- llvm::omp::Directive::OMPD_taskloop,
- llvm::omp::Directive::OMPD_critical,
- llvm::omp::Directive::OMPD_ordered,
- llvm::omp::Directive::OMPD_atomic,
- llvm::omp::Directive::OMPD_master});
+ HasInvalidWorksharingNesting(
+ beginDir.source, llvm::omp::nestedWorkshareErrSet);
}
SetLoopInfo(x);
PushContextAndClauseSets(beginDir.source, beginDir.v);
- // TODO: This check needs to be extended while implementing nesting of regions
- // checks.
- if (beginDir.v == llvm::omp::Directive::OMPD_single) {
- HasInvalidWorksharingNesting(
- beginDir.source, {llvm::omp::Directive::OMPD_do});
- }
if (CurrentDirectiveIsNested()) {
CheckIfDoOrderedClause(beginDir);
if (llvm::omp::teamSet.test(GetContextParent().directive)) {
case llvm::omp::OMPD_workshare:
case llvm::omp::OMPD_parallel_workshare:
CheckWorkshareBlockStmts(block, beginDir.source);
+ HasInvalidWorksharingNesting(
+ beginDir.source, llvm::omp::nestedWorkshareErrSet);
+ break;
+ case llvm::omp::Directive::OMPD_single:
+ // TODO: This check needs to be extended while implementing nesting of
+ // regions checks.
+ HasInvalidWorksharingNesting(
+ beginDir.source, llvm::omp::nestedWorkshareErrSet);
break;
default:
break;
for (const auto &block : sectionBlocks.v) {
CheckNoBranching(block, beginDir.v, beginDir.source);
}
+ HasInvalidWorksharingNesting(
+ beginDir.source, llvm::omp::nestedWorkshareErrSet);
}
void OmpStructureChecker::Leave(const parser::OpenMPSectionsConstruct &) {
Directive::OMPD_teams_distribute_parallel_do,
Directive::OMPD_teams_distribute_parallel_do_simd};
static OmpDirectiveSet doSet{Directive::OMPD_distribute_parallel_do,
- Directive::OMPD_distribute_parallel_do_simd, Directive::OMPD_parallel,
- Directive::OMPD_parallel_do, Directive::OMPD_parallel_do_simd,
- Directive::OMPD_do, Directive::OMPD_do_simd,
- Directive::OMPD_target_parallel_do, Directive::OMPD_target_parallel_do_simd,
+ Directive::OMPD_distribute_parallel_do_simd, Directive::OMPD_parallel_do,
+ Directive::OMPD_parallel_do_simd, Directive::OMPD_do,
+ Directive::OMPD_do_simd, Directive::OMPD_target_parallel_do,
+ Directive::OMPD_target_parallel_do_simd,
Directive::OMPD_target_teams_distribute_parallel_do,
Directive::OMPD_target_teams_distribute_parallel_do_simd,
Directive::OMPD_teams_distribute_parallel_do,
Directive::OMPD_target_parallel_do_simd,
Directive::OMPD_target_teams_distribute_parallel_do_simd,
Directive::OMPD_teams_distribute_parallel_do_simd};
+static OmpDirectiveSet workShareSet{
+ OmpDirectiveSet{Directive::OMPD_workshare,
+ Directive::OMPD_parallel_workshare, Directive::OMPD_parallel_sections,
+ Directive::OMPD_sections, Directive::OMPD_single} |
+ doSet};
static OmpDirectiveSet taskloopSet{
Directive::OMPD_taskloop, Directive::OMPD_taskloop_simd};
static OmpDirectiveSet targetSet{Directive::OMPD_target,
static OmpDirectiveSet nestedOrderedErrSet{Directive::OMPD_critical,
Directive::OMPD_ordered, Directive::OMPD_atomic, Directive::OMPD_task,
Directive::OMPD_taskloop};
+static OmpDirectiveSet nestedWorkshareErrSet{
+ OmpDirectiveSet{Directive::OMPD_task, Directive::OMPD_taskloop,
+ Directive::OMPD_critical, Directive::OMPD_ordered,
+ Directive::OMPD_atomic, Directive::OMPD_master} |
+ workShareSet};
static OmpClauseSet privateSet{
Clause::OMPC_private, Clause::OMPC_firstprivate, Clause::OMPC_lastprivate};
static OmpClauseSet privateReductionSet{
end do
!$omp end do
+ !$omp parallel do
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end parallel do
+
+ !$omp parallel do simd
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end parallel do simd
+
+ !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
+ !$omp distribute parallel do
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end distribute parallel do
+
+ !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
+ !$omp distribute parallel do simd
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end distribute parallel do simd
+
+ !$omp target parallel do
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end target parallel do
+
+ !$omp target parallel do simd
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end target parallel do simd
+
+ !$omp target teams distribute parallel do
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end target teams distribute parallel do
+
+ !$omp target teams distribute parallel do simd
+ do i=1,10
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
+ !$omp single
+ do j=1,10
+ print *,"hello"
+ end do
+ !$omp end single
+ end do
+ !$omp end target teams distribute parallel do simd
+
!$omp do
do i=1,10
!$omp task
end do
!$omp critical
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
!$omp single
aa = bb
!$omp end single
!$omp end parallel
!ERROR: OpenMP constructs enclosed in WORKSHARE construct may consist of ATOMIC, CRITICAL or PARALLEL constructs only
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
!$omp parallel workshare
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
!$omp single
ee = ff
!$omp end single
!$omp end single
!$omp end parallel
+ !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
!$omp parallel sections
!$omp section
aa = my_func()