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

Control over the internal threading of a model #194

Open
WardBrian opened this issue Dec 7, 2023 · 0 comments
Open

Control over the internal threading of a model #194

WardBrian opened this issue Dec 7, 2023 · 0 comments
Labels

Comments

@WardBrian
Copy link
Collaborator

If a model is compiled with STAN_THREADS and uses a function such as map_rect or reduce_sum, this will lead to the model spawning multiple threads during each call to the log density.

Currently, the model is allowed to spawn up to the hardware number of threads, which means if it is done in a loop which is also parallel on the "outside" you get oversubscription.

The Stan Math library lets you set the maximum number of threads by using init_threadpool_tbb.
We could just expose this, but it has some issues, most notably that calling it multiple times has no effect.
Similar to the print callback, this will also globally apply to all instances from the same shared library.

@WardBrian WardBrian added the cpp label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant