MR and model validation on the CPU: workers bounded by their bytes, not the thread count
- The CPU translation function runs as many rotations at once as the host worker pool holds (8 B per grid point each, 550 MiB on a 400 A cell; 33 at once at 32 threads was 18 GiB), at most nthreads. Counted, not reserved: the rotations run on ParallelFor's pool, whose workers must not wait on memory. - Null replicates (model validation's and MR's) whose structure factors are made on the CPU reserve 32 B per point of their grid (ModelGridPoints) against the pool before they start, so the nine replicates, and nulls run side by side, hold at most the pool between them. Every replicate and rotation computes what it did and is stored by index: no result depends on how many run at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PXc1zD1yxHqaR1DGdCTHL4
This commit is contained in:
1 parent
64a87cdf52
commit
43e836573d
5 files changed
+48
-3
No files matched your search
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "../../common/CorrelationCoefficient.h"
|
||||
#include "../../common/JFJochMath.h" // PI (M_PI is not standard, and MSVC does not define it)
|
||||
#include "../../common/HostMemory.h"
|
||||
#include "../../common/Logger.h"
|
||||
#include "../../common/ParallelFor.h"
|
||||
#include "../scale_merge/ReindexAmbiguity.h" // ReindexReflections
|
||||
@@ -1247,7 +1248,17 @@ ModelValidationResult Validate(const std::vector<MergedReflection> &merged,
|
||||
// the order the concurrent replicates finish in.
|
||||
std::vector<double> null_r_work(NULL_REPLICATES), null_margin(NULL_REPLICATES);
|
||||
std::atomic<int> placed_redraws{0};
|
||||
// A replicate whose structure factors are made on the CPU holds a gigabyte or more of grids on a large
|
||||
// cell, so it reserves them against the host's worker pool (HostWorkerPool) first: as many replicates
|
||||
// run at once as it holds, whatever the thread count, and each computes what it computes either way.
|
||||
size_t replicate_bytes = MODEL_FACTORS_BYTES_PER_GRID_POINT
|
||||
* ModelGridPoints(null_model.cell, null_model.find_spacegroup(), null_d_min);
|
||||
#ifdef JFJOCH_USE_CUDA
|
||||
if ((sf_gpu != nullptr && null_d_min == sf_gpu->DMin()) || (sf_null != nullptr && null_d_min == sf_null->DMin()))
|
||||
replicate_bytes = 0;
|
||||
#endif
|
||||
auto run_replicate = [&](int i) {
|
||||
const HostWorkerPool::Reservation reserved(HostWorkerPool::Instance(), replicate_bytes);
|
||||
std::mt19937 rng(NULL_SEED + 1 + i);
|
||||
gemmi::Mat33 rot = null_rotation[i];
|
||||
for (int redraw = 0;; redraw++) {
|
||||
|
||||
Reference in new issue
Block a user