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 semantic checks for OpenMP copyin clause.
Add the semantic checks for the OpenMP 4.5 - 2.15.4.1 copyin clause. Resolve OpenMPThreadprivate directive since the list of items specified in copyin clause should be threadprivate. Test cases : omp-copyin01.f90, omp-copyin02.f90, omp-copyin03.f90, omp-copyin04.f90, omp-copyin05.f90 Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D89385
- Loading branch information
1 parent
0314dff
commit a4a4c50
Showing
8 changed files
with
197 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp | ||
! OpenMP Version 4.5 | ||
! 2.15.4.1 copyin Clause | ||
! A list item that appears in a copyin clause must be threadprivate | ||
|
||
program omp_copyin | ||
|
||
integer :: i | ||
integer, save :: k | ||
integer :: a(10), b(10) | ||
common /cmn/ j | ||
|
||
k = 10 | ||
|
||
!ERROR: Non-THREADPRIVATE object 'k' in COPYIN clause | ||
!$omp parallel do copyin(k) | ||
do i = 1, 10 | ||
a(i) = k + i | ||
j = j + a(i) | ||
end do | ||
!$omp end parallel do | ||
|
||
print *, a | ||
|
||
!ERROR: Non-THREADPRIVATE object 'j' in COPYIN clause | ||
!$omp parallel do copyin(/cmn/) | ||
do i = 1, 10 | ||
b(i) = a(i) + j | ||
end do | ||
!$omp end parallel do | ||
|
||
print *, b | ||
|
||
end program omp_copyin |
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,23 @@ | ||
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp | ||
! OpenMP Version 4.5 | ||
! 2.15.4.1 copyin Clause | ||
! A common block name that appears in a copyin clause must be declared to be | ||
! a common block in the same scoping unit in which the copyin clause appears. | ||
|
||
subroutine copyin() | ||
integer :: a = 10 | ||
common /cmn/ a | ||
|
||
!$omp threadprivate(/cmn/) | ||
call copyin_clause() | ||
|
||
contains | ||
|
||
subroutine copyin_clause() | ||
!ERROR: COMMON block must be declared in the same scoping unit in which the OpenMP directive or clause appears | ||
!$omp parallel copyin(/cmn/) | ||
print *, a | ||
!$omp end parallel | ||
end subroutine copyin_clause | ||
|
||
end subroutine copyin |
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,33 @@ | ||
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp | ||
! OpenMP Version 4.5 | ||
! 2.15.4.1 copyin Clause | ||
! A list item that appears in a copyin clause must be threadprivate. | ||
! Named variables appearing in a threadprivate common block may be specified | ||
! It is not necessary to specify the whole common block. | ||
|
||
program omp_copyin | ||
|
||
integer :: a(10), b(10) | ||
common /cmn/ j, k | ||
|
||
!$omp threadprivate(/cmn/) | ||
|
||
j = 20 | ||
k = 10 | ||
|
||
!$omp parallel copyin(/cmn/) | ||
a(:5) = k | ||
b(:5) = j | ||
!$omp end parallel | ||
|
||
j = j + k | ||
k = k * j | ||
|
||
!$omp parallel copyin(j, k) | ||
a(6:) = j | ||
b(6:) = k | ||
!$omp end parallel | ||
|
||
print *, a, b | ||
|
||
end program omp_copyin |
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,26 @@ | ||
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp | ||
! OpenMP Version 4.5 | ||
! 2.15.4.1 copyin Clause | ||
! A list item that appears in a copyin clause must be threadprivate | ||
|
||
program omp_copyin | ||
|
||
integer :: i | ||
integer, save :: j, k | ||
integer :: a(10), b(10) | ||
|
||
!$omp threadprivate(j, k) | ||
|
||
j = 20 | ||
k = 10 | ||
|
||
!$omp parallel do copyin(j, k) | ||
do i = 1, 10 | ||
a(i) = k + i | ||
b(i) = j + i | ||
end do | ||
!$omp end parallel do | ||
|
||
print *, a, b | ||
|
||
end program omp_copyin |
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,23 @@ | ||
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp | ||
! OpenMP Version 4.5 | ||
! 2.15.4.1 copyin Clause | ||
! A common block name that appears in a copyin clause must be declared to be | ||
! a common block in the same scoping unit in which the copyin clause appears. | ||
|
||
subroutine copyin() | ||
call copyin_clause() | ||
|
||
contains | ||
|
||
subroutine copyin_clause() | ||
integer :: a = 20 | ||
common /cmn/ a | ||
|
||
!$omp threadprivate(/cmn/) | ||
|
||
!$omp parallel copyin(/cmn/) | ||
print *, a | ||
!$omp end parallel | ||
end subroutine copyin_clause | ||
|
||
end subroutine copyin |