Skip to content

Improve the speed of imaged distance calculations. Check for duplicate atom names in residues. - #1198

Merged
drroe merged 30 commits into
Amber-MD:masterfrom
drroe:improveDistCalc.2
Oct 16, 2026
Merged

drroe merged 30 commits into
Amber-MD:masterfrom
drroe:improveDistCalc.2

Conversation

@drroe

@drroe drroe commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Version 7.12.5. Note that this revision increase also takes into account missing revision bumps from previous PRs:
7.12.4 : TIMatch #1193
7.12.3 : Inline common distance routines #1197
7.12.2 : Optimize two-mask radial calculation for orthogonal cells #1196
7.12.1 : Optimize radial calculation for orthogonal cells #1195

Inspired by the previous pull requests which have improved the speed of the radial command with orthogonal shells, I have refactored some of the distance calculations to further improve speed in radial for non-orthogonal cells and for other commands using imaged distance calculations in general.

Most benchmarks have remained at the previous performance (0.98x - 1.00x speedup). However, several benchmarks have improved from this PR:

#Benchmark                                              Old      New  SpeedUp   Change
nativecontacts_benchmark.                            2.9833   2.3967     1.24    19.66
SPAM_benchmark.                                      3.0800   2.4933     1.24    19.05
Hbond_nonortho_benchmark.                            2.7067   2.1333     1.27    21.18
LIE_benchmark.                                       1.5467   1.1433     1.35    26.08
Radial_solvent-solvent_by_site_benchmark.           22.1433  16.1467     1.37    27.08
Watershell_ortho_benchmark.                          3.1800   2.3033     1.38    27.57
Radial_solvent-solute,_center2_benchmark.            2.9900   2.0900     1.43    30.10
Radial_solvent-solvent_benchmark.                    9.9533   6.4033     1.55    35.67
Radial_solvent-solvent,_nointramol_benchmark.       20.1367  12.8767     1.56    36.05
Radial_solvent_to_solute_benchmark.                  5.4833   3.3433     1.64    39.03
Radial_solvent-solute_benchmark.                     4.4967   2.2800     1.97    49.30

In particular the non-orthogonal imaging in the radial command has been sped up almost 2x.

A new class Dcalc has been created which is intended to be used when multiple distances will be calculated in a single frame. Currently it is only used by radial but probably should be put anywhere multiple distances are being calculated. For non-orthogonal images, it uses the same logic employed in Dist_Imaged.cpp to cut down the number of images that need to be checked.

The DIST2_ImageNonOrtho() functions now just call the improved distance routine for non-orthogonal cells from Dist_Imaged.cpp (Cpptraj::Dist2_Imaged_Cart()). The results are identical.

This PR also adds a check for duplicate atom names in residues when topologies are loaded/created since this can lead to unexpected behavior (e.g. typically one expects the mask :1@CA to select a single atom.

drroe and others added 27 commits October 13, 2026 16:08
…s speed about 8% (measured with RDF action). Improve speed of nonortho calcs by using Dist_Imaged routines.
… includes missing revision bumps from previous PRs:

7.12.4 : TIMatch
7.12.3 : Inline common distance routines
7.12.2 : Optimize two-mask radial calculation for orthogonal cells
7.12.1 : Optimize radial calculation for orthogonal cells
@drroe drroe self-assigned this Oct 16, 2026
@drroe
drroe merged commit 5d3516d into Amber-MD:master Oct 16, 2026
12 of 13 checks passed
@drroe
drroe deleted the improveDistCalc.2 branch October 16, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant