Skip to content

perf: Start using cells for bonding calculation - #2621

Merged
rprospero merged 4 commits into
develop2from
dissolve2/bonding-with-cells
Oct 12, 2026
Merged

rprospero merged 4 commits into
develop2from
dissolve2/bonding-with-cells

Conversation

@rprospero

@rprospero rprospero commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

This uses cells to split up the bonding calculation. Instead of parallelising across atoms, we run in parallel across neighbouring cell pairs, which isn't quite as efficient, but hopefully the cell splitting makes up for the loss. One place to pay extra special attention is in line 58 of calculateBondingNode.cpp. I have been doing a dynamic calculation of the size of the box based on the inscribed radius, but this was somehow creating 1000 cells on linux and 2³² cells on Mac. I've now hard coded the cell size, but I would appreciate suggestions on a better way of handling this. At the time I'm writing this, the Mac build is failing due to a server failure for one of our dependencies, so I cannot check whether or not the hard coded size fixed the issue.

To do this, I've added an extra method to cell array that gives all the pairs along with all of the self pairings, which was behind the bug I was dealing with in the standup this morning.

There's also a change switching cells to just store an AtomBase pointer and then adjusting the existing call sites for CellArray.

As future work, we could write a cell atom-pair iterator that would allow us to iterate through the atom pairs in same or neighbouring cells. This would both simplify the code (likely in multiple places) and prevent waiting on the thread with the most populated cell to finish.

@rprospero
rprospero requested review from RobBuchananCompPhys and trisyoungs and removed request for trisyoungs September 24, 2026 14:59
@rprospero
rprospero force-pushed the dissolve2/bonding-with-cells branch 2 times, most recently from abc9ea5 to 4e2065a Compare October 6, 2026 10:47
Comment thread src/templates/algorithms.h Outdated
template <typename> constexpr bool is_optional = false;
template <typename T> constexpr bool is_optional<std::optional<T>> = true;

// View that statically cast

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment may require some clarification, not quite sure what it's meant to mean

@rprospero
rprospero force-pushed the dissolve2/bonding-with-cells branch from f23322d to 3aea339 Compare October 8, 2026 10:28
Comment thread src/nodes/calculateBonding.cpp Outdated

// Get StructureAtom 'i' and its radius
auto radiusI = AtomicRadii::radius(i->Z());
// Get StructureAtom 'j'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something missing here??

@RobBuchananCompPhys RobBuchananCompPhys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, though there are one or two code comments that could do with cleaning up/clarification.

@rprospero
rprospero force-pushed the dissolve2/bonding-with-cells branch from 3aea339 to 473e95b Compare October 12, 2026 09:05
@rprospero
rprospero merged commit e62bc24 into develop2 Oct 12, 2026
15 of 18 checks passed
@rprospero
rprospero deleted the dissolve2/bonding-with-cells branch October 12, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants