From 51f75ffd4463980d7f81c2e47340a625546fc80d Mon Sep 17 00:00:00 2001 From: Critsium-xy Date: Wed, 8 Jul 2026 16:14:40 +0800 Subject: [PATCH] Refactor: drop source_cell dependency on serialization_cereal (cell->lcao) bcast_cell.cpp included source_lcao/module_ri/serialization_cereal.h only to call ModuleBase::bcast_data_cereal on three ABFS file-name lists, all of which are plain std::vector. This created a reverse dependency from source_cell (L1) on source_lcao (L5). Replace the cereal-based broadcast with a small local bcast_string_vector helper built on Parallel_Common::bcast_int/bcast_string, mirroring how ucell.orbital_fn is already broadcast a few lines above. Behaviour is unchanged (broadcast from rank 0 to all ranks); the direct source_cell -> source_lcao include edge is removed. Co-Authored-By: Claude Opus 4.8 (1M context) --- source/source_cell/bcast_cell.cpp | 37 ++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/source/source_cell/bcast_cell.cpp b/source/source_cell/bcast_cell.cpp index 8f2dcd3300e..5c2a2e268f8 100644 --- a/source/source_cell/bcast_cell.cpp +++ b/source/source_cell/bcast_cell.cpp @@ -1,13 +1,30 @@ -#include "unitcell.h" +#include "unitcell.h" #include "source_base/parallel_common.h" #include "source_io/module_parameter/parameter.h" -#ifdef __EXX -#include "source_lcao/module_ri/serialization_cereal.h" -#endif #include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info +#include +#include + namespace unitcell { +#if defined(__MPI) && defined(__EXX) + // Broadcast a vector from rank 0 to all ranks. + // Replaces the former cereal-based ModuleBase::bcast_data_cereal, which + // was only ever used here to broadcast plain lists of ABFS file names and + // pulled source_cell into a dependency on source_lcao/module_ri. + static void bcast_string_vector(std::vector& v) + { + int size = static_cast(v.size()); + Parallel_Common::bcast_int(size); + v.resize(size); + for (int i = 0; i < size; ++i) + { + Parallel_Common::bcast_string(v[i]); + } + } +#endif + void bcast_atoms_tau(Atom* atoms, const int ntype) { @@ -112,15 +129,9 @@ namespace unitcell } #ifdef __EXX - ModuleBase::bcast_data_cereal(GlobalC::exx_info.info_ri.files_abfs, - MPI_COMM_WORLD, - 0); - ModuleBase::bcast_data_cereal(GlobalC::exx_info.info_opt_abfs.files_abfs, - MPI_COMM_WORLD, - 0); - ModuleBase::bcast_data_cereal(GlobalC::exx_info.info_opt_abfs.files_jles, - MPI_COMM_WORLD, - 0); + 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); #endif return; #endif