Skip to content

Commit 956a84d

Browse files
praveen-g-cttDavidTruby
authored andcommitted
[flang] [OpenMP 4.5] Adding lit test cases for OpenMP Constructs.
1. Section 2.5 : Parallel Construct 2. Section 2.7.1 : Loop Construct 3. Section 2.7.2 : Sections Construct 4. Section 2.7.3 : Single Construct 5. Section 2.7.4 : Workshare Construct 6. Section 2.8.1 : Simd Construct 7. Section 2.8.3 : Loop Simd Construct 8. Section 2.9.1 : Task Construct 9. Section 2.9.2 : Taskloop Construct 10. Section 2.9.3 : Taskloop Simd Construct Most of the test cases added as part of this change contains semantic errors except few cases which are semantically correct but thrown a semantic error. Currently flang is not throwing the errors for these cases and throwing semantic errors for the following correct test cases {omp-do03.f90 , omp-loop-simd01.f90 , omp-simd02.f90 , omp-taskloop01.f90} Hence, all the test cases are marked as XFAIL. Reviewed By: DavidTruby Differential Revision: https://reviews.llvm.org/D87908
1 parent 10c94d8 commit 956a84d

26 files changed

+590
-0
lines changed

flang/test/Semantics/omp-do01.f90

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! collapse(n) where n > num of loops
7+
8+
program omp_do
9+
integer i, j, k
10+
11+
!ERROR: Not enough do loops for collapsed !$OMP DO
12+
!$omp do collapse(2)
13+
do i = 1, 10
14+
print *, "hello"
15+
end do
16+
!$omp end do
17+
18+
end program omp_do

flang/test/Semantics/omp-do02.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! Exit statement terminating !$OMP DO loop
7+
8+
program omp_do
9+
integer i, j, k
10+
11+
!$omp do
12+
do i = 1, 10
13+
do j = 1, 10
14+
print *, "Hello"
15+
end do
16+
!ERROR: EXIT statement terminating !$OMP DO loop
17+
exit
18+
end do
19+
!$omp end do
20+
21+
end program omp_do

flang/test/Semantics/omp-do03.f90

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! Semantic error for correct test case
7+
8+
program omp_do
9+
integer i, j, k
10+
integer :: a(10), b(10)
11+
a = 10
12+
j = 0
13+
14+
!$omp parallel
15+
!$omp do linear(j:1)
16+
do i = 1, 10
17+
j = j + 1
18+
b(i) = a(i) * 2.0
19+
end do
20+
!$omp end do
21+
!$omp end parallel
22+
23+
print *, j
24+
print *, b
25+
26+
end program omp_do

flang/test/Semantics/omp-do04.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! The loop iteration variable may not appear in a threadprivate directive.
7+
8+
program omp_do
9+
integer i, j, k
10+
11+
!$omp do firstprivate(i)
12+
!ERROR: !$OMP DO iteration variable i is not allowed in threadprivate
13+
do i = 1, 10
14+
do j = 1, 10
15+
print *, "Hello"
16+
end do
17+
end do
18+
!$omp end do
19+
20+
end program omp_do

flang/test/Semantics/omp-do05.f90

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! chunk_size must be a loop invariant integer expression
7+
! with a positive value.
8+
9+
program omp_do
10+
integer i, j, k
11+
integer :: a(10), b(10)
12+
a = 10
13+
j = 0
14+
15+
!ERROR: INTEGER expression of SCHEDULE clause chunk_size must be positive
16+
!$omp do schedule(static, -1)
17+
do i = 1, 10
18+
j = j + 1
19+
b(i) = a(i) * 2.0
20+
end do
21+
!$omp end do
22+
23+
print *, j
24+
print *, b
25+
26+
end program omp_do

flang/test/Semantics/omp-do06.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL:*
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! The ordered clause must be present on the loop construct if any ordered
7+
! region ever binds to a loop region arising from the loop construct.
8+
9+
program omp_do
10+
integer i, j, k
11+
12+
!$omp do
13+
do i = 1, 10
14+
!ERROR: ‘ordered’ region inside a loop region without an ordered clause.
15+
!$omp ordered
16+
call my_func()
17+
!$omp end ordered
18+
end do
19+
!$omp end do
20+
21+
end program omp_do

flang/test/Semantics/omp-do07.f90

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL:*
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! No statement in the associated loops other than the DO statements
7+
! can cause a branch out of the loops
8+
9+
program omp_do
10+
integer i, j, k
11+
12+
!$omp do
13+
do i = 1, 10
14+
do j = 1, 10
15+
print *, "Hello"
16+
!ERROR: invalid branch to/from OpenMP structured block
17+
goto 10
18+
end do
19+
end do
20+
!$omp end do
21+
22+
10 stop
23+
24+
end program omp_do

flang/test/Semantics/omp-do08.f90

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
7+
program omp_do
8+
integer i, j, k
9+
!$omp do collapse(2)
10+
do i = 1, 10
11+
!ERROR: CYCLE statement to non-innermost collapsed !$OMP DO loop
12+
if (i .lt. 5) cycle
13+
do j = 1, 10
14+
print *, "Hello"
15+
end do
16+
end do
17+
!$omp end do
18+
19+
end program omp_do

flang/test/Semantics/omp-do09.f90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! The do-loop cannot be a DO WHILE or a DO loop without loop control.
7+
8+
program omp_do
9+
integer i, j, k
10+
i = 0
11+
12+
!$omp do
13+
!ERROR: !$OMP DO cannot be a DO WHILE or DO without loop control
14+
do while (i .lt. 10)
15+
do j = 1, 10
16+
print *, "Hello"
17+
end do
18+
i = i + 1
19+
end do
20+
!$omp end do
21+
22+
end program omp_do

flang/test/Semantics/omp-do10.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.1 Loop Construct
6+
! The do-loop iteration variable must be of type integer.
7+
8+
program omp_do
9+
real i, j, k
10+
11+
!$omp do
12+
!ERROR: The do-loop iteration variable must be of type integer.
13+
do i = 1, 10
14+
do j = 1, 10
15+
print *, "Hello"
16+
end do
17+
end do
18+
!$omp end do
19+
20+
end program omp_do
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.8.3 Loop simd Construct
6+
! Semantic error for correct test case.
7+
8+
program omp_loop_simd
9+
integer i, j, k, l
10+
k = 0;
11+
l = 0
12+
13+
!$omp parallel do simd linear(l)
14+
do i = 1, 10
15+
do j = 1, 10
16+
print *, "omp loop simd"
17+
k = k + 1
18+
l = l + 1
19+
end do
20+
end do
21+
22+
print *, k, l
23+
24+
end program omp_loop_simd
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.5 parallel construct.
6+
! A program that branches into or out of a parallel region
7+
! is non-conforming.
8+
9+
program omp_parallel
10+
integer i, j, k
11+
12+
!$omp parallel
13+
do i = 1, 10
14+
do j = 1, 10
15+
print *, "Hello"
16+
!ERROR: invalid branch to/from OpenMP structured block
17+
goto 10
18+
end do
19+
end do
20+
!$omp end parallel
21+
22+
10 stop
23+
24+
end program omp_parallel
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.5 parallel construct.
6+
! A program that branches into or out of a parallel region
7+
! is non-conforming.
8+
9+
program omp_parallel
10+
integer i, j, k
11+
12+
!ERROR: invalid entry to OpenMP structured block
13+
goto 10
14+
15+
!$omp parallel
16+
do i = 1, 10
17+
do j = 1, 10
18+
print *, "Hello"
19+
10 stop
20+
end do
21+
end do
22+
!$omp end parallel
23+
24+
end program omp_parallel
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.7.2 sections Construct
6+
! Only a single nowait clause can appear on a sections directive.
7+
8+
program omp_sections
9+
10+
!$omp sections
11+
!$omp section
12+
print *, "omp section"
13+
!ERROR: Only a single nowait clause can appear on a sections directive.
14+
!$omp end sections nowait nowait
15+
16+
end program omp_sections

flang/test/Semantics/omp-simd01.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.8.1 simd Construct
6+
! A program that branches into or out of a simd region is non-conforming.
7+
8+
program omp_simd
9+
integer i, j
10+
11+
!$omp simd
12+
do i = 1, 10
13+
do j = 1, 10
14+
print *, "omp simd"
15+
!ERROR: invalid branch to/from OpenMP structured block
16+
goto 10
17+
end do
18+
end do
19+
!$omp end simd
20+
21+
10 stop
22+
23+
end program omp_simd

flang/test/Semantics/omp-simd02.f90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.8.1 simd Construct
6+
! Semantic error for correct test case
7+
8+
program omp_simd
9+
integer i, j, k
10+
integer, allocatable :: a(:)
11+
12+
allocate(a(10))
13+
14+
!$omp simd aligned(a)
15+
do i = 1, 10
16+
a(i) = i
17+
end do
18+
!$omp end simd
19+
20+
print *, a
21+
22+
end program omp_simd

flang/test/Semantics/omp-simd03.f90

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
! RUN: %S/test_errors.sh %s %t %f18 -fopenmp
2+
! XFAIL: *
3+
4+
! OpenMP Version 4.5
5+
! 2.8.1 simd Construct
6+
! An ordered construct with the simd clause is the only OpenMP construct
7+
! that can be encountered during execution of a simd region.
8+
9+
program omp_simd
10+
integer i, j, k
11+
integer, allocatable :: a(:)
12+
13+
allocate(a(10))
14+
15+
!$omp simd
16+
do i = 1, 10
17+
!ERROR: Invalid OpenMP construct inside simd region
18+
!$omp single
19+
a(i) = i
20+
!$omp end single
21+
end do
22+
!$omp end simd
23+
24+
print *, a
25+
26+
end program omp_simd

0 commit comments

Comments
 (0)