I am trying to run the first Fortran program in PGI insider, June 2009. I am getting some weird results. Probably something stupid I did, but I just cant’ see it. So, with your indulgence, my code is:
program dbl_it
integer :: n, i
real,dimension(:),allocatable :: a, r, e
character(10) :: arg1
if (iargc() > 0) then
call getarg(1,arg1)
read(arg1,'(i10)') n
else
n=100000
endif
allocate(a(n),r(n),e(n))
do i=1,n
a(i)=2.*i
enddo
!$acc region
do i=1,n
r(i)=2.*a(i)
enddo
!$acc end region
do i=1,n
e(i)=2.*a(i)
enddo
do i=1,n
if (r(i) /= e(i)) then
print *, i,r(i),e(i)
stop 'error found'
endif
enddo
print *, n,'iterations completed'
end program
Note the default for “n” is 100000. As long as I keep n less than or equal to 100000, everything is OK:
[CUDA]$ ./a.out
100000 iterations completed
[CUDA]$ ./a.out 50000
50000 iterations completed
But if I go beyond 100000, woe is me:
[CUDA]$ ./a.out 100001
100001 0.000000 400004.0
Warning: ieee_inexact is signaling
error found
It looks like somehow the GPU is picking up on that 100000 default value and only populating the array “r” up to 100000.
If I change the default to, say, 20000, then the GPU populates “r” only up to 20000. I put in a bounch of diagnostic output to look at n; n alwys outputs OK. But the GPU won’t go beyond the default value.
Many apologies if I am doing something obviously wrong. I have looked at this over and over and I can’t see it. Thanks.