Skip to content

Batched QR factorization of sparse matrices on GPUs. Wrapper of the CUDA library cusolverSpDcsrqrsvBatched()

License

Notifications You must be signed in to change notification settings

romanodev/GBQsparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GBQsparse

Batched QR factorization of sparse matrices on GPUs. Wrapper of the CUDA library cusolverSpDcsrqrsvBatched()

Open In Colab

INSTALL

apt-get install libsuitesparse-dev 
pip install GBQsparse

Background

This package solves multiple linear systems, A x=b, sharing the same sparsity pattern.

Below are some of the resources I have used in writing GBQsparse:

High-level discussion of Batched QR factorization

C++ CUDA examples

SKCUDA examples

StackOverflow

Example

from GBQsparse import MSparse
import scipy.sparse as sp
import numpy as np
import time
import scipy.sparse.linalg as sla

N = 10
nbatch = 10
m = sp.diags([1, -2, 1], [-1, 0, 1], shape=(N, N),format='coo')

A = np.random.random_sample((nbatch,m.nnz))
B = np.random.random_sample((nbatch,N))

m = MSparse(m.row,m.col,N,nbatch,reordering=True)

m.add_LHS(A)

t1 = time.time()
X = m.solve(B)
t2 = time.time()

m.free_memory()

xs = []
for i in range(nbatch):
      S = sp.csr_matrix((A[i],(m.row,m.col)),shape=(N,N),dtype=float)
      x = sla.spsolve(S,B[i])
      xs.append(x)
xs=np.array(xs)

t3 = time.time()
print(t2-t1)
print(t3-t2)
print(np.allclose(xs,X,rtol=1e-01,atol=1e-1))

About

Batched QR factorization of sparse matrices on GPUs. Wrapper of the CUDA library cusolverSpDcsrqrsvBatched()

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages