Skip to content

Refactor Parallel_Reduce: Replace manual gather-reduce with MPI_Allreduce#6922

Merged
mohanchen merged 13 commits intodeepmodeling:developfrom
A-006:gather1
Jan 29, 2026
Merged

Refactor Parallel_Reduce: Replace manual gather-reduce with MPI_Allreduce#6922
mohanchen merged 13 commits intodeepmodeling:developfrom
A-006:gather1

Conversation

@A-006
Copy link
Collaborator

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

Summary

This PR refactors the Parallel_Reduce class to use MPI_Allreduce directly for minimum and maximum operations, replacing the previous implementation that used MPI_Allgather followed by local reduction. This change simplifies the code, reduces memory overhead, and unifies the reduction interface.

Key Changes

  • Refactored Parallel_Reduce Implementation:

    • Replaced gather_min_int_all with reduce_min_int.
    • Replaced gather_max/min_double_all with reduce_max/min_double.
    • Replaced gather_max/min_double_pool with reduce_max/min_double_pool.
    • The new methods utilize MPI_Allreduce with MPI_MIN/MPI_MAX for better efficiency.
  • Updated Call Sites:

    • Updated all usages in source/source_estate/, source/source_pw/, source/source_lcao/, and other modules to match the new API.
    • Removed redundant #ifdef __MPI guards in caller functions, as the Parallel_Reduce wrappers now handle MPI conditional compilation internally.
  • Cleanup:

    • Adjusted unit tests in parallel_reduce_test.cpp.

Impact

  • Reduces code complexity.
  • Potentially improves performance for reduction operations by leveraging optimized MPI implementations.
  • Removes redundant MPI preprocessor directives from high-level code.

@A-006 A-006 marked this pull request as draft January 28, 2026 05:49
@A-006 A-006 marked this pull request as ready for review January 28, 2026 07:52
@mohanchen mohanchen added Refactor Refactor ABACUS codes GPU & DCU & HPC GPU and DCU and HPC related any issues labels Jan 29, 2026
@mohanchen mohanchen merged commit dda5fd5 into deepmodeling:develop Jan 29, 2026
14 checks passed
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