rugnux merge ingest: keep d beside zeta only under an energy bandwidth
The partiality recompute reads d only to broaden the rocking curve by the energy bandwidth. On a large set the final ingest sits at the process's peak resident memory (8a1a: max RSS rose by the array's 4 bytes x 68 M observations), so the array is kept only where a bandwidth is set; with zeta in and the predicted-partiality copy out, the ingest's peak is then where it was. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizBKhTqrAYago9KJG3dA3
This commit is contained in:
1 parent
b46b4a4657
commit
e55750e1e0
2 files changed
+16
-13
No files matched your search
@@ -877,15 +877,17 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
|
||||
// finiteness (immutable) - it lets ComputeAsuGroups stamp the ASU-group id per obs from a flat
|
||||
// 1-byte array instead of re-reading the fat Obs struct for every space group.
|
||||
//
|
||||
// delta_phi is re-solved against the smoothed geometry right here, and zeta and d - the two fields
|
||||
// the partiality recompute reads besides it - are kept beside it, so the smoothing that follows
|
||||
// (SmoothMosaicityAndPartiality) does not sweep the source reflections again.
|
||||
// delta_phi is re-solved against the smoothed geometry right here, and what the partiality
|
||||
// recompute reads besides it - zeta, and d where an energy bandwidth broadens the rocking curve -
|
||||
// is kept beside it, so the smoothing that follows (SmoothMosaicityAndPartiality) does not sweep
|
||||
// the source reflections again.
|
||||
finite_ok.assign(n_keep, 0);
|
||||
ingest_delta_phi.reset(new float[n_keep]);
|
||||
ingest_partiality.reset(new float[n_keep]);
|
||||
ingest_image_number.reset(new float[n_keep]);
|
||||
ingest_zeta.reset(new float[n_keep]);
|
||||
ingest_d.reset(new float[n_keep]);
|
||||
if (x.GetBandwidthFWHM().value_or(0.0f) > 0.0f)
|
||||
ingest_d.reset(new float[n_keep]);
|
||||
std::atomic<int64_t> n_resolved{0};
|
||||
#ifdef JFJOCH_USE_CUDA
|
||||
if (resident_ingest) {
|
||||
@@ -905,7 +907,7 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
|
||||
ingest_partiality[at] = r.partiality;
|
||||
ingest_image_number[at] = r.image_number;
|
||||
ingest_zeta[at] = r.zeta;
|
||||
ingest_d[at] = r.d;
|
||||
if (ingest_d) ingest_d[at] = r.d;
|
||||
const float prescaling_corr = static_cast<float>(
|
||||
r.prescaling_corr * r.qe_corr * r.flight_corr / frame_flux[o]);
|
||||
corr_ingested[at] = r.image_scale_corr;
|
||||
@@ -954,7 +956,7 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
|
||||
ingest_partiality[at] = r.partiality;
|
||||
ingest_image_number[at] = r.image_number;
|
||||
ingest_zeta[at] = r.zeta;
|
||||
ingest_d[at] = r.d;
|
||||
if (ingest_d) ingest_d[at] = r.d;
|
||||
corr_ingested[at] = r.image_scale_corr;
|
||||
++at;
|
||||
}
|
||||
@@ -1283,10 +1285,10 @@ void RotationScaleMerge::SmoothMosaicityAndPartiality() {
|
||||
const double half_wavelength_A = x.GetWavelength_A() / 2.0;
|
||||
ParallelFor(n_frames, nthreads, [&](int f) {
|
||||
for (int i = frame_start[f]; i < frame_start[f] + frame_count[f]; ++i) {
|
||||
const float d = ingest_d[i], zeta = ingest_zeta[i];
|
||||
const float zeta = ingest_zeta[i];
|
||||
float mos = mos_smooth[f];
|
||||
if (bandwidth_sigma > 0.0 && d > 0.0f) {
|
||||
const double sin_theta = half_wavelength_A / d;
|
||||
if (bandwidth_sigma > 0.0 && ingest_d[i] > 0.0f) { // ingest_d is kept exactly then
|
||||
const double sin_theta = half_wavelength_A / ingest_d[i];
|
||||
const double sigma_bw = (180.0 / PI) * bandwidth_sigma * sin_theta
|
||||
/ std::sqrt(1.0 - sin_theta * sin_theta);
|
||||
mos = static_cast<float>(std::sqrt(mos * mos + sigma_bw * sigma_bw));
|
||||
|
||||
@@ -337,10 +337,11 @@ private:
|
||||
bool resident_ingest = false;
|
||||
// What the ingest-time geometry smoothing (SmoothMosaicityAndPartiality) needs, one array per field
|
||||
// in `partials` order: the two fields it rewrites, the two the rocking-event walks read in raw-hkl
|
||||
// order, and the two the partiality recompute reads besides them (zeta, d - handed back as soon as
|
||||
// it is done). So on the resident path no per-observation record is built at all - on a
|
||||
// fine-sliced long axis that record was gigabytes, held beside the source reflections it was copied
|
||||
// from - and the smoothing does not sweep the source reflections again either. Filled by
|
||||
// order, and what the partiality recompute reads besides them (zeta, and d under an energy
|
||||
// bandwidth - handed back as soon as it is done). So on the resident path no per-observation
|
||||
// record is built at all - on a fine-sliced long axis that record was gigabytes, held beside the
|
||||
// source reflections it was copied from - and the smoothing does not sweep the source reflections
|
||||
// again either. Filled by
|
||||
// BuildInRangeObservations and handed back at the end of Ingest. Plain arrays, not sized vectors, for
|
||||
// the reason the staging buffers are (see Ingest): the build writes every element, and a sized vector
|
||||
// would first zero all of them on one thread.
|
||||
|
||||
Reference in new issue
Block a user