When I try to call certain CUBLAS operations (it seems to specifically be those that return their answer, rather than saving it on the GPU) from Fortran I just get 0.0 as the answer (or something close to it). Calling these operations in the same way from C works fine, and calling other CUBLAS operations from Fortran also works fine.
Example:
program cublastest
implicit none
integer M, sizeof_real, devPtrA
parameter (M=5, sizeof_real=4)
real a(M), dotout
integer stat
external cublas_init, cublas_set_vector, cublas_get_vector
external cublas_shutdown, cublas_alloc, cublas_ddot
external cublas_get_error
integer cublas_alloc, cublas_set_vector, cublas_get_vector
integer cublas_get_error
real cublas_ddot
a = 1
write (*,*) 'a: ', a
call cublas_init
stat = cublas_alloc(M, sizeof_real, devPtrA)
if (stat .NE. 0) then
write(*,*) "device memory allocation failed"
stop
endif
stat = cublas_set_vector (M, sizeof_real, a, 1, devPtrA, 1)
if (stat .NE. 0) then
write(*,*) "device memory copy1 failed"
stop
endif
dotout = cublas_ddot (M, devPtrA, 1, devPtrA, 1)
write(*,*) 'dotout: ', dotout
stat = cublas_get_error ()
write(*,*) 'Error: ', stat
call cublas_free (devPtrA)
call cublas_shutdown
stop
end
Thanks