Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Specific examples? #25

Closed
yaoyuki opened this issue Jul 19, 2021 · 2 comments
Closed

[Suggestion] Specific examples? #25

yaoyuki opened this issue Jul 19, 2021 · 2 comments

Comments

@yaoyuki
Copy link

yaoyuki commented Jul 19, 2021

Hi,

Is it possible to set up benchmarking comparison with a specific example between scipy.sparse.spsolve and Pardiso?

I set up PyPardiso in my environment, but I did not see any improvement, and wondering if I set up the environment correctly. Some introductory examples would be helpful for users.

@haasad
Copy link
Owner

haasad commented Oct 26, 2021

Hi @yaoyuki,

I apologize for the late reply. I have updated the basic usage section in the README.

Based on that example, you could do something like this to check the difference in solve speed between the two solvers:

In [1]: import pypardiso

In [2]: import numpy as np

In [3]: import scipy.sparse as sp

In [4]: import scipy.sparse.linalg as spl

In [5]: n = 1000

In [6]: A = sp.rand(n, n, density=0.1, format='csr')

In [7]: b = np.random.rand(n)

In [8]: %time x_scipy = spl.spsolve(A, b)
CPU times: user 397 ms, sys: 0 ns, total: 397 ms
Wall time: 147 ms

In [9]: %time x_pypardiso = pypardiso.spsolve(A, b)
CPU times: user 222 ms, sys: 20.1 ms, total: 242 ms
Wall time: 178 ms

In [10]: n = 10000

In [11]: A = sp.rand(n, n, density=0.1, format='csr')

In [12]: b = np.random.rand(n)

In [13]: %time x_scipy = spl.spsolve(A, b)
CPU times: user 5min, sys: 856 ms, total: 5min
Wall time: 1min 15s

In [14]: %time x_pypardiso = pypardiso.spsolve(A, b)
CPU times: user 38 s, sys: 680 ms, total: 38.7 s
Wall time: 15 s

But please be aware that the solver performance always depends on your specific problem and your hardware, so a real benchmark is difficult. The discussion in this issue kinnala/scikit-fem/issues/690 has some very detailed benchmarking between pypardiso and the scipy superLU solver.

Does that answer your question?

@yaoyuki
Copy link
Author

yaoyuki commented Oct 26, 2021

thx! yes, I thought it would be helpful to have an example to check if one has set up the environment correctly, given that Intel MKL seems tricky. I think it would be great if readme includes the difference in time. As you say, it does depend on the environment, but just as a guide.

(In my own environment, I don't see a big difference for this specific example, but it seems the problem is on my side.)

@yaoyuki yaoyuki closed this as completed Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants