Skip to content

Refactor: move EXX file-list broadcast out of source_cell (#7635)#7663

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-bcast-exx-7635
Jul 21, 2026
Merged

Refactor: move EXX file-list broadcast out of source_cell (#7635)#7663
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-bcast-exx-7635

Conversation

@Critsium-xy

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

Copy link
Copy Markdown
Collaborator

Background

Fixes #7635.

source_cell is a data-structure layer that should not depend on a higher layer. bcast_cell.cpp violated this by reaching into GlobalC::exx_info (owned by source_hamilt/module_xc) to broadcast the ABFS/JLE orbital-file lists:

#include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info
...
bcast_string_vector(GlobalC::exx_info.info_ri.files_abfs);
bcast_string_vector(GlobalC::exx_info.info_opt_abfs.files_abfs);
bcast_string_vector(GlobalC::exx_info.info_opt_abfs.files_jles);

Data lifecycle

These lists live in GlobalC::exx_info and flow:

  1. Populate (rank 0): source_cell/read_atom_species.cpp parses ABFS_ORBITAL / ABFS_JLES_ORBITAL from STRU during setup_cell.
  2. Broadcast (all ranks): previously in bcast_cell.cpp — the coupling this PR removes.
  3. Consume: the LCAO EXX/RI code — Exx_LRI (RI-EXX), Exx_Opt_Orb::generate_matrix (opt-ABFs), RPA_LRI::postSCF (RPA).

Change

The ABFS/JLE orbital files are an LCAO-only concept, so the broadcast belongs with the LCAO EXX manager, not in source_cell or the generic XC module:

  • Add bcast_exx_file_lists() in source_lcao/setup_exx.{h,cpp}.
  • Invoke it at the start of Exx_NAO::init(), before Exx_LRI copies info_ri.
  • Remove the exx_info.h include, the bcast_string_vector helper, and the three broadcast calls from bcast_cell.cpp.

Exx_NAO::init() is called from ESolver_KS_LCAO::before_all_runners — reused by TDDFT / DM2rho / DoubleXC (they call the base), while LR reuses the already-built Exx_LRI via move_exx_lri. It runs on all ranks, after setup_cell populated the lists on rank 0 (driver calls setup_cell before before_all_runners), and before every consumer:

  • RI-EXX: the Exx_LRI copy of info_ri happens right after the broadcast inside init().
  • opt-ABFs: generate_matrix runs later in the same before_all_runners.
  • RPA: RPA_LRI(GlobalC::exx_info.info_ri) is built in ctrl_scf_lcao during the SCF run, after before_all_runners.

After this, bcast_cell.cpp no longer depends on any higher layer.

Behaviour

Preserved. The broadcast still runs after the rank-0 populate and before any EXX consumption. The previous per-ionic-step re-broadcast (via bcast_unitcell in update_cell.cpp during relax/MD) is dropped, which is behaviour-neutral because the file lists are static once read from STRU.

Because __EXX implies __LCAO (LibRI requires ENABLE_LCAO), setup_exx.cpp is always built whenever the broadcast is compiled.

Verification

  • Repo-wide grep confirms bcast_cell.cpp has no remaining exx/GlobalC reference; the only remaining exx_info user in source_cell is read_atom_species.cpp (write side — see note).
  • g++ -std=c++14 -fsyntax-only passes on the broadcast function body compiled against the real exx_info structs (MPI headers stubbed locally). setup_exx.cpp itself pulls LibRI/cereal and so is exercised by CI rather than locally.

Note (out of scope)

The write sidesource_cell/read_atom_species.cpp parsing the ABFS STRU sections into GlobalC::exx_info — still couples source_cell to the XC layer. #7635 is specifically about the broadcast in bcast_cell.cpp; moving the ABFS STRU-section parsing out of source_cell is larger and best handled as a follow-up.

Global dependency budget (governance)

This PR is migration-neutral for the GlobalV::/GlobalC::/PARAM budget: the three GlobalC::exx_info broadcast calls are moved from bcast_cell.cpp to setup_exx.cpp (-3/+3, net zero in code), and source_cell is fully decoupled from the XC layer. No new global-state coupling is introduced.

@Critsium-xy
Critsium-xy force-pushed the decouple/source_cell-bcast-exx-7635 branch from d99198f to 6b51394 Compare July 21, 2026 07:00
…ng#7635)

bcast_cell.cpp reached into GlobalC::exx_info (source_hamilt/module_xc) to
broadcast the ABFS/JLE orbital-file lists, making the source_cell
data-structure layer depend on a higher layer.

The ABFS/JLE orbital files are an LCAO-only concept, so the broadcast is
placed in the LCAO EXX manager: add bcast_exx_file_lists() in
source_lcao/setup_exx.{h,cpp} and invoke it at the start of Exx_NAO::init(),
before Exx_LRI copies info_ri. init() runs in ESolver_KS_LCAO::before_all_runners
(reused by TDDFT/DM2rho/DoubleXC; LR reuses the moved Exx_LRI), on all ranks,
after setup_cell has populated the lists on rank 0 and before every consumer
(RI-EXX, opt-ABFs generate_matrix, RPA postSCF).

This removes the exx_info.h include, the helper, and the three broadcast
calls from bcast_cell.cpp. The per-ionic-step re-broadcast previously done
via bcast_unitcell is dropped, which is behaviour-neutral: the file lists
are static once read from STRU.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Critsium-xy
Critsium-xy force-pushed the decouple/source_cell-bcast-exx-7635 branch from 6b51394 to 2c79471 Compare July 21, 2026 08:01
@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Jul 21, 2026
@mohanchen
mohanchen merged commit 83e5099 into deepmodeling:develop Jul 21, 2026
18 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 The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[source_cell] bcast_cell.cpp relies on source_hamilt/module_xc/exx_info.h

2 participants