Skip to content

Commit fcef6cd

Browse files
committed
move kpar into read_input_item
1 parent 0098171 commit fcef6cd

File tree

8 files changed

+34
-39
lines changed

8 files changed

+34
-39
lines changed

source/module_base/global_variable.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ namespace GlobalV
1818

1919
int NPROC = 1; ///< global number of process
2020
int KPAR = 1; ///< global number of pools
21-
int KPAR_LCAO = 1; ///< global number of pools for LCAO diagonalization only
2221
int MY_RANK = 0; ///< global index of process
2322
int MY_POOL = 0; ///< global index of pool (count in pool)
2423
int MY_STOGROUP = 0;

source/module_base/global_variable.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ namespace GlobalV
2828
// NAME : DCOLOR( color of each group)
2929
// NAME : GRANK( index of grid world)
3030
// NAME : GSIZE( number of processors in each grid world)
31-
// NAME : KPAR_LCAO ( global number of pools for LCAO diagonalization only)
3231
//========================================================================
3332
extern int NPROC;
3433
extern int KPAR;
@@ -44,7 +43,6 @@ extern int DSIZE;
4443
extern int DCOLOR;
4544
extern int GRANK;
4645
extern int GSIZE;
47-
extern int KPAR_LCAO;
4846

4947
//==========================================================
5048
// NAME : ofs_running( contain information during runnnig)

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,16 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
241241
}
242242

243243
// 12) if kpar is not divisible by nks, print a warning
244-
if (GlobalV::KPAR_LCAO > 1)
244+
if (PARAM.globalv.kpar_lcao > 1)
245245
{
246-
if (this->kv.get_nks() % GlobalV::KPAR_LCAO != 0)
246+
if (this->kv.get_nks() % PARAM.globalv.kpar_lcao != 0)
247247
{
248248
ModuleBase::WARNING("ESolver_KS_LCAO::before_all_runners", "nks is not divisible by kpar.");
249249
std::cout << "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
250250
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
251251
"%%%%%%%%%%%%%%%%%%%%%%%%%%"
252252
<< std::endl;
253-
std::cout << " Warning: nks (" << this->kv.get_nks() << ") is not divisible by kpar (" << GlobalV::KPAR_LCAO
253+
std::cout << " Warning: nks (" << this->kv.get_nks() << ") is not divisible by kpar (" << PARAM.globalv.kpar_lcao
254254
<< ")." << std::endl;
255255
std::cout << " This may lead to poor load balance. It is strongly suggested to" << std::endl;
256256
std::cout << " set nks to be divisible by kpar, but if this is really what" << std::endl;

source/module_hsolver/hsolver_lcao.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ void HSolverLCAO<T, Device>::solve(hamilt::Hamilt<T>* pHamilt,
4747

4848
if (this->method != "pexsi")
4949
{
50-
if (GlobalV::KPAR_LCAO > 1
50+
if (PARAM.globalv.kpar_lcao > 1
5151
&& (this->method == "genelpa" || this->method == "elpa" || this->method == "scalapack_gvx"))
5252
{
5353
#ifdef __MPI
54-
this->parakSolve(pHamilt, psi, pes, GlobalV::KPAR_LCAO);
54+
this->parakSolve(pHamilt, psi, pes, PARAM.globalv.kpar_lcao);
5555
#endif
5656
}
57-
else if (GlobalV::KPAR_LCAO == 1)
57+
else if (PARAM.globalv.kpar_lcao == 1)
5858
{
5959
/// Loop over k points for solve Hamiltonian to eigenpairs(eigenvalues and eigenvectors).
6060
for (int ik = 0; ik < psi.get_nk(); ++ik)

source/module_io/input_conv.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -171,37 +171,9 @@ void Input_Conv::Convert()
171171
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "orbital_dir", PARAM.inp.orbital_dir);
172172
// GlobalV::global_pseudo_type = PARAM.inp.pseudo_type;
173173

174-
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax")
175-
{
176-
}
177-
178174

179-
if (PARAM.inp.device == "gpu" && PARAM.inp.basis_type == "pw")
180-
{
181-
GlobalV::KPAR = base_device::information::get_device_kpar(PARAM.inp.kpar, PARAM.inp.bndpar);
182-
}
183-
#ifdef __LCAO
184-
else if (PARAM.inp.basis_type == "lcao") {
185-
/// GlobalV::KPAR_LCAO is used in LCAO diagonalization only
186-
GlobalV::KPAR_LCAO = PARAM.inp.kpar;
187-
/// all other parts of the code use GlobalV::KPAR = 1
188-
GlobalV::KPAR = 1;
189-
}
190-
#endif
191-
else
192-
{
193-
GlobalV::KPAR = PARAM.inp.kpar;
194-
}
195-
if (PARAM.inp.device == "cpu" and PARAM.inp.precision == "single")
196-
{
197-
// cpu single precision is not supported while float_fftw lib is not available
198-
#ifndef __ENABLE_FLOAT_FFTW
199-
ModuleBase::WARNING_QUIT(
200-
"Input_Conv",
201-
"Single precision with cpu is not supported while float_fftw lib is not available; \
202-
\n Please recompile with cmake flag \"-DENABLE_FLOAT_FFTW=ON\".\n");
203-
#endif // __ENABLE_FLOAT_FFTW
204-
}
175+
GlobalV::KPAR = PARAM.inp.kpar;
176+
205177

206178

207179
#ifdef __LCAO

source/module_io/read_input_item_system.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ void ReadInput::item_system()
233233
item.annotation = "devide all processors into kpar groups and k points "
234234
"will be distributed among";
235235
read_sync_int(input.kpar);
236+
item.reset_value = [](const Input_Item& item, Parameter& para) {
237+
if (para.inp.device == "gpu" && para.inp.basis_type == "pw")
238+
{
239+
para.input.kpar = base_device::information::get_device_kpar(para.inp.kpar, para.inp.bndpar);
240+
}
241+
#ifdef __LCAO
242+
else if (para.inp.basis_type == "lcao")
243+
{
244+
para.sys.kpar_lcao = para.inp.kpar;
245+
para.input.kpar = 1;
246+
}
247+
#endif
248+
};
236249
item.check_value = [](const Input_Item& item, const Parameter& para) {
237250
if (para.input.basis_type == "lcao" && para.input.kpar > 1)
238251
{
@@ -796,6 +809,17 @@ void ReadInput::item_system()
796809
const std::string warningstr = nofound_str(avail_list, "precision");
797810
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
798811
}
812+
813+
// cpu single precision is not supported while float_fftw lib is not available
814+
if (para.inp.device == "cpu" && para.inp.precision == "single")
815+
{
816+
#ifndef __ENABLE_FLOAT_FFTW
817+
ModuleBase::WARNING_QUIT(
818+
"ReadInput",
819+
"Single precision with cpu is not supported while float_fftw lib is not available; \
820+
\n Please recompile with cmake flag \"-DENABLE_FLOAT_FFTW=ON\".\n");
821+
#endif
822+
}
799823
};
800824
this->add_item(item);
801825
}

source/module_io/read_set_globalv.cpp

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,6 @@ void ReadInput::set_globalv_bcast()
127127
add_double_bcast(sys.dq);
128128
add_int_bcast(sys.nqx);
129129
add_int_bcast(sys.nqxq);
130+
add_int_bcast(sys.kpar_lcao);
130131
}
131132
} // namespace ModuleIO

source/module_parameter/system_parameter.h

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ struct System_para
5353
bool double_grid = false; ///< true if "ndx,ndy,ndz" is larger than "nx,ny,nz"
5454
double uramping = -10.0 / 13.6; /// U-Ramping method (Ry)
5555
std::vector<double> hubbard_u = {}; ///< Hubbard Coulomb interaction parameter U (Ry)
56+
int kpar_lcao = 1; ///< global number of pools for LCAO diagonalization only
5657
};
5758
#endif

0 commit comments

Comments
 (0)