Skip to content

Control over the internal threading of a model #194

@WardBrian

Description

@WardBrian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions