I try to build program with cusparseSgthr
routine, and I get error in compiler (see fig.1).
st/src/test.cuf:29: undefined reference to `cusparseSgthr'
gmake[2]: *** [CMakeFiles/bspmv.dir/build.make:96: bspmv] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/bspmv.dir/all] Error 2
If I comment line with cusparseSgthr
and execute only create and destroy cusparseHandle, then it works (see the fig. 2).
The full code of the example:
program cusparse_test
! use a
use cudafor
use cusparse
implicit none
integer :: n, m, ierr
integer , allocatable :: ph(:)
integer , device, allocatable :: pd(:)
real , allocatable :: arr(:), arr2(:)
real , allocatable, device :: darr(:), darr2(:)
type(cusparseHandle) :: cusp
n = 5
allocate (arr(n))
allocate (arr2(n))
! accending array
arr(:) = [(m, m=1,n)]
allocate (darr(n))
! H2D arr
darr(:) = arr(:)
! Define array of indices
allocate (pd(n))
pd(:) = 3
! create target array
allocate (darr2(n))
darr2 = 0.0
ierr = cusparseCreate(cusp)
ierr = cusparseSgthr(cusp, n, darr, darr2, pd, 1)
arr2 = darr2
write(*,'("res: ", 5es10.2)') arr2(:)
deallocate(arr, arr2)
deallocate(darr, darr2, pd)
ierr = cusparseDestroy(cusp)
end program cusparse_test