<div dir="auto">It is possible to write your own openmp implimentation, performing the row multiplications in parallel, using Cython or whatever low language you like.  Since sparse matrix dense vector multiplication is memory bandwidth limited, you will see good performance if the problem fits into CPU cache.  Otherwise, you will see only marginal improvements.  If your problem has structure, then that should be exploited to make things faster.  Also permutations like reverse Cuthill-Mckee, in SciPy, can give a modest boost.<div dir="auto"><br></div><div dir="auto">Best,</div><div dir="auto"><br></div><div dir="auto">Paul</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Aug 29, 2017 04:26, "Michele Martone" <<a href="mailto:michelemartone@users.sourceforge.net">michelemartone@users.sourceforge.net</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Marc,<br>
<br>
did you try the PyRSB prototype:<br>
<br>
 "librsb is a high performance sparse matrix library implementing the<br>
  Recursive Sparse Blocks format, which is especially well suited for<br>
  multiplications in iterative methods on huge sparse matrices.<br>
  PyRSB is a Cython-based Python interface to librsb."<br>
 <a href="https://github.com/michelemartone/pyrsb" rel="noreferrer" target="_blank">https://github.com/<wbr>michelemartone/pyrsb</a><br>
<br>
?<br>
<br>
How large are your matrices ?<br>
<br>
Are they symmetric ?<br>
<br>
If your matrices are large you might get quite of a speedup;<br>
if symmetric, even better.<br>
<br>
Best regards,<br>
Michele<br>
<br>
p.s.: PyRSB (a thin interface) is a prototype, but librsb itself<br>
 <a href="http://librsb.sourceforge.net/" rel="noreferrer" target="_blank">http://librsb.sourceforge.net/</a><br>
is in a mature state and usable also from Fortran, and OpenMP based.<br>
<div class="elided-text"><br>
On 20170828@18:14, marc wrote:<br>
> Dear Scipy developers,<br>
><br>
> We are developing a program that perform a large number of sparse matrix<br>
> multiplications. We recently wrote a Python version of this program for<br>
> several reasons (the original code is in Fortran).<br>
><br>
> We are trying now to improve the performance of the Python version and we<br>
> noticed that one of the bottlenecks are the sparse matrix multiplications,<br>
> as example,<br>
><br>
> import numpy as np<br>
> from scipy.sparse import csr_matrix<br>
><br>
> row = np.array([0, 0, 1, 2, 2, 2])<br>
> col = np.array([0, 2, 2, 0, 1, 2])<br>
> data = np.array([1, 2, 3, 4, 5, 6], dtype=np.float32)<br>
><br>
> csr = csr_matrix((data, (row, col)), shape=(3, 3))<br>
> print(csr.toarray())<br>
><br>
> A = np.array([1, 2, 3], dtype=np.float32)<br>
><br>
> print(csr*A)<br>
><br>
><br>
> I started to look at the Scipy code to see how this functions were<br>
> implemented, and realized that there is no openmp parallelization over the<br>
> for loops. Like in function  csr_matvec in sparse/sparsetools/csr.h (line<br>
> 1120). Is it possible to parallelize this loops with openmp? Do you have<br>
> maybe better ideas to improve the performances for this kind of operations?<br>
><br>
> Best regards,<br>
> Marc Barbry<br>
> ______________________________<wbr>_________________<br>
> SciPy-Dev mailing list<br>
> <a href="mailto:SciPy-Dev@python.org">SciPy-Dev@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scipy-dev</a><br>
</div><br>______________________________<wbr>_________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@python.org">SciPy-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scipy-dev</a><br>
<br></blockquote></div><br></div>