Skip to content

Conversation

@A-006
Copy link
Collaborator

@A-006 A-006 commented Jan 9, 2026

Description

This PR addresses the logic for handling and reporting k-point specific plane wave counts (ngk) in the ModuleIO::write_eig_iter and ModuleIO::write_eig_file functions. It ensures that plane wave basis sizes are correctly aggregated across MPI ranks and accurately reported in the output logs.

Technical Breakdown & Conclusions

  • $nks$ vs $ngk$:
    • $nks$: Represents the number of symmetry-reduced k-points assigned to the local pool (current group of processors).
    • $ngk$: A std::vector<int> registry. Each element ngk[ik] stores the number of plane waves (G-vectors) used for the $ik$-th k-point (i.e., the basis set dimension).
  • Parallel Logic:
    • During parallel execution, kv.ngk is resized to match the local pool size (nks). This explains why the size might appear small (e.g., size 2 for 2 k-points).
    • Since G-vectors for a single k-point are distributed across ranks within a pool, an MPI_Allreduce with SUM over POOL_WORLD is required to obtain the total physical basis size for each k-point.

Changes

  • Corrected Basis Summation: Implemented MPI_Allreduce to aggregate ngk counts across ranks in the same pool, ensuring the output reports the true total number of plane waves per k-point.
  • Refined Multi-Pool Collection: Updated the logic where Global Rank 0 gathers eigenvalues (ekb) and occupations (wg) from other pools to prevent output race conditions.
  • Cleanup: Removed redundant debug std::cout statements regarding ngk sizes while maintaining improved logging formats.

Verification (Commit: 80281a5)

  • Test Case: 009_Li27Ni9O54Mn9Co9 (PW basis).
  • Environment: 28-process MPI run with KPAR enabled.
  • Result: Verified that even when nks is small, the plane wave counts are correctly calculated and stored, with the final output reflecting the full physical basis set assigned to those k-points.

@A-006 A-006 marked this pull request as draft January 9, 2026 03:50
@A-006 A-006 marked this pull request as ready for review January 10, 2026 02:10
const int nks = kv.get_nks();
const int nkstot = kv.get_nkstot();

std::vector<int> ngk_tot = kv.ngk;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this line be deleted?

ModuleBase::WARNING_QUIT("ModuleIO::write_eig_file", "Eigenvalues are too large!");
}

std::vector<int> ngk_tot = kv.ngk;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this line be deleted?

@mohanchen mohanchen added Refactor Refactor ABACUS codes GPU & DCU & HPC GPU and DCU and HPC related any issues labels Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants