From dc88610e0dfd2e9d89dacb2ecca3cd87b14c3e57 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 16 Nov 2026 19:18:12 +0100 Subject: [PATCH] Refinement on the CPU: the arms take half of the threads each only where the lattice admits a twin law Without one the twinned arm ends at once and its half sat idle (found by lane t: about 6 of 12 threads busy through the whole refinement). Identical R-free and evaluations; at 12 threads thau 125 -> 92 s, 9zlo 143 -> 90 s. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- image_analysis/structure_refinement/Refinement.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/image_analysis/structure_refinement/Refinement.cpp b/image_analysis/structure_refinement/Refinement.cpp index d360c8f59..609a0fcd5 100644 --- a/image_analysis/structure_refinement/Refinement.cpp +++ b/image_analysis/structure_refinement/Refinement.cpp @@ -4645,7 +4645,10 @@ RefinementResult RefineModel(const gemmi::Structure &placed, const std::vector 1; + // on the CPU each arm on half of the threads - where the lattice admits a twin law, without which the twinned + // arm ends at once and its half would sit idle + const bool halves = on_cpu && settings.population <= 1 && settings.nthreads > 1 && + !RefinementTwinLaws(cell, sg).empty(); RefinementSettings untwinned_settings = settings, twin_settings = settings; if (halves) { twin_settings.nthreads = settings.nthreads / 2;