Magma version of BLAS routine ZSBMV

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
fletchjp
Posts: 203
Joined: Mon Dec 27, 2010 7:29 pm

Magma version of BLAS routine ZSBMV

Post by fletchjp » Mon Aug 03, 2015 8:13 am

I am working on an interim method of using sparse matrix techniques to solve some problems.

I want to multiply

Code: Select all

r = B q
and have the countb elements of B stored in b_sparse with indices in ibs and jbs. Using two extra vectors qq and rr indexed in the same way as b_sparse I can get the multiplication done in one call using the BLAS routine zsbmv

Code: Select all

         call zscal(N,ZERO,r,1)
         do i = 1, countb
            qq(i) = q(ibs(i))
         enddo
C This is band matrix multiplication with only the diagonal.
C It is worth the effort to copy q to qq and rr back to r.
         bands = 0 
         CALL zsbmv('L',countb,bands,ONE,b_sparse,1,qq,1,ZERO,rr,1)
         do i = 1, countb
            r(jbs(i)) = r(jbs(i)) + rr(i)
         enddo         
There is a timing advantage to this using OpenBLAS 0.2.14.

I have looked but cannot find a MAGMA version of zsbmv. Is this something you are thinking of doing?

Thanks

John

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Magma version of BLAS routine ZSBMV

Post by hartwig anzt » Mon Aug 03, 2015 8:25 am

John,

if I do understand you correct, you want to multiply a sparse matrix with a vector - is this correct? And the sparse matrix has a nice diagonal property?

If so, I would recommend just using a default sparse matrix vector (SpMV) routine. These are typically highly optimized, and will sure satisfy your performance goal.

Hartwig

fletchjp
Posts: 203
Joined: Mon Dec 27, 2010 7:29 pm

Re: Magma version of BLAS routine ZSBMV

Post by fletchjp » Mon Aug 03, 2015 9:42 am

Hartwig

Yes, I do want to multiply a sparse matrix into a vector ( r = B q ).

What I have done is copy the vector values to another vector so that my multiplication is now

Code: Select all

rr[i] = bb[i] * qq[i]
which is now dense. I am using ZSBMV which is in BLAS but not I think in MagmaBlas.

I have two cases, one with about 60,000 entries which is running well on the CPU.

I have another case with 3,300,000 entries which I think would benefit from using Magma.

There seems to be no BLAS routine which does element wise vector-vector multiplication. ZSBMV can be used to achieve it.

http://stackoverflow.com/questions/7621 ... on-in-blas was where I found the suggestion.

I cannot yet use the sparse routines in Magma 1.6.2, so this is an alternative.

Thanks for your help

John

P.S. It seems that CUDA 6.5 does have versions of SSBMV and DSBMV but not the complex versions:
  • fletcher@fletcher-desktop:/usr/local/cuda-6.5/include$ grep sbmv *.h
    cublas_api.h:CUBLASAPI cublasStatus_t CUBLASWINAPI cublasSsbmv_v2 (cublasHandle_t handle,
    cublas_api.h:CUBLASAPI cublasStatus_t CUBLASWINAPI cublasDsbmv_v2 (cublasHandle_t handle,
    cublas.h:void CUBLASWINAPI cublasSsbmv (char uplo, int n, int k, float alpha,
    cublas.h:void CUBLASWINAPI cublasDsbmv (char uplo, int n, int k, double alpha,
    cublas_v2.h:#define cublasSsbmv cublasSsbmv_v2
    cublas_v2.h:#define cublasDsbmv cublasDsbmv_v2

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Magma version of BLAS routine ZSBMV

Post by hartwig anzt » Mon Aug 03, 2015 10:21 am

John,

now I see what you want: element-wise multiplication of a vector. And you found a workaround using a sparse matrix. I promise, once you have the code running on the GPU using MAGMA, I'll write a function doing this quickly. This is very easy on a GPU.

Hartwig

fletchjp
Posts: 203
Joined: Mon Dec 27, 2010 7:29 pm

Re: Magma version of BLAS routine ZSBMV

Post by fletchjp » Mon Aug 03, 2015 11:13 am

Hartwig

No, I have found the work around using a routine designed for banded diagonal matrix multiplication (which is what SB means). I put my sparse matrix data into a vector and shuffle the values to be multiplied from the original vector into a vector matching the sparse data.

The GNU Scientific Library does have a routing called gsl_vector_mul - see

https://www.gnu.org/software/gsl/manual ... tions.html

I would like it if you could do me a routine. I am working in FORTRAN but I guess can interface from C++.

Thanks

John

P.S. There is a FORTRAN implementation zsbmv.f in Magma 1.6.2. It is located in magma-1.6.2/testing/lin.
  • fletcher@fletcher-desktop:~/magma-1.6.2/testing/lin$ ls zsb*
    zsbmv.f
I don''t think that is what I am using, I think my code gets it from OpenBLAS.

Post Reply