Skip to content

Problem 2 of Final Assignment for Parallel Programming: Parallel Optimization of Eigenvalue Solution via Iterative Methods#7492

Open
L12345j wants to merge 22 commits into
deepmodeling:developfrom
L12345j:develop
Open

Problem 2 of Final Assignment for Parallel Programming: Parallel Optimization of Eigenvalue Solution via Iterative Methods#7492
L12345j wants to merge 22 commits into
deepmodeling:developfrom
L12345j:develop

Conversation

@L12345j

@L12345j L12345j commented Jun 19, 2026

Copy link
Copy Markdown

This PR adds a PPCG eigensolver implementation for the HSolver module and extends the related unit tests.

Main changes:

  • Add a PPCG eigensolver based on a block preconditioned conjugate-gradient style subspace method.
  • Integrate PPCG into the plane-wave HSolver path with diago_method = ppcg.
  • Add numerical stability handling for small or nearly full-rank subspaces.
  • Extend PPCG tests with LAPACK reference checks, small-matrix edge cases, and comparisons with existing solvers.
  • Add BPCG kernel tests, including OpenMP thread-consistency checks.
  • Add a helper script/target for generating HSolver unit test reports.

Testing:

  • MODULE_HSOLVER_ppcg
  • MODULE_HSOLVER_bpcg

Notes:

  • The BPCG/OpenMP-related part is mainly for correctness and thread-consistency validation.
  • No stable end-to-end performance speedup is claimed for the BPCG OpenMP changes.

Copilot AI review requested due to automatic review settings June 19, 2026 12:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new PPCG (Projected Preconditioned Conjugate Gradient) block eigensolver into the HSolver (plane-wave) path and expands HSolver unit tests, including additional BPCG kernel correctness/thread-consistency checks and a helper to generate test reports.

Changes:

  • Add DiagoPPCG implementation and integrate it into HSolverPW via diago_method = ppcg.
  • Extend HSolver unit tests with PPCG/BPCG validation against LAPACK and add BPCG kernel tests (incl. OpenMP consistency).
  • Add a CMake custom target + script to generate HSolver unit test reports.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
source/source_hsolver/diago_ppcg.h Declares the PPCG solver API and internal workspace/state.
source/source_hsolver/diago_ppcg.cpp Implements PPCG iteration, subspace projection, and orthonormalization.
source/source_hsolver/hsolver_pw.cpp Adds ppcg as a selectable diagonalization method in PW HSolver.
source/source_hsolver/kernels/bpcg_kernel_op.cpp Adds OpenMP thresholds/guards and refactors some kernels for thread-safe reductions.
source/source_hsolver/test/diago_ppcg_test.cpp Adds PPCG unit tests, LAPACK comparisons, and consistency checks.
source/source_hsolver/test/diago_bpcg_test.cpp Extends BPCG tests, fixes indexing, adds kernel tests and OpenMP consistency checks.
source/source_hsolver/test/CMakeLists.txt Adds PPCG test target, copies test assets into build dir, adds report target.
source/source_hsolver/test/generate_hsolver_test_report.sh Adds helper script to run HSolver unit tests and write logs/JUnit XML.
source/source_hsolver/CMakeLists.txt Adds diago_ppcg.cpp to HSolver build objects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/source_hsolver/diago_ppcg.cpp Outdated
Comment on lines +162 to +167
// Cholesky: gram = U^H U (upper), then invert U in-place -> gram holds inv(U) in upper triangle
int info = 0;
lapackConnector::potrf('U', ncols, gram.data<T>(), ncols, info);
assert(info == 0);
lapackConnector::trtri('U', 'N', ncols, gram.data<T>(), ncols, info);
assert(info == 0);
Comment thread source/source_hsolver/diago_ppcg.cpp Outdated
Comment on lines +8 to +11
#include "source_hsolver/kernels/bpcg_kernel_op.h" // reuse normalize_op / apply_eigenvalues_op / precondition_op

#include "source_base/module_container/base/third_party/lapack.h"

Comment on lines +45 to +47
ctest --test-dir "$build_dir" -V -R "$test_regex" --output-junit "$xml_file" 2>&1 | tee "$log_file"
status=${PIPESTATUS[0]}

Comment on lines +562 to +563
TEST(DiagoPPCGTest, ComprehensiveBenchmark)
{
Comment on lines +386 to +393
std::string filename = "H-KPoints-Si2.dat";
ifs.open(filename);
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hm);
Comment thread source/source_hsolver/diago_ppcg.cpp Outdated

namespace hsolver {

namespace lapackConnector = container::lapackConnector;
@mohanchen mohanchen changed the title 并行程序设计期末大作业第二题:迭代法求解特征值的并行优化 Problem 2 of Final Assignment for Parallel Programming: Parallel Optimization of Eigenvalue Solution via Iterative Methods Jun 19, 2026
@mohanchen mohanchen added project_learning Diago Issues related to diagonalizaiton methods labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Diago Issues related to diagonalizaiton methods project_learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants