Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions source/source_cell/bcast_cell.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
#include "unitcell.h"
#include "source_base/parallel_common.h"

#include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info

#include <string>
#include <vector>

namespace unitcell
{
#if defined(__MPI) && defined(__EXX)
// Broadcast a vector<string> 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<std::string>& v)
{
int size = static_cast<int>(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)
{
Expand Down Expand Up @@ -131,12 +112,6 @@ namespace unitcell
{
Parallel_Common::bcast_string(ucell.orbital_fn[i]);
}

#ifdef __EXX
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
}
Expand Down
41 changes: 41 additions & 0 deletions source/source_lcao/setup_exx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

#ifdef __EXX
#include "source_lcao/module_ri/Exx_LRI_interface.h"
#include "source_hamilt/module_xc/exx_info.h" // use the global Exx_Info
#if defined(__MPI)
#include "source_base/parallel_common.h"
#include <string>
#include <vector>
#endif
#endif

#ifdef __EXX
#if defined(__MPI)
namespace
{
// Broadcast a vector<string> from rank 0 to all ranks.
// Moved here from source_cell/bcast_cell.cpp so that source_cell no longer
// depends on the XC module just to distribute these ABFS file-name lists.
void bcast_string_vector(std::vector<std::string>& v)
{
int size = static_cast<int>(v.size());
Parallel_Common::bcast_int(size);
v.resize(size);
for (int i = 0; i < size; ++i)
{
Parallel_Common::bcast_string(v[i]);
}
}
} // namespace
#endif

void bcast_exx_file_lists()
{
#if defined(__MPI)
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
}
#endif

template <typename TK>
Expand All @@ -20,6 +56,11 @@ void Exx_NAO<TK>::init()
// which cause the failure of the subsequent procedure reused by ESolver_LCAO_TDDFT
// 2. always construct but only initialize when if(cal_exx) is true
// because some members like two_level_step are used outside if(cal_exx)

// Distribute the ABFS/JLE file lists (read from STRU on rank 0) to all ranks
// before Exx_LRI copies info_ri below.
bcast_exx_file_lists();

if (GlobalC::exx_info.info_ri.real_number)
{
this->exd = std::make_shared<Exx_LRI_Interface<TK, double>>(GlobalC::exx_info.info_ri, GlobalC::exx_info.info_global);
Expand Down
13 changes: 13 additions & 0 deletions source/source_lcao/setup_exx.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,18 @@ class Exx_NAO

};

#ifdef __EXX
/**
* @brief Broadcast the ABFS/JLE orbital-file lists held in the global Exx_Info instance.
*
* The lists are read from STRU on rank 0 during setup_cell and must be
* distributed to all ranks before the LCAO EXX/RI module consumes them.
* This logic lives here (rather than in source_cell or the generic XC module)
* because the ABFS/JLE orbital files are an LCAO-only concept. It is invoked at
* the start of Exx_NAO::init(), before Exx_LRI copies info_ri.
*/
void bcast_exx_file_lists();
#endif


#endif
Loading