Repository navigation
COORDINATION without a neighbor list: faster, threaded, thread-indepe… - #1642
Merged
Merged
Conversation
…ndent CoordinationBase (COORDINATION, DHENERGY, GHBFIX): - pairCutoff2(): pairs beyond the cutoff of the switching function are skipped before pairing(); derivatives and virial are added only for the pairs with a nonzero derivative. - Without a neighbor list the pairs are taken from the groups in blocks of rows (the larger group), without storing the list of all the pairs. Each block adds the derivatives of its rows directly and stores those of the columns, which are summed over the blocks in order: the result does not depend on the number of threads. - With NLIST/NLISTCELLS/PAIR, the per-thread buffers are kept between steps and summed in parallel, in the order of the threads, instead of in a critical section. Core: for actions with many atoms, retrieveAtoms, setForcesOnAtoms (when no atom is requested twice), checkForForces (few values with many derivatives) and clearDerivatives use the threads; the results are identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtWQypT9j2SfDguLb95
The value and the virial were accumulated through references (in the lambda of calculateBlocks) or in a Tensor in memory, one store and load per pair. They are now summed per batch in local variables, with the six components of the symmetric virial. Without D_MAX (all the pairs computed), the loop is now 6% faster than on master instead of 3% slower; NLIST is 6-10% faster. The virial changes in the last digits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtWQypT9j2SfDguLb95
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1642 +/- ##
========================================
Coverage 88.97% 88.97%
========================================
Files 651 652 +1
Lines 81815 81939 +124
========================================
+ Hits 72793 72908 +115
- Misses 9022 9031 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The local reference to the Pbc was unused in the instantiations without pbc (CodeQL). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016vwxtWQypT9j2SfDguLb95
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ndent
CoordinationBase (COORDINATION, DHENERGY, GHBFIX):
Core: for actions with many atoms, retrieveAtoms, setForcesOnAtoms (when no atom is requested twice), checkForForces (few values with many derivatives) and clearDerivatives use the threads; the results are identical.
Claude-Session: https://claude.ai/code/session_016vwxtWQypT9j2SfDguLb95
COORDINATION without a neighbour list (2026-11-17)
Follows coordination-nolist-kickoff.md.
Status:
coordination-nolist(from master 33b78e7) in the Mac worktreeClaude outputs/coordination-nolist/wt; not pushed. The same diff is inClaude outputs/coordination-nolist/coordination-nolist.patch.Setup
Claude outputs/coordination-nolist/wt, branchcoordination-nolistfrom master 33b78e7 (= origin/master;openaccPTM-multigpunot merged yet).-O2 -g -fno-omit-frame-pointer,CXX="ccache mpicxx",--enable-modules=all --disable-doc --disable-python;core/Value.hrebuilds almost everything (~25 min);PLUMED_KERNEL=... plumed-runtime driver(lost with the container)./usr/lib/linux-tools/6.8.0-149-generic/perf(apt-get install linux-tools-generic; theperfwrapper refuses the running kernel). Profile withplumed benchmark --ixyz conf --nsteps Nandstacks.py(rootPlumedMain::performCalc);perf annotate -l -s "<symbol> [clone ._omp_fn.0]"for line level. Leaf libc calls (memset) lose their direct caller with frame-pointer stacks.Claude outputs/coordination-nolist/bench/run.sh(COORDINATION + RESTRAINT, driver timers, best of 3; configs fromneighbor-sums/bench-one-row/gen.py).Results (cloud, 2 cores, -O2, fwd+bwd ms/step with forces, best of 3; master → branch)
input | pairs | atoms | 1 thread | 2 threads -- | -- | -- | -- | -- 1 atom vs 10k | 10k | 10k | 0.33 → 0.22 | 0.29 → 0.18 1 atom vs 100k | 100k | 100k | 4.92 → 3.66 | 5.03 → 1.97 200 × 500 | 100k | 700 | 1.90 → 0.85 | 1.02 → 0.46 GROUPA 500 | 125k | 500 | 2.36 → 1.07 | 1.25 → 0.56 1000 × 2000 | 2M | 3000 | 39.3 → 18.6 | 21.0 → 9.4 NLIST, 1 vs 100k, stride 10 | | | 0.058 → 0.055 | 0.125 → 0.059 NLIST, 1000 × 2000, stride 10 | | | 2.49 → 2.14 | 1.28 → 1.13cellsMinimumGroupon openaccPTM-multigpu (no cells for few rows) should address it; not checked.Next
- Committed on the Mac: 168703a on
- Leonardo 8/32 threads for c1-100k and for 1000×2000.
- Optional: vectorizable orthorhombic
# COORDINATION without a neighbour list (2026-11-17)coordination-nolist(from master 33b78e7), Carlo's identity + Co-Authored-By. Not pushed.Pbc::apply.Follows [coordination-nolist-kickoff.md](coordination-nolist-kickoff.md).
Status:
coordination-nolist(from master 33b78e7) in the Mac worktreeClaude outputs/coordination-nolist/wt; not pushed. The same diff is inClaude outputs/coordination-nolist/coordination-nolist.patch.Setup
Claude outputs/coordination-nolist/wt, branchcoordination-nolistfrom master 33b78e7 (= origin/master;openaccPTM-multigpunot merged yet).-O2 -g -fno-omit-frame-pointer,CXX="ccache mpicxx",--enable-modules=all --disable-doc --disable-python;core/Value.hrebuilds almost everything (~25 min);PLUMED_KERNEL=... plumed-runtime driver(lost with the container)./usr/lib/linux-tools/6.8.0-149-generic/perf(apt-get install linux-tools-generic; theperfwrapper refuses the running kernel). Profile withplumed benchmark --ixyz conf --nsteps Nandstacks.py(rootPlumedMain::performCalc);perf annotate -l -s "<symbol> [clone ._omp_fn.0]"for line level. Leaf libc calls (memset) lose their direct caller with frame-pointer stacks.Claude outputs/coordination-nolist/bench/run.sh(COORDINATION + RESTRAINT, driver timers, best of 3; configs fromneighbor-sums/bench-one-row/gen.py).Results (cloud, 2 cores, -O2, fwd+bwd ms/step with forces, best of 3; master → branch)
x+=100trick), also when Pbc.cpp is built with -O3. A possible separate item: a vectorizable rounding, which would change the last digits everywhere.What changed
CoordinationBase, all CVs):virtual double pairCutoff2() const, +inf by default. Coordination returns dmax²·(1+1e-12), a margin for the rounding of dmax² and of the sqrt incalculateSqr. GHBFIX returns itsdmax_squared.pairing. Derivatives and virial are added only whendfunc!=0.calculateBlocks): no NeighborList is built, so the pairs are no longer stored (8 B/pair).rowsPerBlock = max(16, ceil(512/ncols))rows; it is raised if nblocks·ncols > 2^20.blockColumns[b]. The columns are then summed over the blocks in order (parallel over the columns), and value and virial per block are summed in order.mpiDeriv+comm.Sum.calculateList): persistent per-thread buffers summed in thread order, in parallel over the atoms, instead of thecritical.threadUsedcopes with a smaller team (without OpenMPgetNumThreads()is 2 but the team has 1 thread).ActionAtomistic::retrieveAtoms: the positions are copied with threads (≥ 2×16384 atoms per group).ActionAtomistic::setForcesOnAtoms: the forces are added with threads, only if no atom is requested twice. The new memberatomsAreUniqueis set inrequestAtomsfromuniquebefore/afterremoveDuplicates.ActionWithValue::checkForForces: with few values and ≥ 16 chunks of 4096 derivatives, the threads share the derivatives. The same operations as the serial loop are used, so the results are identical.ActionWithValue::clearDerivatives: values fewer than threads →Value::clearDerivatives(force, nt)(new, in Value.cpp, with OpenMP in the .cpp and not in the header).Verification
PLUMED_NUM_THREADS=2: all 1169 regtests pass.%.17g:--dump-forces) of 1 atom vs 100k: identical on 1 and 2 threads.Profile before the change (master)
Colvar::applyserial,retrieveAtoms);omp_derivtook 23% and thecritical21%.No list vs NLIST / NLISTCELLS (branch, cloud, fwd+bwd ms/step, 1t / 2t)
D_MAX=1.2; NLIST and NLISTCELLS with NL_CUTOFF=1.5 NL_STRIDE=10; "cells1" = NLISTCELLS NL_CUTOFF=1.2 NL_STRIDE=1 (exact, no skin).
cellsMinimumGroupon openaccPTM-multigpu (no cells for few rows) should address it; not checked.Next
coordination-nolist(from master 33b78e7), Carlo's identity + Co-Authored-By. Not pushed.Pbc::apply.