aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran
diff options
context:
space:
mode:
authorMaxim Blumenthal <maxim.blumenthal@intel.com>2015-07-22 17:19:31 +0000
committerIlya Verbin <ilya.verbin@intel.com>2015-07-22 17:19:31 +0000
commit8cb3a6ff1e05d0c2091518cb49b127980b26cfdf (patch)
treea74c00aa96cbb32759da71a0fb1850a630b9e8a4 /libgomp/testsuite/libgomp.fortran
parentb7e936261fd8e6325e84fc4bca2b47ca99b4128d (diff)
2015-07-22 Maxim Blumenthal <maxim.blumenthal@intel.com>
PR libgomp/66950 * testsuite/libgomp.c/examples-4/simd-7.c (N): Change to 30 from 45. (fib_ref): New function. (fib): Correct corner cases in the recursion. (main): Replace the non-simd loop with fib_ref call. * testsuite/libgomp.fortran/examples-4/simd-7.f90: (fib_ref): New subroutine. (fibonacci): Lower the parameter N to 30. Correct accordingly check for the last array element value. Replace the non-simd loop with fib_ref call. Remove redundant b_ref array. Remove the comparison of the last array element with according Fibonacci sequence element. (fib): Correct corner cases in the recursion. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@226080 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/testsuite/libgomp.fortran')
-rw-r--r--libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f9030
1 files changed, 17 insertions, 13 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90 b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90
index a61bb038bf0..75606570503 100644
--- a/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90
+++ b/libgomp/testsuite/libgomp.fortran/examples-4/simd-7.f90
@@ -4,9 +4,9 @@
program fibonacci
implicit none
- integer,parameter :: N=45
+ integer,parameter :: N=30
integer :: a(0:N-1), b(0:N-1)
- integer :: a_ref(0:N-1), b_ref(0:N-1)
+ integer :: a_ref(0:N-1)
integer :: i
integer, external :: fib
@@ -15,35 +15,39 @@ program fibonacci
b(i) = i
end do
- do i = 0,N-1
- b_ref(i) = i
- end do
-
!$omp simd
do i=0,N-1
a(i) = fib(b(i))
end do
- do i=0,N-1
- a_ref(i) = fib(b_ref(i))
- end do
+ call fib_ref (a_ref, N)
do i = 0, N-1
if (a(i) .ne. a_ref(i)) call abort ()
end do
- if (a(44) .ne. 1134903170) call abort()
-
end program
recursive function fib(n) result(r)
!$omp declare simd(fib) inbranch
integer :: n, r
- if (n <= 2) then
- r = n
+ if (n <= 1) then
+ r = n
else
r = fib(n-1) + fib(n-2)
endif
end function fib
+
+subroutine fib_ref(a_ref, n)
+ integer :: n, a_ref(0:n-1)
+
+ a_ref(0) = 0
+ a_ref(1) = 1
+
+ do i = 2, n-1
+ a_ref(i) = a_ref(i-1) + a_ref(i-2)
+ end do
+
+end subroutine fib_ref