ModelScaleGPU: the host polls for a scale fit's launches instead of sleeping on them

A Levenberg-Marquardt step is a few short launches the host then reads the sums of, a hundred or so steps per
fit, and the process has every synchronisation sleep until the device raises the wake-up
(set_gpu_blocking_sync): for these launches the wake-up costs more than the work. The fit's waits poll the
stream instead. Outputs are byte-identical; the refinement's scale refit counter drops 20-27% and the
molecular replacement's scale fits gain a little on the demo-sized sets.

Summing the block partials on the host instead of in a kernel was tried alongside and dropped: the coarse
solvent grid of 88 fits made it a megabyte of read-back per step, slower than the kernel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
leonarski_fandClaude Fable 5.1 committed 2026-10-26 20:58:10 +01:00
1 parent 128e3bb9ae
commit f724bd1117
2 files changed
+13 -3

No files matched your search

@@ -78,6 +78,10 @@ private:
// The sums of the first `nfits` uploaded fits over all points, one row of SLOTS doubles per fit, on
// the host.
const double *Reduce(int nfits);
// The stream's queued work done, polled for: a fit's launches are short and the host waits for every one
// of them, so sleeping until the device raises the wake-up (set_gpu_blocking_sync) would cost more than
// the work itself.
void Wait();
const double *Sums(const std::vector<ModelScaleFitState> &fits);
void FitBatch(const float2 *d_fcmol, const float2 *d_fmask, std::vector<ModelScaleFitState> &fits);
// gemmi's Levenberg-Marquardt for every fit in `fits` from the parameters it holds.