From 8ef877dc1418dbf197ed457e5b3903de8a174207 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 16 Nov 2026 22:33:42 +0100 Subject: [PATCH] Refinement: no trials run ahead on the CPU On the CPU the trial slots share the run's threads, so a trial run ahead of the decision that needs it takes threads from the trials that are needed. Run them ahead only on the GPU, where a spare slot is a card of its own. The outcome is unchanged: trials run ahead and not needed were already discarded with their evaluations. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- image_analysis/structure_refinement/Refinement.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/image_analysis/structure_refinement/Refinement.cpp b/image_analysis/structure_refinement/Refinement.cpp index ecceb852d..b7ae83199 100644 --- a/image_analysis/structure_refinement/Refinement.cpp +++ b/image_analysis/structure_refinement/Refinement.cpp @@ -3275,13 +3275,15 @@ RefinementResult RefineOnce(const gemmi::Structure &placed, const std::vector cards; for (const TrialSlot &s : trial_slots) cards.insert(s.ctx->device); const bool one_card = cards.size() == 1 && *cards.begin() >= 0; - auto ahead = [&](size_t trials) { return !one_card && trial_slots.size() >= trials; }; + const bool on_gpu = ctx.engine->OnGPU(); + auto ahead = [&](size_t trials) { return on_gpu && !one_card && trial_slots.size() >= trials; }; int ahead_evaluations = 0; auto drop_ahead = [&](TrialOutcome &o) { ahead_evaluations += o.evaluations;