diff --git a/rugnux/RugnuxFirstPass.cpp b/rugnux/RugnuxFirstPass.cpp index c4fb4c61a..f6664d617 100644 --- a/rugnux/RugnuxFirstPass.cpp +++ b/rugnux/RugnuxFirstPass.cpp @@ -119,10 +119,10 @@ namespace { return spots; } - // First-pass spot finding on workers of its own, spread over the cards as the first pass's own - // workers are (worker t on card t % cards), for work that runs beside the first pass. Each worker - // keeps its engine from one call to the next - building one costs far more than a frame - and - // gives it back on that card. + // First-pass spot finding on workers of its own, for work that runs beside the first pass: spread + // over the cards other than card 0, which the first pass itself keeps busy (worker t on card + // 1 + t % (cards - 1); card 0 only on a one-card machine). Each worker keeps its engine from one + // call to the next - building one costs far more than a frame - and gives it back on that card. class SpotFindingWorkers { public: SpotFindingWorkers(JFJochReader &reader, const DiffractionExperiment &x, @@ -165,13 +165,15 @@ namespace { std::unique_ptr profile; }; - // fn(t) on n threads of its own, thread t on card t % cards: the card its engine lives on. + // fn(t) on n threads of its own, thread t on the card its engine lives on. template void OnWorkers(size_t n, Fn fn) { std::vector> futures; for (size_t t = 0; t < n; t++) futures.emplace_back(std::async(std::launch::async, [this, &fn, t] { - if (const int32_t gpus = get_gpu_count(); gpus > 0) - pin_gpu(static_cast(t) % gpus); + if (const int32_t gpus = get_gpu_count(); gpus > 1) + pin_gpu(1 + static_cast(t) % (gpus - 1)); + else if (gpus == 1) + pin_gpu(0); fn(t); })); for (auto &f : futures)