How build cusparse<t>gthr in fortran?

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

Hi medvsn,

In looking through the cuSPARSE documentation, I see that this routine was deprecated in CUDA 11.0 and removed in CUDA 12 so no longer available.

Using the flag “-gpu=cuda11.8 -cudalib=cusparse” you can revert to using the older CUDA version, but you should investigate finding an alternative method as well.

-Mat

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.