Refinement: the likelihood's D and beta fitted bin by bin on the refinement's threads
EstimateLikelihoodParameters fits each resolution bin on its own and writes only that bin's values, so the bins run under ParallelFor; the result is the same, bit for bit. It was the largest single stage of a refinement (107 calls, one core): 5reo 2.42 -> 0.56 s, 8dyz 2.46 -> 0.57 s, 9yl4 3.54 -> 0.88 s; whole refinement 5reo 6.3 -> 4.8 s, 8dyz 6.9 -> 5.3 s (RTX 5080, -N 8, loaded box). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit 85aa34d3031c8e36be4462fca544bc801af45d5a) (cherry picked from commit d84ba55252adf455d5b4ba62052dfbafa6290a64)
This commit is contained in:
1 parent
24b1711d64
commit
dd49d4e2f2
3 files changed
+6
-5
No files matched your search
@@ -229,7 +229,7 @@ RefinementReflections PrepareRefinementReflections(const std::vector<MergedRefle
|
||||
}
|
||||
|
||||
void EstimateLikelihoodParameters(const RefinementReflections &refl, const std::vector<std::complex<float>> &fmodel,
|
||||
XrayRowModel &rows) {
|
||||
XrayRowModel &rows, size_t nthreads) {
|
||||
const size_t n = refl.Size();
|
||||
std::vector<double> fc(n);
|
||||
for (size_t i = 0; i < n; i++)
|
||||
@@ -248,7 +248,8 @@ void EstimateLikelihoodParameters(const RefinementReflections &refl, const std::
|
||||
const size_t bins = std::clamp<size_t>(free.size() / FREE_PER_BIN, 1, MAX_BINS);
|
||||
|
||||
std::vector<double> centre(bins), bin_d(bins), bin_beta(bins);
|
||||
for (size_t b = 0; b < bins; b++) {
|
||||
// each bin is fitted on its own
|
||||
ParallelFor(static_cast<int>(bins), nthreads, [&](int b) {
|
||||
const std::vector<size_t> idx(free.begin() + b * free.size() / bins, free.begin() + (b + 1) * free.size() / bins);
|
||||
double s2 = 0, sfo = 0, sfc2 = 0, sfofc = 0;
|
||||
for (size_t i : idx) {
|
||||
@@ -271,7 +272,7 @@ void EstimateLikelihoodParameters(const RefinementReflections &refl, const std::
|
||||
}
|
||||
bin_d[b] = d;
|
||||
bin_beta[b] = beta;
|
||||
}
|
||||
});
|
||||
rows.d.resize(n);
|
||||
rows.var.resize(n);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
||||
Reference in new issue
Block a user