Skip to content
Open
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
14 changes: 8 additions & 6 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ VPATH=./src_global:\
./source_base/module_container/ATen/ops:\
./source_base/module_device:\
./source_base/module_mixing:\
./source_base/module_out:\
./source_md:\
./source_basis/module_pw:\
./source_base/module_fft:\
Expand Down Expand Up @@ -181,6 +182,11 @@ OBJS_BASE=assoc_laguerre.o\
device_helpers.o\
output_device.o\
parallel_2d.o\
binstream.o\
filename.o\
sparse_matrix.o\
read_exit_file.o\
orb_io.o\

OBJS_CELL=atom_pseudo.o\
atom_spec.o\
Expand Down Expand Up @@ -211,6 +217,8 @@ OBJS_CELL=atom_pseudo.o\
read_pseudo.o\
cal_wfc.o\
cal_ux.o\
cif_io.o\
ucell_io.o\

OBJS_DEEPKS=LCAO_deepks.o\
deepks_basic.o\
Expand Down Expand Up @@ -548,7 +556,6 @@ OBJS_IO=module_parameter/input_conv.o\
module_dos/cal_pdos_gamma.o\
module_dos/cal_pdos_multik.o\
module_dos/cal_ldos.o\
cif_io.o\
module_bessel/numerical_descriptor.o\
module_bessel/numerical_basis.o\
module_bessel/numerical_basis_jyjy.o\
Expand All @@ -560,7 +567,6 @@ OBJS_IO=module_parameter/input_conv.o\
read_wfc_pw.o\
read_wf2rho_pw.o\
restart.o\
binstream.o\
module_wannier/to_wannier90.o\
module_qo/to_qo_kernel.o\
module_qo/to_qo_mpi.o\
Expand Down Expand Up @@ -612,10 +618,7 @@ OBJS_IO=module_parameter/input_conv.o\
module_parameter/read_input_item_other.o\
module_parameter/read_input_item_output.o\
module_parameter/read_set_globalv.o\
orb_io.o\
cal_pLpR.o\
filename.o\
ucell_io.o\

OBJS_IO_LCAO=cal_r_overlap_R.o\
write_orb_info.o\
Expand All @@ -632,7 +635,6 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\
single_R_io.o\
module_hs/write_HS_R.o\
module_dm/write_dmr.o\
sparse_matrix.o\
module_mulliken/output_mulliken.o\
module_mulliken/output_sk.o\
module_mulliken/output_dmk.o\
Expand Down
8 changes: 8 additions & 0 deletions source/source_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@ add_library(
parallel_comm.cpp
parallel_reduce.cpp
parallel_device.cpp
parallel_grid.cpp
spherical_bessel_transformer.cpp
cubic_spline.cpp
parallel_2d.cpp
projgen.cpp
module_out/binstream.cpp
module_out/filename.cpp
module_out/sparse_matrix.cpp
module_out/file_reader.cpp
module_out/csr_reader.cpp
module_out/read_exit_file.cpp
module_out/orb_io.cpp
module_mixing/mixing_data.cpp
module_mixing/mixing.cpp
module_mixing/plain_mixing.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <string>
#include "binstream.h"
#include "source_base/module_out/binstream.h"

namespace
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <set>
#include "source_io/module_output/filename.h"
#include "source_base/module_out/filename.h"
#include "source_base/tool_quit.h"

namespace ModuleIO
Expand All @@ -19,7 +19,7 @@ std::string filename_output(
const int istep,
const int iter)
{
// output filename = "{PARAM.globalv.global_out_dir}/property{s}{spin index}
// output filename = "{global_out_dir}/property{s}{spin index}
// {k(optional)}{k-point index}{g(optional)}{geometry index1}{_basis(nao|pw)}
// + {".txt"/".dat"}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "source_io/module_output/orb_io.h"
#include "orb_io.h"
#include "source_base/tool_quit.h"
#ifdef __MPI
#include "source_base/parallel_common.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "parallel_grid.h"
#include "source_base/global_function.h"
#include "source_base/global_variable.h"
#include "source_io/module_parameter/parameter.h"

#ifdef __MPI
#include "source_base/parallel_comm.h" // use POOL_WORLD
Expand All @@ -10,27 +9,10 @@

Parallel_Grid::Parallel_Grid()
{
this->allocate = false;
this->allocate_final_scf = false; // LiuXh add 20180619
}

Parallel_Grid::~Parallel_Grid()
{
if (this->allocate || this->allocate_final_scf) // LiuXh add 20180619
{
for (int ip = 0; ip < GlobalV::KPAR; ip++)
{
delete[] numz[ip];
delete[] startz[ip];
delete[] whichpro[ip];
delete[] whichpro_loc[ip];
}
delete[] numz;
delete[] startz;
delete[] whichpro;
delete[] whichpro_loc;
delete[] nproc_in_pool;
}
}

void Parallel_Grid::init(const int& ncx_in,
Expand All @@ -39,7 +21,8 @@ void Parallel_Grid::init(const int& ncx_in,
const int& nczp_in,
const int& nrxx_in,
const int& nbz_in,
const int& bz_in)
const int& bz_in,
const int nprocgroup)
{

ModuleBase::TITLE("Parallel_Grid", "init");
Expand Down Expand Up @@ -70,37 +53,20 @@ void Parallel_Grid::init(const int& ncx_in,
#endif

// enable to call this function again liuyu 2023-03-10
if (this->allocate)
if (!this->numz.empty())
{
for (int ip = 0; ip < GlobalV::KPAR; ip++)
{
delete[] numz[ip];
delete[] startz[ip];
delete[] whichpro[ip];
delete[] whichpro_loc[ip];
}
delete[] numz;
delete[] startz;
delete[] whichpro;
delete[] whichpro_loc;
delete[] nproc_in_pool;
this->allocate = false;
this->nproc_in_pool.clear();
this->numz.clear();
this->startz.clear();
this->whichpro.clear();
this->whichpro_loc.clear();
}

// (2)
assert(allocate == false);
assert(this->numz.empty());
assert(GlobalV::KPAR > 0);

this->nproc_in_pool = new int[GlobalV::KPAR];
int nprocgroup = 0;
if (PARAM.inp.esolver_type == "sdft")
{
nprocgroup = GlobalV::NPROC_IN_BNDGROUP;
}
else
{
nprocgroup = GlobalV::NPROC;
}
this->nproc_in_pool.resize(GlobalV::KPAR);

const int remain_pro = nprocgroup % GlobalV::KPAR;
for (int i = 0; i < GlobalV::KPAR; i++)
Expand All @@ -112,33 +78,28 @@ void Parallel_Grid::init(const int& ncx_in,
}
}

this->numz = new int*[GlobalV::KPAR];
this->startz = new int*[GlobalV::KPAR];
this->whichpro = new int*[GlobalV::KPAR];
this->whichpro_loc = new int*[GlobalV::KPAR];
this->numz.resize(GlobalV::KPAR);
this->startz.resize(GlobalV::KPAR);
this->whichpro.resize(GlobalV::KPAR);
this->whichpro_loc.resize(GlobalV::KPAR);

for (int ip = 0; ip < GlobalV::KPAR; ip++)
{
const int nproc = nproc_in_pool[ip];
this->numz[ip] = new int[nproc];
this->startz[ip] = new int[nproc];
this->whichpro[ip] = new int[this->ncz];
this->whichpro_loc[ip] = new int[this->ncz];
ModuleBase::GlobalFunc::ZEROS(this->numz[ip], nproc);
ModuleBase::GlobalFunc::ZEROS(this->startz[ip], nproc);
ModuleBase::GlobalFunc::ZEROS(this->whichpro[ip], this->ncz);
ModuleBase::GlobalFunc::ZEROS(this->whichpro_loc[ip], this->ncz);
this->numz[ip].assign(nproc, 0);
this->startz[ip].assign(nproc, 0);
this->whichpro[ip].assign(this->ncz, 0);
this->whichpro_loc[ip].assign(this->ncz, 0);
}

this->allocate = true;
this->z_distribution();

return;
}

void Parallel_Grid::z_distribution()
{
assert(allocate);
assert(!this->numz.empty());

int* startp = new int[GlobalV::KPAR];
startp[0] = 0;
Expand Down Expand Up @@ -207,7 +168,7 @@ void Parallel_Grid::z_distribution()
}

#ifdef __MPI
void Parallel_Grid::bcast(const double* const data_global, double* data_local, const int& rank) const
void Parallel_Grid::bcast(const double* const data_global, double* data_local, const int& rank, const bool is_sdft) const
{
std::vector<double> zpiece(ncxy);
for (int iz = 0; iz < this->ncz; ++iz)
Expand All @@ -224,18 +185,20 @@ void Parallel_Grid::bcast(const double* const data_global, double* data_local, c
}
}
}
this->zpiece_to_all(zpiece.data(), iz, data_local);
if (is_sdft)
{
this->zpiece_to_stogroup(zpiece.data(), iz, data_local);
}
else
{
this->zpiece_to_all(zpiece.data(), iz, data_local);
}
}
}

void Parallel_Grid::zpiece_to_all(double* zpiece, const int& iz, double* rho) const
{
if (PARAM.inp.esolver_type == "sdft")
{
this->zpiece_to_stogroup(zpiece, iz, rho);
return;
}
assert(allocate);
assert(!this->numz.empty());
// ModuleBase::TITLE("Parallel_Grid","zpiece_to_all");
MPI_Status ierror;

Expand Down Expand Up @@ -304,7 +267,7 @@ void Parallel_Grid::zpiece_to_all(double* zpiece, const int& iz, double* rho) co
#ifdef __MPI
void Parallel_Grid::zpiece_to_stogroup(double* zpiece, const int& iz, double* rho) const
{
assert(allocate);
assert(!this->numz.empty());
// TITLE("Parallel_Grid","zpiece_to_all");
MPI_Status ierror;

Expand Down Expand Up @@ -425,75 +388,3 @@ void Parallel_Grid::reduce(double* rhotot, const double* const rhoin, const bool
return;
}
#endif

void Parallel_Grid::init_final_scf(const int& ncx_in,
const int& ncy_in,
const int& ncz_in,
const int& nczp_in,
const int& nrxx_in,
const int& nbz_in,
const int& bz_in)
{

ModuleBase::TITLE("Parallel_Grid", "init");

this->ncx = ncx_in;
this->ncy = ncy_in;
this->ncz = ncz_in;
this->nczp = nczp_in;
this->nrxx = nrxx_in;
this->nbz = nbz_in;
this->bz = bz_in;

if (nczp < 0)
{
GlobalV::ofs_warning << " nczp = " << nczp << std::endl;
ModuleBase::WARNING_QUIT("Parallel_Grid::init", "nczp<0");
}

assert(ncx > 0);
assert(ncy > 0);
assert(ncz > 0);

this->ncxy = ncx * ncy;
this->ncxyz = ncxy * ncz;

#ifndef __MPI
return;
#endif

// (2)
assert(allocate_final_scf == false);
assert(GlobalV::KPAR > 0);

this->nproc_in_pool = new int[GlobalV::KPAR];
const int remain_pro = GlobalV::NPROC % GlobalV::KPAR;
for (int i = 0; i < GlobalV::KPAR; i++)
{
nproc_in_pool[i] = GlobalV::NPROC / GlobalV::KPAR;
if (i < remain_pro)
{
this->nproc_in_pool[i]++;
}
}

this->numz = new int*[GlobalV::KPAR];
this->startz = new int*[GlobalV::KPAR];
this->whichpro = new int*[GlobalV::KPAR];

for (int ip = 0; ip < GlobalV::KPAR; ip++)
{
const int nproc = nproc_in_pool[ip];
this->numz[ip] = new int[nproc];
this->startz[ip] = new int[nproc];
this->whichpro[ip] = new int[this->ncz];
ModuleBase::GlobalFunc::ZEROS(this->numz[ip], nproc);
ModuleBase::GlobalFunc::ZEROS(this->startz[ip], nproc);
ModuleBase::GlobalFunc::ZEROS(this->whichpro[ip], this->ncz);
}

this->allocate_final_scf = true;
this->z_distribution();

return;
}
Loading
Loading