diff --git a/rugnux/RugnuxImagePass.cpp b/rugnux/RugnuxImagePass.cpp index 90060a378..3ba388961 100644 --- a/rugnux/RugnuxImagePass.cpp +++ b/rugnux/RugnuxImagePass.cpp @@ -368,9 +368,19 @@ void Rugnux::ImagePass(PipelineLocals &p) { // which is what a previous attempt at this got wrong. // Only the full-analysis worker drives a card; the azimuthal one preprocesses and integrates on // the CPU and wants every thread it can have, so the cap must not reach it. + // A worker also holds about 24 bytes a detector pixel of its card - sixteen held 6.3 GB on a 16.8 Mpx + // detector - and the workers keep to half of the card, so a small card gets fewer of them. How many + // there are changes only how fast the loop runs, never what it computes. const int gpus = get_gpu_count(); + int workers_per_card = 16; + if (gpus > 0) { + constexpr int64_t WORKER_BYTES_PER_PIXEL = 24; + const auto fit = static_cast(get_gpu_total_memory(0) / 2) + / (WORKER_BYTES_PER_PIXEL * experiment_.GetPixelsNum()); + workers_per_card = static_cast(std::clamp(fit, 1, 16)); + } const int image_workers = (per_image_analysis && config_.nthreads_auto && gpus > 0) - ? std::min(config_.nthreads, std::max(16, 16 * gpus)) + ? std::min(config_.nthreads, workers_per_card * gpus) : config_.nthreads; if (image_workers < config_.nthreads) logger.Info("Per-image loop: {} of {} threads ({} GPUs) - past what a card can take queue "