[petsc-users] Transform scipy sparse to partioned, parallel petsc matrix in PETSc4py
Jan Grießer
griesser.jan at googlemail.com
Sun Feb 11 11:35:10 CST 2018
Hey,
i have a precomputed scipy sparse matrix for which I want to solve the
eigenvalue problem for a matrix of size 35000x35000. I don´t really get how
to parallelize this problem correctly.
Similar to another
thread(https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2013-August/01850
1.html) I tried the following code:
D = scipy.sparse.load_npz("sparse.npz")
B = D.tocsr()
# Construct the matrix Ds in parallel
Ds = PETSc.Mat().create()
Ds.setSizes(CSRmatrix.shape)
Ds.assemble()
# Fill the matrix
rstart, rend = Ds.getOwnershipRange()
csr = (
B.indptr[rstart:rend+1] - B.indptr[rstart],
B.indices[B.indptr[rstart]:B.indptr[rend]],
B.data[B.indptr[rstart]:B.indptr[rend]]
)
Ds = PETSc.Mat().createAIJ(size=CSRmatrix.shape, csr=csr)
Ds.assemble()
# Solve the eigenvalue problem
solve_eigensystem(Ds)
This code works for 1 processor with mpiexec n 1 python example.py, however
for increasing number of processors it appears as if al processors try to
solve the overall problem instead of splitting it into blocks and solve for
a subset of eigenvalues and eigenvectors.
Why is this the case or did I miss something?
Greetings Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180211/62ce5a99/attachment.html>
More information about the petsc-users
mailing list