You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scope: 9 files changed, +304 -6 lines.
Build: cmake --build build exit=0, abacus_basic_para linked successfully.
Test suite (all run with OMP_NUM_THREADS=1 mpirun -np 4):
- MODULE_BASE_ProcessTopology : 8 / 8 passed
(5 divide_mpi_groups arithmetic cases
+ 2 synthetic ProcessTopology accessor cases
+ 1 MPI-global integration case
ParallelGlobalCreateTopology.FourRanksKpar2Bndpar2DiagNp2
covering every scalar field, the 6 legacy-global comm sizes
and matrix/atom == MPI_COMM_NULL).
- MODULE_BASE_ParaReduce : 10 / 10 passed
- MODULE_BASE_ParaGlobal : 6 / 6 passed
- MODULE_BASE_ParaCommon : 1 / 1 passed
1. Error-path fix in divide_mpi_groups:
The even=true branch used to `exit(1)` on an uneven split, which
bypassed ABACUS' WARNING_QUIT machinery (no stack cleanup, no
consistent formatting). Replaced with
ModuleBase::WARNING_QUIT("...Even partition requested...") so all
failure paths now share the same error sink. No call-site change.
2. New Parallel_Global::create_topology(world, my_rank, kpar, bndpar,
diag_np, grid_np):
- Declared in parallel_global.h together with a detailed docstring
explaining the kpar -> pool -> band-group layering, the legacy
communicator aliases and the "caller later fills matrix / atom
domains" injection contract.
- Implemented in parallel_global.cpp under the same TU that owns
divide_pools so we reuse every existing MPI_Comm_split /
MPICommGroup::divide_group_comm helper rather than re-implement
the partition.
- non-__MPI builds return the trivial single-process
ProcessTopology() instead of linking MPI code.
- Snapshot construction:
* nproc_in_pool vector is built with the even=false partition
rule directly (base = world/kpar; first `extra_procs` groups
get base+1). No MPI calls, O(kpar) only.
* Legacy divide_pools(...) is called first -> fills POOL_WORLD
/ KP_WORLD / INT_BGROUP / BP_WORLD scalars and ints.
* split_diag_world / split_grid_world(diag_np) are called
immediately afterwards, folding the "two subroutines that
real drivers have always called after divide_pools" step
into a single factory so callers cannot forget to build
rgrid/diag views. diag_np==0 safely falls back to diag_np=1.
* Scalars (kpar/my_pool/rank_in_pool / band group triple) and
all 6 legacy-global MPI_Comm handles plus MPI_COMM_NULL for
matrix/atom are then forwarded to the ProcessTopology full
constructor once.
- Compatibility: after create_topology returns, the 6 extern
MPI_Comm globals (POOL_WORLD..DIAG_WORLD) are still valid and
hold exactly the same handles as before because they were the
ones copied into the topology. No existing call site has to
change today. The migration plan remains: new code takes a
const ProcessTopology&; legacy code keeps reading the aliases.
3. Unit tests added to parallel_topology_test.cpp:
- The file now provides its own main(argc, argv) that calls
MPI_Init / MPI_Finalize around RUN_ALL_TESTS so gtest-based
processes never issue MPI calls before MPI_Init (the error that
surfaced while wiring the integration case).
- Integration case ParallelGlobalCreateTopology.FourRanksKpar2Bndpar2DiagNp2:
* GTEST_SKIP() if nproc != 4.
* Asserts scalar invariants for every rank (world_size, kpar,
bndpar, nproc_in_pool vector, pool_root_rank,
band_group_root_rank).
* Per-rank scalar expectations are laid out in a comment table
R0..R3 that was cross-validated against the real factory
output during development.
* Asserts MPI_Comm_size/rank for all 6 derived legacy
communicators plus matrix/atom == MPI_COMM_NULL.
- Both synthetic ProcessTopology cases are untouched.
4. Hand-written SOURCES lists wired parallel_topology.cpp:
create_topology lives in parallel_global.cpp and constructs a
ProcessTopology, pulling the class' constructor symbol. Many unit
test and module CMakeLists already enumerate parallel_global.cpp
by hand and therefore need to also name parallel_topology.cpp as
a local TU. The following targets were updated:
- MODULE_BASE_ParaCommon / ParaGlobal / ParaReduce (the 3
parallel unit tests that mirror ParaTopology).
- MODULE_PW_pwdft tests (source_pw/module_pwdft/test).
- MODULE_MD_func (source_md/test).
- MODULE_IO_* (source_io/test).
- MODULE_PW_PW_Kernels_UTs (module_pw/kernels/test).
- MODULE_CELL_ParaKpoints (source_cell/test).
This is exactly the same repair we had to apply for ParaCommon in
Step 0. AGENTS rule: "Keep source file additions deterministic;
update the relevant CMakeLists.txt" – satisfied.
Governance notes (agent_governance_check --staged):
- WARNING Header dependency (parallel_global.h:10 includes
parallel_topology.h): Required because create_topology returns
ProcessTopology by-value, which requires the complete class
declaration in every TU that includes parallel_global.h.
parallel_topology.h only brings in <vector> and <mpi.h>, so no
parallel_comm.h 6-comm transitive leakage is reintroduced.
Exception allowed = yes.
- WARNING Documentation sync: 0 user-facing INPUT / CLI / external
API change. Factory is not yet called from production code.
Exception allowed = yes.
- GlobalV / PARAM / GlobalC: 0 new reads. The factory only
receives its inputs by-value from callers and constructs the
topology object; it never reaches into PARAM. AGENTS rule 1
budget strictly non-increasing.
- AGENTS rule 5 (no new default args on existing interfaces):
create_topology is a brand-new free function, so the 6-int + 8-MPI_Comm
ProcessTopology constructor default-args for matrix_world / atom_world
(introduced in step 1a) still apply, but we did not add defaults
to an existing signature.
- C++11 compatible. One variable per declaration. No new direct
MPI calls outside the __MPI guarded factories.
0 commit comments