Refactor(io): modularize sparse matrix writer interface#7468
Open
goodchong wants to merge 9 commits into
Open
Conversation
Add a Phase 0 compatibility test suite for write_HS_R-related output contracts and save the refactor plan. Tests: ctest --test-dir build-phase0 -R MODULE_IO_write_hs_r_compat_test -V
Fix sparse binary header writing, non-MPI save_mat stream opening, Vxc(R) ownership, and AngularMomentumCalculator null logging. Extend write_HS_R compatibility coverage for legacy binary sparse headers and update the refactor plan with Phase 1 status. Tests: ctest --test-dir build-phase0 -R MODULE_IO_write_hs_r_compat_test -V Tests: ctest --test-dir build-phase0 -R MODULE_IO_cal_pLpR_test -V Tests: ctest --test-dir build-phase0 -R MODULE_IO_single_R_test -V Tests: ctest --test-dir build-phase0 -R MODULE_IO_sparse_matrix_test -V Builds: cmake --build build-phase0 --target io_advanced -j8 Builds: cmake -B build-phase1-nompi -DBUILD_TESTING=OFF -DENABLE_MPI=OFF && cmake --build build-phase1-nompi --target io_advanced -j8
Keep the local markdown file untracked while removing it from the remote branch contents.
This reverts commit fa0347e.
This reverts commit 644fdd9.
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
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
This PR refactors the sparse CSR writer interface in ModuleIO.
Summary:
Redesigns ModuleIO::save_sparse to use a structured SparseWriteOptions object instead of a long parameter list.
Adds type aliases for sparse real-space matrix data:RCoordinate
SparseRBlock
SparseRMatrix
Updates save_sparse and output_single_R so matrix dimensions are derived from Parallel_Orbitals::get_global_row_size() instead of PARAM.globalv.nlocal.
Refactors save_sparse internals into smaller helper routines for:counting nonzero entries by R
counting output R vectors
opening output files
writing CSR headers
writing R records
Updates output_single_R to use the same SparseWriteOptions context, including threshold, binary mode, reduce mode, and temporary file directory.
Updates all affected call sites, including:write_HS_R.cpp
write_vxc_r.hpp
restart_exx_csr.hpp
cal_r_overlap_R.cpp
Fixes the EXX restart CSR path so it no longer passes a default-constructed Parallel_Orbitals; it now initializes a serial Parallel_Orbitals with the correct matrix dimension before writing.
Updates tests to verify that CSR output uses the dimension from pv, not the global nlocal.
Tests run:
git diff --check
cmake --build build-phase0 --target MODULE_IO_single_R_test -j8
cmake --build build-phase0 --target MODULE_IO_write_hs_r_compat_test -j8
ctest --test-dir build-phase0 -R MODULE_IO_write_hs_r_compat_test -V
ctest --test-dir build-phase0 -R MODULE_IO_single_R_test -V
cmake --build build-phase0 --target io_advanced -j8
cmake --build build-phase1-nompi --target io_advanced -j8
Any changes of core modules? (ignore if not applicable)