yixuan / RSpectra

R Interface to the Spectra Library for Large Scale Eigenvalue and SVD Problems
http://cran.r-project.org/package=RSpectra
80 stars 12 forks source link

how to control the cores used by svds #19

Closed Zilong-Li closed 3 years ago

Zilong-Li commented 3 years ago

Hi yixuan,

I noticed that all machines' cores will be used when I run svds on my large matrix. Under some conditions, we may want to control the cores used by a program. How can I make it?

Also, I am writing a program using the Spectra (C++). There seems no way to run it in parallel. But RSpectra can take advantages of multi cores. What's the difference?

Looking forward to your reply. Thanks in advance.

privefl commented 3 years ago

Probably because you have some high-performance parallelized matrix library linked with R. Which makes every matrix computation faster and using multiple cores. You can try to use RhpcBLASctl::omp_set_num_threads() to change this.

Zilong-Li commented 3 years ago

Thanks @privefl ! I made it by using RhpcBLASctl::blas_set_num_threads().

So maybe there is a way to run Spectra in parallel. I'll try to figure it out. If you have any ideas, please let me know.