Skip to content

Add funcionality to set/get total number of threads (wrapper for mkl_set_num_threads and mkl_get_num_threads) - #180

Merged
ViralBShah merged 2 commits into
JuliaLinearAlgebra:masterfrom
VinceNeede:master
May 19, 2025
Merged

Add funcionality to set/get total number of threads (wrapper for mkl_set_num_threads and mkl_get_num_threads)#180
ViralBShah merged 2 commits into
JuliaLinearAlgebra:masterfrom
VinceNeede:master

Conversation

@VinceNeede

Copy link
Copy Markdown
Contributor

This should give to the user the possibility to set the global number of threads, in particular this is the only way to set LAPACK threads (see this discussion on MKL forum, and JuliaLinearAlgebra/libblastrampoline#151). Also a section for Threading control is added in the Readme.

Solves #174

@ViralBShah
ViralBShah merged commit 7d61425 into JuliaLinearAlgebra:master May 19, 2025
@ViralBShah

Copy link
Copy Markdown
Member

@VinceNeede May I give you commit access here to be able to make new releases and such? It is a pretty slow moving package, but hopefully it doesn't need to wait on me or anyone else.

@hersle

hersle commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator

Can a new release be tagged? It would be nice to access this :)

It confused me that MKL.{set/get}_num_threads mentioned in the README is not available in the latest release.

@ViralBShah

Copy link
Copy Markdown
Member

Releasing in #181. Happy to give folks here commit access to help maintain the package. Please let me know.

@VinceNeede

Copy link
Copy Markdown
Contributor Author

I'm sorry for the late answer. Unfortunately I don't feel confident enough for this, yet. Still thank you for the offer!

@ViralBShah

Copy link
Copy Markdown
Member

Totally understand. Note that MKL.jl is a low-risk package to learn the ropes, and it is always possible to fix things or undo them.

@giordano giordano linked an issue Jun 4, 2025 that may be closed by this pull request
@ViralBShah

Copy link
Copy Markdown
Member

@hersle Can I give you commit access for managing this repo? You seemed to be ahead of me in the registration process :-)

@hersle

hersle commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator

@ViralBShah Sure. I can only help with small stuff like that, though, at least for now :)

Thanks both for the PR and swift reply!

@ViralBShah

Copy link
Copy Markdown
Member

@ViralBShah Sure. I can only help with small stuff like that, though, at least for now :)

That's the best help! Invited you.

@m-schwendt

Copy link
Copy Markdown

If I understand this correctly then mkl_set_num_threads should now set the number of threads used by MKL at runtime, right? It doesn't seem to work, though. The only way still seems to set the environmental variable MKL_NUM_THREADS. At least that was the only way I could get different threads when trying it on two different HPC clusters (using Julia 1.11.6 and MKL 0.9.0).

@VinceNeede

Copy link
Copy Markdown
Contributor Author

I cannot confirm. It works for me with Julia v1.11.6 and MKL v0.9.0. Could you please open a separate issue? Also note that for Blas and Lapack threads you can now use BLAS.set_num_theads(nthreads) directly from LinearAlgebra

@m-schwendt

Copy link
Copy Markdown

@VinceNeede Sorry, you are right. I accidentally used MKL.BLAS.set_num_threads instead of MKL.set_num_threads.

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

Successfully merging this pull request may close these issues.

Setting MKL thread number

4 participants