Skip to content

P3M: shifted Green's function for the truncated solver, adjustable overlap cutoff, overlap-layout fixes - #611

Merged
aaadelmann merged 10 commits into
masterfrom
610-implement-shifted-greens-function-overwrite-for-p3m
Oct 14, 2026
Merged

aaadelmann merged 10 commits into
masterfrom
610-implement-shifted-greens-function-overwrite-for-p3m

Conversation

@aliemen

@aliemen aliemen commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

closes #610

This RP was intended to implement a shifted Green's implementation such that we can run simulation with source planes and P3M in OPALX. The main idea is that the "image" solve is performed with a normal shifted Green's kernel. PP interaction in the images are ignored, since they are (this is an approximation) more than RCUT away from the source plane.

Apart from that, I also found a few optimizations and smaller fixes that help with using P3M on bigger problems.

Changes

  • FFTOpenPoissonSolver::shiftedGreensFunction now accepts TRUNCATED. It still uses the Green's function without the erf factor, but the distinction is necessary to optimize Green's rebuilds. Then P3M can use FFTTruncatedGreenPeriodicPoissonSolver::shiftedGreensFunction(shift), which delegates to the open solver.
  • You can now change $\alpha$ (a factor in the truncated Green's function depending on RCUT) between runs. That allows for "adaptive cutoff radii", which is necessary if we want to define RCUT with $h$. Everything in the layout is regenerated when $\alpha$ changes.
  • ParticleSpatialOverlapLayout gets a few helper methods to change $\alpha$ and register its change.
  • The number of local cells is now capped at max(16 N, 2^24) where N is the number of local plus ghost particles after exchange (this is necessary to not run into "exceeds INT_MAX" errors. If it runs into this cap, the cells are simply widened to reduce the number of cells necessary (which can increase PP count, but at least the program doesn't crash). This does not influence the set of interacting particle pairs.
  • Bugs:
    • particleRanks is now constructed with an explicit extent of 0. Kokkos 5.2.0 treated the missing extent as a huge one, which caused illegal memory accesses on GPU.
    • In the non-neighbor rank scan, outsideCounts is now indexed by i (the position in outsideIds) instead of by the particle ID.
    • createPeriodicGhostParticles now re-reads the position view after the copy, because the copy may have reallocated it.
    • ParticleAttrib::internalCopy, used for periodic ghosts, had three problems: it copied the first particles instead of the boundary particles (view(i) instead of view(indices(i))), it grew the views destructively (dropping all attribute data), and it took the view before the views grew. All fixed now.
  • Some smaller timer location/naming and assertion fixes/additions.

Testing

I ran OPALX against this branch on up to 8 GH200 nodes just fine. This branch also works fine with OPALX master (even though some adjustments are needed to use these new features). Also added some more unit tests that should check more edge cases.

There is still a bug with periodic ghost particles in the PP interaction, which has already existed in master before. I will make a separate issue and fix it at a different time. It's not critical, since we want to use open P3M anyways.

…ide P3M's truncated Greens solver for approximate Dirichlet BCs
…ce clear error when number of cell counts exceeds the maximum
…or PP interaction. This optimization can use larger cells optimizing memory in sparse regions A LOT. Edge cases can have slightly worse performance, but at least no random seg-fault
…nd periodic Ewald kernels whenever alpha changes, so updating alpha between solves moves the P3M split.
…he boundary ones and losing all attribute data when the views grow, with a regression scenario.
…or a cutoff-aware updateLayout that rebuilds halos and cells, and report cutoffs exceeding half a rank region with a descriptive exception.
…out and solver each have their own. Properly set a cellsOutdated_m flag on layout change
@aliemen
aliemen requested a review from aaadelmann October 14, 2026 10:29
@aliemen aliemen self-assigned this Oct 14, 2026
@aliemen aliemen added bug Something isn't working enhancement New feature or request labels Oct 14, 2026
@aliemen aliemen linked an issue Oct 14, 2026 that may be closed by this pull request
@aliemen
aliemen requested a balanced review from Copilot October 14, 2026 10:29

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/Interaction/TruncatedGreenParticleInteraction.hpp Outdated
@aaadelmann
aaadelmann self-requested a review October 14, 2026 12:11
@aliemen

aliemen commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Tests look good. But still, I cannot merge myself until the CI notification is fixed.

@aaadelmann
aaadelmann merged commit 3dd06c2 into master Oct 14, 2026
3 checks passed
@aaadelmann
aaadelmann deleted the 610-implement-shifted-greens-function-overwrite-for-p3m branch October 14, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cleanup enhancement New feature or request gitlab-mirror

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement shifted Green's function overwrite for P3M algorithm

3 participants