Skip to content

Accelerate Ewald calculation - #244

Merged
awvwgk merged 5 commits into
dftd3:mainfrom
Growl1234:ewald
Oct 21, 2026
Merged

awvwgk merged 5 commits into
dftd3:mainfrom
Growl1234:ewald

Conversation

@Growl1234

@Growl1234 Growl1234 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
  • Prepare kernel constants once, skip unused C6 and ATM work, remove unused buffers, and move repeated calculations out of inner loops.
  • Support radix-2/3 FFT meshes to avoid excessive padding, and reuse kernel values for opposite wave vectors while handling Nyquist planes correctly.
  • Combine symmetric pole contributions and streamline mesh initialization and contraction.

For the supplied 576-atom cell with OMP_NUM_THREADS=24 ./s-dftd3 1.xyz --zero pbe --grad --ewald, wall time has decreased from 96.536 s to 2.726 s.

@Growl1234
Growl1234 force-pushed the ewald branch 3 times, most recently from ef03af8 to ef76de1 Compare October 21, 2026 14:15
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.90805% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.45%. Comparing base (6a0bb18) to head (9142b51).

Files with missing lines Patch % Lines
src/dftd3/fourier/kernel.f90 69.56% 1 Missing and 6 partials ⚠️
src/dftd3/disp.f90 70.00% 0 Missing and 3 partials ⚠️
src/dftd3/fourier/fft.f90 95.34% 0 Missing and 2 partials ⚠️
src/dftd3/fourier/ewald.f90 50.00% 0 Missing and 1 partial ⚠️
src/dftd3/fourier/spme.f90 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #244      +/-   ##
==========================================
+ Coverage   63.43%   63.45%   +0.02%     
==========================================
  Files          47       47              
  Lines        6831     6855      +24     
  Branches     2422     2438      +16     
==========================================
+ Hits         4333     4350      +17     
- Misses       1190     1191       +1     
- Partials     1308     1314       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

GitHub has started updating `ubuntu-latest` to 26.04 but not yet done...

@awvwgk awvwgk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, looks good to me

@Growl1234

Growl1234 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Side note:

  • With radix-2/3 FFT support, --ewald-mesh now rounds up to the smallest size of the form $(2^a)(3^b)$, instead of the next power of two. For example, --ewald-mesh 288 now uses $288^3$ rather than $512^3$, so identical command-line settings may produce different actual meshes.
  • Runtime is substantially lower even at a fixed $512^3$ mesh (--ewald-mesh 512; now about 19~20s), thanks to kernel precomputation, symmetry reuse, the revised FFT implementation, and fewer redundant mesh writes.

Now this PR should be ready. There maybe follow-up work worth considering, but I don't expect it to bring significant performance improvement.

@awvwgk
awvwgk merged commit 12f36be into dftd3:main Oct 21, 2026
38 checks passed
@Growl1234
Growl1234 deleted the ewald branch October 21, 2026 17:30
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.

2 participants