rugnux --model: fit the bulk-solvent grid points in parallel
FitModelScale fits ~113 (k_sol, b_sol) grid points, each a full Levenberg-Marquardt over every working reflection, and it is the largest single cost of --model (every fit_model call: the first fit, the twin-law probe, the fit after the rigid body, each null replicate). It ran on one thread. Each point starts from fit_isotropic_b_approximately(), which sets k_overall and b_star from the data and the point's solvent pair alone, so no point depends on the one before it. The points of each pass (coarse, then the refinement around the coarse winner) now run in contiguous chunks, each on its own copy of the Scaling, and the winner is read off afterwards in grid order with the serial rule (lowest finite R, first on a tie). Each point's arithmetic is unchanged, so the result is the serial loop's bit for bit. Where fit_isotropic_b_approximately() has five or fewer reflections to fit on it returns without setting anything and points would chain, so there the grid is still walked serially on the caller's Scaling. Inside a null replicate (a pool worker) the chunks run inline, as before. To check: MODEL_* keys and md5 of the maps/.mtz/_model.cif identical with and without this commit on the audit set; model-phase time on a fit-dominated set. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT
This commit is contained in:
1 parent
e6adf8d650
commit
2f727b1975
4 files changed
+84
-19
No files matched your search
@@ -141,3 +141,26 @@ TEST_CASE("ModelScaling adds nothing when there is no solvent to model") {
|
||||
CHECK(scaling.b_sol >= 10.0);
|
||||
CHECK(scaling.b_sol <= 80.0);
|
||||
}
|
||||
|
||||
// The grid points are fitted in parallel; the answer must be the serial one, bit for bit.
|
||||
TEST_CASE("ModelScaling is the same on any number of threads") {
|
||||
const gemmi::UnitCell cell = Cell();
|
||||
const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name("P 21 21 21");
|
||||
REQUIRE(sg != nullptr);
|
||||
gemmi::Scaling<float> serial(cell, sg);
|
||||
serial.use_solvent = true;
|
||||
MakePoints(serial, cell, /*k_overall=*/0.5, /*b_iso=*/20.0,
|
||||
/*k_sol=*/0.35, /*b_sol=*/45.0, /*d_min=*/2.0, /*d_max=*/50.0);
|
||||
gemmi::Scaling<float> parallel = serial;
|
||||
|
||||
const ModelScaleReport r1 = FitModelScale(serial, {}, 1);
|
||||
const ModelScaleReport r8 = FitModelScale(parallel, {}, 8);
|
||||
CHECK(r1.n_grid == r8.n_grid);
|
||||
CHECK(r1.r_work_fit == r8.r_work_fit);
|
||||
CHECK(serial.k_sol == parallel.k_sol);
|
||||
CHECK(serial.b_sol == parallel.b_sol);
|
||||
CHECK(serial.k_overall == parallel.k_overall);
|
||||
CHECK(serial.b_star.u11 == parallel.b_star.u11);
|
||||
CHECK(serial.b_star.u22 == parallel.b_star.u22);
|
||||
CHECK(serial.b_star.u33 == parallel.b_star.u33);
|
||||
}
|
||||
Reference in new issue
Block a user