Performance: optimize module HS matrix output - #7838
Open
goodchong wants to merge 2 commits into
Open
Conversation
mohanchen
reviewed
Aug 19, 2026
|
|
||
| // The off-diagonal term in SOC calculaiton is zero, and the two diagonal terms are the same | ||
| int new_index | ||
| = iw1 - PARAM.globalv.npol * orb_index_row + (iw2 - PARAM.globalv.npol * orb_index_col) * PARAM.globalv.npol; |
Collaborator
There was a problem hiding this comment.
could you avoid using PARAM?
Collaborator
|
Could you explain more about what this PR does? |
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.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
Fix #
Unit Tests and/or Case Tests for my changes
What's changed?
• This PR improves the performance of source_io/module_hs without changing the user-facing matrix formats.
Replaces row-by-row dense MPI reductions for sparse R-space matrices with sparse entry gathering. Communication
changes from approximately O(N²) to O(nnz) per R block.
Builds CSR values, column indices, and row pointers directly in memory, eliminating temporary index files.
Merges duplicate distributed entries before applying the sparse threshold.
Iterates only over locally owned rows and columns when calculating r(R), avoiding global nlocal² traversal on every
MPI rank.
Batches dense H(k)/S(k)/Vxc matrix reductions in groups of 64 rows and removes the redundant per-row MPI barrier.
Pre-indexes HContainer atom-pair R blocks, avoiding repeated scans of every atom pair for each lattice vector while
keeping memory bounded to one materialized R block.
Adds an optional Google Benchmark for sparse single-R CSR output at different matrix sizes.
Preserves existing text and native binary output ordering and formats.
Governance Notes