Refinement: the per-evaluation host chain on the threads and in place
Byte-identical: every pass is element by element in the serial loop's order, or a copy that is no longer made. - The engine's gradients are read in place from its pinned buffers and widened to double on the threads (RefinementGPUEngine::HostGradient/HostRestraintGradient); the positions go up from a pinned vector of the engine's host side; the model's atom pointers are kept between calls (the model is the context's own). - Context: the riders moved and folded on the threads - a parent takes its riders in index order through a CSR list (SetRiderParents), as the serial walk added them. - AtomTarget: the parameters set and the gradient assembled on the threads; the per-atom gradient vectors kept between evaluations (7 MB each on a large model: made anew, their pages fault in every time). - RefinementMinimiser: the sweeps over the parameters (x + alpha d, s, y) on the threads it is given, the dot products the serial chains they were; Direction()'s working vector and a let-go pair's vectors reused. A/B against the frozen combined2 binary, one lock hold each, outputs identical but provenance lines: cytc refinement 1.600 -> 1.548 s (live), 1.724 -> 1.668 (CLI); thau 1.906 -> 1.885, 2.031 -> 2.027; 4nwv (with the commit before) 39.9 -> 35.5 s, the ladder 14.6 -> 12.7, each step 8.3 -> 7.2. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
1 parent
b16873036c
commit
d122118d73
5 files changed
+174
-99
No files matched your search
@@ -59,14 +59,19 @@ public:
|
||||
// from them): called again only where some atom's density changed. Read until the call returns; from pinned
|
||||
// memory they go up by DMA.
|
||||
void SetDensities(const ModelDensityAtom *atoms, size_t n);
|
||||
// The atoms' grid positions (fractional times the grid size, not wrapped), in the order of SetDensities().
|
||||
void SetPositions(const std::vector<std::array<float, 4>> &pos);
|
||||
// The atoms' grid positions (fractional times the grid size, not wrapped), in the order of SetDensities():
|
||||
// read until the next evaluation returns, so from a pinned buffer the copy goes up by DMA.
|
||||
void SetPositions(const std::array<float, 4> *pos, size_t n);
|
||||
// F of the atoms at the rows.
|
||||
void Fcalc(std::vector<std::array<float, 2>> &f);
|
||||
// The bulk-solvent mask's F at the rows (the mask atoms fractional, wrapped), on the mask's own grid.
|
||||
void Fmask(const std::vector<ModelMaskAtom> &mask_atoms, std::vector<std::array<float, 2>> &f);
|
||||
// -ln L over the working rows for the atoms last set and, with `grad`, dT/d(x, y, z, B) per atom.
|
||||
double Evaluate(std::vector<std::array<float, 4>> *grad);
|
||||
// -ln L over the working rows for the atoms last set and, with `grad`, dT/d(x, y, z, B) per atom into
|
||||
// HostGradient().
|
||||
double Evaluate(bool grad);
|
||||
// The gradients of the last evaluation, in the engine's pinned buffers: valid until the next one.
|
||||
const std::array<float, 4> *HostGradient() const;
|
||||
const std::array<float, 4> *HostRestraintGradient() const;
|
||||
|
||||
// Restraint set `which` (0 or 1), as RestraintSet holds it.
|
||||
void SetRestraints(int which, const std::vector<RestraintRecord> &records, const std::vector<int> &plane_atoms,
|
||||
@@ -75,10 +80,10 @@ public:
|
||||
double EvaluateRestraints(int which, const std::vector<std::array<float, 4>> &xyzb,
|
||||
std::vector<std::array<float, 4>> *grad);
|
||||
// Evaluate() and EvaluateRestraints() in one submission with one wait: the X-ray target is queued first, and
|
||||
// `xyzb` writes the restraints' x, y, z, B of every atom while the device works on it.
|
||||
double EvaluateWithRestraints(std::vector<std::array<float, 4>> *grad, int which,
|
||||
const std::function<void(std::array<float, 4> *)> &xyzb,
|
||||
std::vector<std::array<float, 4>> *restraint_grad, double &restraints);
|
||||
// `xyzb` writes the restraints' x, y, z, B of every atom while the device works on it. The gradients into
|
||||
// HostGradient() and HostRestraintGradient().
|
||||
double EvaluateWithRestraints(bool grad, int which, const std::function<void(std::array<float, 4> *)> &xyzb,
|
||||
bool restraint_grad, double &restraints);
|
||||
|
||||
// The most atoms of a plane restraint the kernel takes.
|
||||
static constexpr int MAX_PLANE_ATOMS = 32;
|
||||
|
||||
Reference in new issue
Block a user