Repository navigation
feat(pw): expose the serial basis assembly as PW_Basis::init_serial - #8268
Zanthoxylum wants to merge 3 commits into
Conversation
The plain serial assembly chain (initgrids -> initparameters -> default FFT mode -> setuptransform -> collect_local_pw) was duplicated in every serial test scaffolding because the production wrappers setup_pwrho / setup_pwwfc bundle it with global parallel state (GlobalV::NPROC_IN_ POOL / RANK_IN_POOL / ofs_running), the full Input_para, K_Vectors and GPU branches -- unreachable from a serial unit test. Expose the chain as public PW_Basis::init_serial and PW_Basis_K::init_serial (FFT-box + k-list variant) so heavily-used test setup references the source API instead of mirroring it; the DFPT serial fixture's SetupBases shrinks to the two init_serial calls plus its (k, q) data wiring. The parallel production path is untouched. All DFPT serial test binaries rebuilt from deleted binaries; full MODULE_DFPT ctest 10/10 (the local 11_PW_GPU integration failure is a pre-existing no-CUDA environment issue, identical on the unmodified baseline).
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
The migrated fixture preserves its original basis initialization sequence. One API-contract clarification is below. Static review at 292c3d0; the reported build and runtime results were not independently verified.
|
|
||
| //Serial basis assembly: the plain production sequence (initgrids -> | ||
| //initparameters -> default FFT mode -> setuptransform -> collect_local_pw) | ||
| //without any parallel/device context (no initmpi, default distribution). |
There was a problem hiding this comment.
Non-blocking: Please state that the advertised no-initmpi use requires PW sources compiled without __MPI. Both initgrids overloads otherwise reach MPI_Allreduce with a fresh object's MPI_COMM_NULL; the migrated DFPT fixture avoids this by recompiling those sources with __MPI disabled.
There was a problem hiding this comment.
Done in 883b21d: both init_serial declarations (PW_Basis and
PW_Basis_K) now carry the requirement explicitly -- the no-initmpi use
requires the PW sources compiled without __MPI, because with __MPI the
initgrids overloads reduce over the object communicator, which is
MPI_COMM_NULL on a fresh basis that never called initmpi. The note also
points at the working pattern: the DFPT serial test targets compile the
PW sources with __MPI disabled (abacus_disable_feature_definitions),
which is exactly why the migrated fixture is safe. Comment-only change;
abacus_basic_para rebuilt clean (make rc=0).
…ction test tool
The DFPTSerialBase base class and its header are removed in favor of
dfpt_test_tool.{h,cpp} (the module_pw test/test_tool pattern): shared
declarations plus one implementation TU of free functions -- setup_cell,
make_coulomb_atom, make_nc_atom, make_two_atom_cell, make_nlcc_two_atom_
cell, setup_bases, vloc_coulomb, analytic_dvloc, fkey, gkey -- and the
shared test-world constants (lat0 / ecutwfc / rho_mult / cubic_edge).
Every test file now derives its own fixture directly from ::testing::Test,
owns its objects as members and calls the utilities it needs; there is no
shared fixture base class and no fixture header. The rho files keep their
file-local RNG. CMakeLists swaps dfpt_serial_fixture.cpp for
dfpt_test_tool.cpp in every target. setup_bases keeps the raw assembly
chains and adopts PW_Basis::init_serial once deepmodeling#8268 lands. All six serial
targets rebuilt from deleted binaries (make rc=0); case counts conserved
(pert 7 / phon 20 / rho 11 / q0 6 / xc 6 / write_dyn 6); full MODULE_DFPT
ctest 10/10.
Per review: the no-initmpi use advertised by init_serial requires the PW sources compiled without __MPI -- with __MPI the initgrids overloads reduce over the object communicator, which is MPI_COMM_NULL on a fresh basis. Both init_serial declarations now state this; the DFPT fixture works because its test targets compile the PW sources with __MPI disabled.
Summary
The plain serial basis assembly chain
was mirrored by every serial test scaffolding, because the production
wrappers
setup_pwrho/setup_pwwfcbundle it with global parallelstate (
GlobalV::NPROC_IN_POOL/RANK_IN_POOL,GlobalV::ofs_runninglogging), the full
Input_para,K_Vectors, and GPU/double-gridbranches — unreachable from a serial unit test. This PR exposes the
chain as a public source API so heavily-used test setup references the
source instead of duplicating it:
PW_Basis::init_serial(lat0, latvec, gridecut)(pw_basis.h /pw_init.cpp): the five-call sequence above, no parallel/device
context, default distribution.
PW_Basis_K::init_serial(lat0, latvec, nx, ny, nz, ecut, nk, kvec_d)(pw_basis_k.h / .cpp): the FFT-box + k-list variant, for a wfc basis
sharing the rho grid's box.
SetupBases— the single most-shared testhelper (every serial DFPT test file reaches it) — shrinks to the two
init_serialcalls plus its (k, q) data wiring.The parallel production path (
setup_pwrho/setup_pwwfc) isuntouched: it interleaves
initmpiand device/precision branchesbetween the same calls, so unifying it onto
init_serialis a separatedecision; this PR only removes the test-side mirror.
Scope and dependency on #8259
dfpt_serial_fixture.cpp'sSetupBasesis the single most-sharedtest helper (every serial DFPT test file reaches it) and the only
test-side file this PR touches. refactor(dfpt): split the oversized DFPT serial tests along the source boundaries #8259 rewrites the test
.cppfiles and their
CMakeLists.txtbut does not modify the fixture, sothe two PRs have zero file overlap and no merge-order constraint.
xc
make_basishelper and the rho/q0 local basis rebuilds) aredeliberately not converted here: those files are being rewritten
by refactor(dfpt): split the oversized DFPT serial tests along the source boundaries #8259, and touching them in parallel would produce avoidable
conflicts. They adopt
init_serialin a small follow-up once refactor(dfpt): split the oversized DFPT serial tests along the source boundaries #8259lands (whichever PR merges second simply rebases that adoption).
Verification
exit code 0 per target); full
MODULE_DFPTsuite 10/10 — thefixture output is byte-identical by construction (the chain is the
same five calls).
11_PW_GPUintegration failure is a pre-existing no-CUDAenvironment issue: verified identical on the unmodified baseline
(stash + rebuild + rerun).
Documentation
No docs change needed: additive internal API, no INPUT or user-facing
behavior change.