You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::thread::hardware_concurrency() returns, when possible, the underlying hardware capability to run threads, which might not corresponds to the actual number of cores available to the process (through the use of taskset, batch system like slurm, etc...). The consequence is that the program might run in a non optimal way. For example, if I run taskset -c 1 on my 20 cores machines, it will run 20 workers on only one core.
Consider this code run through the slurm scheduler using srun, requesting 4 cores:
$ srun -c 4 ./get_cores
srun: job 13694693 queued and waiting for resources
srun: job 13694693 has been allocated resources
using std::thread::hardware_concurrency: 96
using sched_getaffinity: 4
I think a more sane behavior would be to use sched_getaffinity as in the folly library for example (folly/folly/system/HardwareConcurrency.cpp)
Thanks for the info - this certainly looks like a worthwhile change for users who take more active control over their CPU resources. We'll look into it for a future release.
Hello,
In the default_thread_allocations function, C++ hardware_concurrency is used to determine the maximum number of threads.
dorado/dorado/utils/parameters.cpp
Line 13 in 9dc15a8
std::thread::hardware_concurrency() returns, when possible, the underlying hardware capability to run threads, which might not corresponds to the actual number of cores available to the process (through the use of taskset, batch system like slurm, etc...). The consequence is that the program might run in a non optimal way. For example, if I run taskset -c 1 on my 20 cores machines, it will run 20 workers on only one core.
Consider this code run through the slurm scheduler using srun, requesting 4 cores:
I think a more sane behavior would be to use sched_getaffinity as in the folly library for example (
folly/folly/system/HardwareConcurrency.cpp
)What do you think ?
Thank you for considering this change !
The text was updated successfully, but these errors were encountered: