Optimize GintAtom::set_phi() in module_gint#7530
Open
chaomianpkp wants to merge 2 commits into
Open
Conversation
…ional SIMD - Extract set_phi_at_meshgrid() for single meshgrid computation - Cache norm once, use inv_dist, hoist rcut/nw/nwl out of the loop - Add optional GINT_SET_PHI_SIMD and GINT_SET_PHI_OPENMP CMake options - Use SIMD-compatible for-loop form (no comma increment in omp simd)
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.
Summary
Optimize
GintAtom::set_phi()inmodule_gint, which is a hotspot on thecal_gint_rho/cal_gint_vlpath in LCAO grid integration.Changes:
set_phi_at_meshgrid()coord.norm()once,use
inv_distinstead of repeated divisions, cachercut/nw/nwl/dr_uniformGINT_SET_PHI_SIMD,GINT_SET_PHI_OPENMP(nested OpenMP in SCF is intentionally disabled when already inside a parallel region)
Motivation
set_phi()is called for every atom on every fine meshgrid inside each BigGrid.The original implementation repeated norm/division and loop-invariant lookups.
Test plan
ENABLE_MPI=OFF,USE_OPENMP=ON,ENABLE_LCAO=ON-DGINT_SET_PHI_SIMD=ONctest -R gint(if BUILD_TESTING=ON)tests/performance/P110_C2H6O_lcao(ethanol + vacuum box)etot/ stress unchanged within floating-point tolerance (~1e-10)cal_gint_vl: 5.70s → 1.86s (~3.1×)cal_gint_rho: 5.29s → 1.53s (~3.5×)#pragma omp simdon theiwloop shows no measurable gain on tested platformNotes
GINT_SET_PHI_OPENMPis for non-nested contexts only; normal SCF uses micro-opts only.