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

Manage threading in the backend #492

Open
patrick-nicodemus opened this issue Jul 18, 2023 · 0 comments
Open

Manage threading in the backend #492

patrick-nicodemus opened this issue Jul 18, 2023 · 0 comments

Comments

@patrick-nicodemus
Copy link

This feature arguably falls outside the scope of the library - it is really a problem which is 2 dependencies down the food chain - but I will suggest it anyway because I think it makes a difference in quality of life for users. The linear algebra backend called by Numpy sometimes does very naive and inappropriate multithreading, where a single small matrix multiplication can be parallelized across all cores of the machine, resulting in a longer computation that takes more cores. I am running the computation on a 20 core machine, and if I try to compute the GW distances between two 100x100 matrices, it engages all 20 cores and takes 20ms; forcing Numpy to use a single thread brings the computation to about 12ms.

This problem is quite subtle to debug, as Numpy (or really its BLAS backend) launches 20 threads at the beginning of the program no matter how large the matrices are, but then it dynamically decides whether to use all threads or leave some idle. This is a clever design decision as it gets past the overhead of creating the threads up front, but for debugging parallelization-related performance issues it is quite confusing, because the system debugger will tell you that 20 threads are active, when in reality 1 is active and 19 are idle.

My feature request is that you integrate a tool such as joblib/threadpoolctl into the library and provide options to the user to control or limit thread-level parallelization, together with sensible defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant