Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][OpenMP] Add parser support for order clause
Added parser support for OpenMP 5.0 & 5.1 feature ORDER([order-modifier :]concurrent) clause for all applicable and supported OpenMP directives. Reviewed By: kiranchandramohan, abidmalikwaterloo Differential Revision: https://reviews.llvm.org/D142524
- Loading branch information
1 parent
c9fd858
commit a7d352c
Showing
8 changed files
with
384 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
! REQUIRES: plugins, examples, shell | ||
|
||
! RUN: %flang_fc1 -load %llvmshlibdir/flangOmpReport.so -plugin flang-omp-report -fopenmp %s -o - | FileCheck %s | ||
|
||
! Check for ORDER([order-modifier :]concurrent) clause on OpenMP constructs | ||
|
||
subroutine test_order() | ||
integer :: i, j = 1 | ||
!$omp do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end do | ||
end subroutine | ||
|
||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 9 | ||
!CHECK: construct: do | ||
!CHECK: clauses: | ||
!CHECK: - clause: order | ||
!CHECK: details: concurrent | ||
|
||
subroutine test_order_reproducible() | ||
integer :: i, j = 1 | ||
!$omp simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end simd | ||
end subroutine | ||
|
||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 25 | ||
!CHECK: construct: simd | ||
!CHECK: clauses: | ||
!CHECK: - clause: order | ||
!CHECK: details: 'reproducible:concurrent' | ||
|
||
subroutine test_order_unconstrained() | ||
integer :: i, j = 1 | ||
!$omp target teams distribute parallel do simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target teams distribute parallel do simd | ||
end subroutine | ||
|
||
!CHECK: - file: {{.*}} | ||
!CHECK: line: 41 | ||
!CHECK: construct: target teams distribute parallel do simd | ||
!CHECK: clauses: | ||
!CHECK: - clause: order | ||
!CHECK: details: 'unconstrained:concurrent' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s | ||
! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s | ||
|
||
! Check for ORDER([order-modifier :]concurrent) clause on OpenMP constructs | ||
|
||
subroutine test_do_order() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp do order(concurrent) | ||
!$omp do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end do | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = do | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_simd_order_reproducible() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp simd order(reproducible:concurrent) | ||
!$omp simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Reproducible | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_do_simd_order_unconstrained() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp do simd order(unconstrained:concurrent) | ||
!$omp do simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end do simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = do simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Unconstrained | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_parallel_do_order() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp parallel do order(concurrent) | ||
!$omp parallel do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end parallel do | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = parallel do | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_parallel_do_simd_order_reproducible() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp parallel do simd order(reproducible:concurrent) | ||
!$omp parallel do simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end parallel do simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = parallel do simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Reproducible | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_simd_order_unconstrained() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target simd order(unconstrained:concurrent) | ||
!$omp target simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Unconstrained | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_parallel_do_order() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target parallel do order(concurrent) | ||
!$omp target parallel do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target parallel do | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target parallel do | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_parallel_do_simd_order_reproducible() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target parallel do simd order(reproducible:concurrent) | ||
!$omp target parallel do simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target parallel do simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target parallel do simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Reproducible | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_teams_distribute_simd_order_unconstrained() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp teams distribute simd order(unconstrained:concurrent) | ||
!$omp teams distribute simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end teams distribute simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = teams distribute simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Unconstrained | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_teams_distribute_parallel_do_order() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp teams distribute parallel do order(concurrent) | ||
!$omp teams distribute parallel do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end teams distribute parallel do | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = teams distribute parallel do | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_teams_distribute_parallel_do_simd_order_reproducible() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp teams distribute parallel do simd order(reproducible:concurrent) | ||
!$omp teams distribute parallel do simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end teams distribute parallel do simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = teams distribute parallel do simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Reproducible | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_teams_distribute_simd_order_unconstrained() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target teams distribute simd order(unconstrained:concurrent) | ||
!$omp target teams distribute simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target teams distribute simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target teams distribute simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Unconstrained | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_teams_distribute_parallel_do_order() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target teams distribute parallel do order(concurrent) | ||
!$omp target teams distribute parallel do order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target teams distribute parallel do | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target teams distribute parallel do | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_target_teams_distribute_parallel_do_simd_order_reproducible() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp target teams distribute parallel do simd order(reproducible:concurrent) | ||
!$omp target teams distribute parallel do simd order(reproducible:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end target teams distribute parallel do simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = target teams distribute parallel do simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Reproducible | ||
!PARSE-TREE-NEXT: Type = Concurrent | ||
|
||
subroutine test_taskloop_simd_order_unconstrained() | ||
integer :: i, j = 1 | ||
!CHECK: !$omp taskloop simd order(unconstrained:concurrent) | ||
!$omp taskloop simd order(unconstrained:concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
!$omp end taskloop simd | ||
end subroutine | ||
|
||
!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct | ||
!PARSE-TREE-NEXT: OmpBeginLoopDirective | ||
!PARSE-TREE-NEXT: OmpLoopDirective -> llvm::omp::Directive = taskloop simd | ||
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Order -> OmpOrderClause | ||
!PARSE-TREE-NEXT: Kind = Unconstrained | ||
!PARSE-TREE-NEXT: Type = Concurrent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp | ||
|
||
subroutine omp_order() | ||
integer :: i, j = 1 | ||
!ERROR: At most one ORDER clause can appear on the SIMD directive | ||
!$omp simd order(concurrent) order(concurrent) | ||
do i=1,10 | ||
j = j + 1 | ||
end do | ||
end subroutine omp_order |
Oops, something went wrong.