Thread count from the CPUs the process may use, not the machine's
std::thread::hardware_concurrency() counts every CPU of the node, so a job given a CPU set (taskset, a cpuset, a Slurm allocation) or a container CPU quota started one thread per node CPU: the default -N, the shared worker pool and every "0 = all threads" default. AvailableCpus() (ThreadAffinity) counts the start affinity mask, capped by the cgroup CPU quota (v2 cpu.max, v1 cfs_quota/period, the process's own cgroup and then the mounted root), read once. Outside Linux it is hardware_concurrency(), so the viewer tree stays portable. It replaces every hardware_concurrency() call outside the tests and the vendored pocketfft. Only how many threads run changes; the passes split their work by n alone, so the results do not depend on it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi
This commit is contained in:
1 parent
af3ea9ccad
commit
50006eff88
14 files changed
+88
-23
No files matched your search
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "../common/JFJochException.h"
|
||||
#include "../common/Logger.h"
|
||||
#include "../common/ThreadAffinity.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -285,7 +286,7 @@ Layout Place(const std::vector<Frame> &frames, const std::string &logger_name) {
|
||||
}
|
||||
|
||||
void ForEachInOrder(size_t n, const std::function<void(size_t)> &fn) {
|
||||
const size_t nthreads = std::min<size_t>(std::max(1u, std::thread::hardware_concurrency()), 8);
|
||||
const size_t nthreads = std::min<size_t>(AvailableCpus(), 8);
|
||||
std::atomic<size_t> next{0};
|
||||
std::vector<std::future<void>> futures;
|
||||
for (size_t t = 0; t < nthreads; t++)
|
||||
|
||||
Reference in new issue
Block a user