Commit 27c4ac7d by Maxim Blumenthal Committed by Ilya Verbin

re PR libgomp/66950 (FAIL: libgomp.fortran/examples-4/simd-7.f90 -O0 execution test)

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.

From-SVN: r226080
parent 19e18903
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.
2015-07-21 Nathan Sidwell <nathan@codesourcery.com> 2015-07-21 Nathan Sidwell <nathan@codesourcery.com>
* target.c (gomp_offload_image_to_device): Rename to ... * target.c (gomp_offload_image_to_device): Rename to ...
......
...@@ -5,17 +5,27 @@ ...@@ -5,17 +5,27 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define N 45 #define N 30
int a[N], a_ref[N], b[N]; int a[N], a_ref[N], b[N];
#pragma omp declare simd inbranch #pragma omp declare simd inbranch
int fib( int n ) int fib( int n )
{ {
if (n <= 2) if (n <= 1)
return n; return n;
else { else
return fib(n-1) + fib(n-2); return fib(n-1) + fib(n-2);
} }
void fib_ref()
{
int i;
a_ref[0] = 0;
a_ref[1] = 1;
for (i=2; i < N; i++)
a_ref[i] = a_ref[i-2] + a_ref[i-1];
} }
int main(void) int main(void)
...@@ -30,8 +40,7 @@ int main(void) ...@@ -30,8 +40,7 @@ int main(void)
for (i=0; i < N; i++) for (i=0; i < N; i++)
a[i] = fib(b[i]); a[i] = fib(b[i]);
for (i=0; i < N; i++) fib_ref ();
a_ref[i] = fib(b[i]);
for (i=0; i < N; i++) for (i=0; i < N; i++)
if (a[i] != a_ref[i]) if (a[i] != a_ref[i])
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
program fibonacci program fibonacci
implicit none implicit none
integer,parameter :: N=45 integer,parameter :: N=30
integer :: a(0:N-1), b(0:N-1) 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 :: i
integer, external :: fib integer, external :: fib
...@@ -15,35 +15,39 @@ program fibonacci ...@@ -15,35 +15,39 @@ program fibonacci
b(i) = i b(i) = i
end do end do
do i = 0,N-1
b_ref(i) = i
end do
!$omp simd !$omp simd
do i=0,N-1 do i=0,N-1
a(i) = fib(b(i)) a(i) = fib(b(i))
end do end do
do i=0,N-1 call fib_ref (a_ref, N)
a_ref(i) = fib(b_ref(i))
end do
do i = 0, N-1 do i = 0, N-1
if (a(i) .ne. a_ref(i)) call abort () if (a(i) .ne. a_ref(i)) call abort ()
end do end do
if (a(44) .ne. 1134903170) call abort()
end program end program
recursive function fib(n) result(r) recursive function fib(n) result(r)
!$omp declare simd(fib) inbranch !$omp declare simd(fib) inbranch
integer :: n, r integer :: n, r
if (n <= 2) then if (n <= 1) then
r = n r = n
else else
r = fib(n-1) + fib(n-2) r = fib(n-1) + fib(n-2)
endif endif
end function fib 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment