Hi everybody
I am giving my first steps with cuda fortran but I am getting a problem with the following simple code incTest.cuf
module simpleOps_m
contains
attributes(global) subroutine inc(a,b)
implicit none
integer :: a(:)
integer, value :: b
integer :: i, n
i= threadIdx%x
a(i)=a(i)+b
end subroutine inc
end module simpleOps_m
program incTest
use cudafor
use simpleOps_m
implicit none
integer :: b, n=256
integer, allocatable :: a(:)
integer, allocatable, device :: a_d(:)
allocate (a(n), a_d(n))
a=1
b=3
a_d=a
call inc<<<1,n>>>(a_d,b)
a=a_d
if (all(a==4)) &
write(*,*) 'Test Passed'
deallocate (a,a_d)
end program incTest
I compiled the code with pgf90 -Minfo -o exe incTest.cuf and I got the following
inctest:
33, all reduction inlined
but when I ran it I didn’t get the message ‘Test Passed’. Before I tested an even simpler code copydat.cuf and it worked
program copyData
use cudafor
implicit none
integer, parameter :: n=256
real :: a(n), b(n)
real, device :: a_d(n),b_d(n)
a=1.0
a_d=a
b_d=a_d
b= b_d
if (all(a==b)) &
write(*,*) 'Test passed'
end program copyData
What test can I do to know what is the problem
Thanks for your time