Closed BurningKarl closed 3 years ago
It may be as simple as passing a different parameter to the underlying SPQR C library. I would welcome a pull request, or if it's a small change, a tip on what to change.
I saw this when working through another issue, ran the script above and, FWIW, I cannot reproduce this issue.
%run matrix.py
np.linalg.qr: 8.187024593353271
sparseqr.qr: 6.860008001327515
%run matrix.py
np.linalg.qr: 7.470994234085083
sparseqr.qr: 6.794812202453613
%run matrix.py
np.linalg.qr: 7.407967805862427
sparseqr.qr: 7.4680376052856445
%run matrix.py
np.linalg.qr: 7.614963054656982
sparseqr.qr: 6.833277225494385
Since sparseqr is a wrapper to suitesparse, if suitesparse is built with multithreading and/or multi core support (and the blas libraries it relies on), then sparseqr will be multithreaded/multi core.
Tests above run on ubuntu 20.04 lts, suitesparse 5.8.1 compiled with intel-oneapi-mkl-2021.3.0 (and associated packages) and a (old) laptop limited to two cores (one thread per core). Both cores appeared to be fully utilized for both np qr and sparse qr.
Check if your blas libraries are multithreaded.
HTH.
Thanks for your input @stuart-nolan. I tried installing the sparseqr
in a fresh virtual environment just now and it indeed used multiple cores. Interestingly though, while np.linalg.qr
utilizes 100% of my computing power, sparseqr.qr
uses only about 50% (i.e. 4 out of 8 cores). Maybe this is due to some virtual cores vs. physical cores hiccup. As I cannot reproduce the problem myself, we can consider this issue closed.
For completeness sake, my operating system is Ubuntu 20.04 LTS with libsuitsparse-dev
version 5.7.1 and libopenblas-dev
version 0.3.8 installed (from the official repositories).
Dear developers,
thank you for providing this library to access the SPQR functionality using Python code. Unfortunately, the provided
qr
function does not take advantage of multiple cores on my machine making it much slower compared to np.linalg.qr which uses all available CPU cores by default. To give you an example I ran the following code on my computer (Intel Core i7-1165G7 @ 2.80GHz x 8 running Ubuntu 20.04) and documented the runtimes:I could clearly see, using my system monitor, that
sparseqr.qr
only used one CPU core which is weird, given that SPQR is advertised as "a multifrontal multithreaded sparse QR factorization package."Is multithreading currently supported by
sparseqr
? If so, what do I have to do to enable it? If not, could you elaborate on what it would take to support it or whether this is even feasible for a Python wrapper?Many thanks in advance!