Skip to content

Refactor: remove dead cross module includes#7574

Merged
mohanchen merged 7 commits into
deepmodeling:developfrom
Critsium-xy:refactor/remove-dead-cross-module-includes
Jul 2, 2026
Merged

Refactor: remove dead cross module includes#7574
mohanchen merged 7 commits into
deepmodeling:developfrom
Critsium-xy:refactor/remove-dead-cross-module-includes

Conversation

@Critsium-xy

@Critsium-xy Critsium-xy commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

I'm scanning all useless headers and remove them. This is a easy step to remove some dependencies.

Critsium-xy and others added 5 commits July 1, 2026 13:28
Drop two dead includes that create needless reverse dependencies from
source_cell onto higher layers:
  - source_estate/read_orb.h  (elecstate::read_orb_file not used here;
    the real user is read_atoms_helper.cpp)
  - source_basis/module_ao/ORB_read.h  (ORB / LCAO_Orbitals not used here)

Verified by compiling the `cell` target with ENABLE_LCAO=ON so the
former `#ifdef __LCAO` block was actually exercised.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Static scan + per-target compile verification identified 9 unused
includes that create reverse/lateral dependency edges between modules.
Removing them weakens the coupling without any behavior change:

  io   -> md    input_conv.cpp        (md_func.h)
  estate -> lcao  elecstate_energy_terms.cpp, elecstate_print.cpp
                                       (module_deepks/LCAO_deepks.h)
  lcao -> pw    rdmft_tools.cpp (structure_factor.h),
                wavefunc_in_pw.cpp (soc.h)
  lcao -> io    FORCE_gamma.cpp, FORCE_k.cpp (module_hs/write_HS.h)
  pw   -> io    forces_cc.cpp, forces_scc.cpp (module_output/output_log.h)

Verified by building io_basic, elecstate, rdmft, hamilt_lcao and
module_pwdft (ENABLE_LCAO=ON) after removal; all link targets compile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Remove unused source_io includes across the esolver drivers. These are
on the allowed esolver->io direction, so this is include hygiene rather
than decoupling, but it trims 29 needless includes.

Verified three ways:
  1. `make esolver` (ENABLE_LCAO=ON) recompiles all 21 TUs, 0 errors.
  2. Feature-guarded headers checked explicitly since __RAPIDJSON,
     __EXX/__LIBRI and __MLALGO are OFF in this build: the json
     (init_info.h/output_info.h) and restart_exx_csr.h symbols are
     unused in their consumers (Json::add_output_scf_mag in
     esolver_ks.cpp comes from output_info.h, which is kept).
  3. Whole-file precise-symbol sweep (incl. all #ifdef blocks) finds
     no specific symbol of any removed header in its consumer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two dead includes missed by the first reverse-edge pass:

  estate -> lcao   elecstate_energy_terms.cpp
                   (module_deltaspin/spin_constrain.h; SpinConstrain
                   is not referenced anywhere in the file)
  esolver -> io    esolver_double_xc.cpp
                   (module_hs/write_HS.h; only a comment mentions
                   ModuleIO::write_hsk(), no actual call)

Verified: no header symbol appears anywhere in the consumer (guards
included), and `make elecstate` / `make esolver` build cleanly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Critsium-xy Critsium-xy marked this pull request as ready for review July 2, 2026 02:05
@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Jul 2, 2026
@mohanchen mohanchen merged commit 4fa13e1 into deepmodeling:develop Jul 2, 2026
16 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