Skip to content

Refactor Parallel_Grid::init into serial/parallel subroutines - #8111

Merged
mohanchen merged 1 commit into
developfrom
refactor-parallel-grid-init
Oct 10, 2026
Merged

mohanchen merged 1 commit into
developfrom
refactor-parallel-grid-init

Conversation

@MrLi000001

Copy link
Copy Markdown
Collaborator

Motivation The original Parallel_Grid::init used an in-function #ifndef __MPI ... return; guard, which effectively split the function into two halves. Readers had to infer that "the serial build stops here while the parallel build continues", violating clear control-flow and increasing maintenance burden.

Changes

Split the original init into two single-responsibility functions:
init_serial(...): assigns dimension members, validates nczp < 0, asserts sizes, and computes ncxy/ncxyz (shared by both builds).
init_parallel(nprocgroup): partitions processes across Pools by KPAR, allocates numz/startz/whichpro/whichpro_loc, and calls z_distribution().
The new init(...) orchestrates both: calls init_serial always, then init_parallel under #ifdef __MPI.
Removed the old init implementation and a now-stale comment, eliminating the mid-function #ifndef __MPI early return.
Added init_serial / init_parallel private declarations to the header.
Result

Logically equivalent; behavior is unchanged.
Serial vs. parallel code paths are now clearly separated, improving readability and maintainability.
Testing

Serial build (-DENABLE_MPI=OFF) passes
Parallel build (-DENABLE_MPI=ON) passes

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Agent Governance Check

Severity Rule Location Reason Suggested action Exception
warning PR metadata completeness pull_request.body missing sections: Linked Issue, Unit Tests and/or Case Tests for my changes, What's changed? Fill the PR template with issue linkage, test evidence, and a concise change summary. allowed
warning Test evidence review pull_request.body Source code changed without test path changes or PR test evidence. Add focused tests, update a relevant case, or document why tests are not required. allowed
warning Documentation sync review pull_request.body Source changes have no docs change or explicit no-docs-needed statement. Add documentation updates for behavior/interface changes, or state why documentation is not required. allowed

@MrLi000001
MrLi000001 force-pushed the refactor-parallel-grid-init branch from 980aa54 to 94c7126 Compare October 10, 2026 03:22
@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Oct 10, 2026
@mohanchen
mohanchen merged commit 21eb4a9 into develop Oct 10, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants