Skip to content

fix(input): broadcast parser errors before MPI exits - #8215

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
Stardust0831:fix/input-parser-mpi-exit
Oct 26, 2026
Merged

mohanchen merged 2 commits into
deepmodeling:developfrom
Stardust0831:fix/input-parser-mpi-exit

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

What's changed?

Legacy INPUT errors, including missing headers, unknown or repeated parameters, and file/stream failures, can exit on rank zero while other MPI ranks are waiting for a broadcast. The parser now returns the diagnostic to read_parameters, which broadcasts it before all ranks enter the error-exit path. Messages identify the input file, with manual links for parameter and syntax errors.

Linked Issue

Addresses the MPI parser follow-up in #8192, continuing #7719.

Unit Tests and/or Case Tests for my changes

Passed: eight four-process MPI cases (including coverage builds), 41 serial reader/item tests, 13 executable input checks, and serial/four-process Si SCF calculations.

The MPI regression driver uses the real reader and exit handler, confirms all four processes reach shutdown, and times out if they do not. Rebuilding it with the original parser reproduced the unknown-parameter timeout; the fixed parser passes. The EOF case repeats a scalar string parameter with no value or final newline; all four processes must reach shutdown.

Build and test commands

SERIAL_BUILD and MPI_BUILD are Release builds with MPI disabled/enabled respectively. Both use GCC 13.4, OpenMP enabled, LCAO/ELPA/FLOAT_FFTW disabled, and OMP_NUM_THREADS=1 at runtime. Executables report v3.11.0-beta11.

cmake --build "$SERIAL_BUILD" --target MODULE_IO_input_domain_reader \
  MODULE_IO_read_item_serial MODULE_IO_read_input_serial abacus_pw_omp -j 8
ctest --test-dir "$SERIAL_BUILD" -V \
  -R '^MODULE_IO_(input_domain_reader|read_item_serial|read_input_serial)$'

cmake --build "$MPI_BUILD" --target MODULE_IO_input_error_mpi abacus_pw_para -j 8
ctest --test-dir "$MPI_BUILD" -V -R '^MODULE_IO_input_error_mpi_'

"$SERIAL_BUILD/abacus_pw_omp" --version
"$SERIAL_BUILD/abacus_pw_omp" -h nspin
# From each prepared INPUT case directory:
"$SERIAL_BUILD/abacus_pw_omp" --check-input
mpirun -np 4 "$MPI_BUILD/abacus_pw_para"

Coverage verification reproduced undefined gcov symbols before the fix. With target-level add_coverage, the test executable links and all eight MPI cases pass using ENABLE_COVERAGE=ON, without global compiler/linker coverage flags. Shutdown markers are flushed before collective finalization so the launcher cannot discard a peer's marker on nonzero exit.

# COVERAGE_BUILD uses the same dependencies with ENABLE_COVERAGE=ON.
cmake --build "$COVERAGE_BUILD" --target MODULE_IO_input_error_mpi -j 8
ctest --test-dir "$COVERAGE_BUILD" -V -R '^MODULE_IO_input_error_mpi_'

Successful MPI --check-input has an existing finalization issue, so MPI executable checks use normal execution. The regression driver supplies collective MPI shutdown explicitly. Governance and whitespace checks passed.

Governance Notes

The developer guide documents the shared error path. The affected inputs were already invalid, so parameter metadata and defaults require no changes. The change is confined to input parsing and its tests; no calculation modules are modified. No exceptions requested.

No documentation update required for the coverage/EOF follow-up because it only changes test infrastructure and regression coverage.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Static review found one coverage-build issue. Candidate builds and tests were not run under the static-only scope.

Comment thread source/source_io/test/CMakeLists.txt
@Stardust0831 Stardust0831 added the Input&Output Suitable for coders without knowing too many DFT details label Oct 24, 2026
Comment thread source/source_io/module_parameter/read_input.cpp
@mohanchen
mohanchen merged commit 2513d97 into deepmodeling:develop Oct 26, 2026
19 checks passed
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Input&Output Suitable for coders without knowing too many DFT details Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants