Skip to content

Commit 96730e8

Browse files
authored
new gint module (This is a big PR that replaces old integral codes) (#6296)
* version 0.0 * change gemm function * enable gint_vl_gpu * add new gemm function * support rho calculation * enable fvl calculation * small change * enable vlocal-metagga and tau calculation * add set ddphi * enable gint_vl_nspin4_gpu * add gint_vl_metagga_nspin4_gpu * enable fvl_meta_gpu * optimize dgemm_vbatch * set streams num * small fix * optimize gint_atom * delete virtual function * add cal_env to new gint module * renew some notes * simplify cuda_mem_wrapper.h * update cuda_mem_wrapper.h * fix get_wf_lcao.cpp * fix assert error * add gint_info init for lcao_others * refactor output_dHR * add gint_dvlocal to new gint module * add namespace * remove some shared_ptr * rename phi_mul_phi_vldr3 * small modification * remove some outdated comments * small modification * small modification * renew gint interface in rdmft related code * renew gint interface in get_pchg_lcao.cpp * fully support new gint module * reduce header dependency * remove redundant ";" * fix cmakelist * add checkcudalasterror * small modification * add some timer * Revert "change gemm function" This reverts commit ab61eb4. * fix a bug * fix bugs * delete unused declaration * make new gint module the default compilation option * add more specific debug info * fix bug of gint_env_k.cpp * fix a bug about mixing_dmr * small modification * fix bug of mixing_dmr * modify comment * replace pointer with std::vector in Numerical_Orbital * change copy assignment function in intarray * fix error in module_lr * replace module with source * include missing header * fix a bug * update some result.ref * fix compilation error when MPI is disabled * add makefile support * fix compilation error
1 parent 9631697 commit 96730e8

File tree

123 files changed

+6305
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+6305
-662
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ if(ENABLE_LCAO)
252252
add_compile_definitions(__PEXSI)
253253
set(CMAKE_CXX_STANDARD 14)
254254
endif()
255-
if(NEW_GINT)
256-
add_compile_definitions(__NEW_GINT)
255+
if(OLD_GINT)
256+
add_compile_definitions(__OLD_GINT)
257257
endif()
258258
else()
259259
set(ENABLE_MLALGO OFF)

source/Makefile.Objects

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ VPATH=./src_global:\
6161
./module_hamilt_lcao/module_deltaspin:\
6262
./module_hamilt_lcao/hamilt_lcaodft/operator_lcao:\
6363
./module_hamilt_lcao/module_gint:\
64+
./module_hamilt_lcao/module_gint/temp_gint:\
6465
./module_relax:\
6566
./source_hamilt/module_vdw:\
6667
./module_io:\
@@ -273,13 +274,13 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
273274
lcao_others.o\
274275
esolver_dm2rho.o\
275276

276-
OBJS_GINT=gint.o\
277+
OBJS_GINT=gint_old.o\
277278
gint_gamma_env.o\
278279
gint_gamma_vl.o\
279-
gint_fvl.o\
280-
gint_rho.o\
281-
gint_tau.o\
282-
gint_vl.o\
280+
gint_fvl_old.o\
281+
gint_rho_old.o\
282+
gint_tau_old.o\
283+
gint_vl_old.o\
283284
gint_k_env.o\
284285
gint_k_sparse1.o\
285286
gint_k_pvpr.o\
@@ -298,6 +299,30 @@ OBJS_GINT=gint.o\
298299
cal_ddpsir_ylm.o\
299300
mult_psi_dmr.o\
300301
init_orb.o\
302+
batch_biggrid.o\
303+
big_grid.o\
304+
biggrid_info.o\
305+
divide_info.o\
306+
gint_atom.o\
307+
gint_common.o\
308+
gint_dvlocal.o\
309+
gint_env_gamma.o\
310+
gint_env_k.o\
311+
gint_fvl_meta.o\
312+
gint_fvl.o\
313+
gint_info.o\
314+
gint_interface.o\
315+
gint_rho.o\
316+
gint_tau.o\
317+
gint_vl_metagga_nspin4.o\
318+
gint_vl_metagga.o\
319+
gint_vl_nspin4.o\
320+
gint_vl.o\
321+
gint.o\
322+
localcell_info.o\
323+
phi_operator.o\
324+
set_ddphi.o\
325+
unitcell_info.o\
301326

302327
OBJS_HAMILT=hamilt_pw.o\
303328
hamilt_sdft_pw.o\

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/veff_lcao.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void Veff<OperatorLCAO<double, double>>::contributeHR()
6868
double* vr_eff1 = this->pot->get_effective_v(this->current_spin);
6969
double* vofk_eff1 = this->pot->get_effective_vofk(this->current_spin);
7070

71-
#ifndef __NEW_GINT
71+
#ifdef __OLD_GINT
7272
if(XC_Functional::get_ked_flag())
7373
{
7474
Gint_inout inout(vr_eff1, vofk_eff1, Gint_Tools::job_type::vlocal_meta);
@@ -113,7 +113,7 @@ void Veff<OperatorLCAO<std::complex<double>, double>>::contributeHR()
113113
double* vr_eff1 = this->pot->get_effective_v(this->current_spin);
114114
double* vofk_eff1 = this->pot->get_effective_vofk(this->current_spin);
115115

116-
#ifndef __NEW_GINT
116+
#ifdef __OLD_GINT
117117
// if you change the place of the following code,
118118
// rememeber to delete the #include
119119
if(XC_Functional::get_ked_flag())
@@ -155,7 +155,7 @@ void Veff<OperatorLCAO<std::complex<double>, std::complex<double>>>::contributeH
155155
ModuleBase::TITLE("Veff", "contributeHR");
156156
ModuleBase::timer::tick("Veff", "contributeHR");
157157

158-
#ifndef __NEW_GINT
158+
#ifdef __OLD_GINT
159159
double* vr_eff1 = nullptr;
160160
double* vofk_eff1 = nullptr;
161161
for (int is = 0; is < 4; is++)
@@ -187,19 +187,15 @@ void Veff<OperatorLCAO<std::complex<double>, std::complex<double>>>::contributeH
187187
if(XC_Functional::get_ked_flag())
188188
{
189189
vofk_eff[is] = this->pot->get_effective_vofk(is);
190-
if(is == 3)
191-
{
192-
ModuleGint::cal_gint_vl_metagga(vr_eff, vofk_eff, this->hR);
193-
}
194-
}
195-
else
196-
{
197-
if(is == 3)
198-
{
199-
ModuleGint::cal_gint_vl(vr_eff, this->hR);
200-
}
201190
}
202191
}
192+
if(XC_Functional::get_ked_flag())
193+
{
194+
ModuleGint::cal_gint_vl_metagga(vr_eff, vofk_eff, this->hR);
195+
} else
196+
{
197+
ModuleGint::cal_gint_vl(vr_eff, this->hR);
198+
}
203199
#endif
204200

205201
ModuleBase::timer::tick("Veff", "contributeHR");

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/veff_lcao.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class Veff<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
5050
this->cal_type = calculation_type::lcao_gint;
5151

5252
this->initialize_HR(ucell_in, GridD_in);
53+
#ifdef __OLD_GINT
5354
GK_in->initialize_pvpR(*ucell_in, GridD_in, nspin);
55+
#endif
5456
}
5557
/**
5658
* @brief Construct a new Veff object for Gamma-only calculation
@@ -69,8 +71,9 @@ class Veff<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
6971
{
7072
this->cal_type = calculation_type::lcao_gint;
7173
this->initialize_HR(ucell_in, GridD_in);
72-
74+
#ifdef __OLD_GINT
7375
GG_in->initialize_pvpR(*ucell_in, GridD_in, nspin);
76+
#endif
7477
}
7578

7679
~Veff<OperatorLCAO<TK, TR>>(){};

source/module_hamilt_lcao/hamilt_lcaodft/pulay_force_stress_gint.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace PulayForceStress
2020
{
2121
const int nspin = PARAM.inp.nspin;
2222

23-
#ifndef __NEW_GINT
23+
#ifdef __OLD_GINT
2424
if (set_dmr_gint) { gint.transfer_DM2DtoGrid(dm.get_DMR_vector()); } // 2d block to grid
2525
for (int is = 0; is < nspin; ++is)
2626
{

source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "module_parameter/parameter.h"
44
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h"
5+
#include "module_hamilt_lcao/module_gint/temp_gint/gint_interface.h"
56
#include <vector>
67

78
void sparse_format::cal_dS(const UnitCell& ucell,
@@ -49,7 +50,6 @@ delete[] fsr_dh.DHloc_fixedR_y;
4950
delete[] fsr_dh.DHloc_fixedR_z;
5051
return;
5152
}
52-
5353
void sparse_format::cal_dH(const UnitCell& ucell,
5454
const Parallel_Orbitals& pv,
5555
LCAO_HS_Arrays& HS_Arrays,
@@ -58,6 +58,7 @@ void sparse_format::cal_dH(const UnitCell& ucell,
5858
const LCAO_Orbitals& orb,
5959
const int& current_spin,
6060
const double& sparse_thr,
61+
const ModuleBase::matrix& v_eff,
6162
Gint_k& gint_k)
6263
{
6364
ModuleBase::TITLE("sparse_format", "cal_dH");
@@ -106,8 +107,38 @@ void sparse_format::cal_dH(const UnitCell& ucell,
106107
delete[] fsr_dh.DHloc_fixedR_y;
107108
delete[] fsr_dh.DHloc_fixedR_z;
108109

109-
gint_k.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, ucell, grid);
110-
110+
if(PARAM.inp.nspin==2)
111+
{
112+
#ifdef __OLD_GINT
113+
gint_k.allocate_pvdpR();
114+
// note: some MPI process will not have grids when MPI cores are too
115+
// many, v_eff in these processes are empty
116+
const double* vr_eff1
117+
= v_eff.nc * v_eff.nr > 0 ? &(v_eff(current_spin, 0)) : nullptr;
118+
119+
if (!PARAM.globalv.gamma_only_local)
120+
{
121+
if (PARAM.inp.vl_in_h)
122+
{
123+
Gint_inout inout(vr_eff1,
124+
current_spin,
125+
Gint_Tools::job_type::dvlocal);
126+
gint_k.cal_gint(&inout);
127+
}
128+
}
129+
gint_k.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, ucell, grid);
130+
gint_k.destroy_pvdpR();
131+
#else
132+
const double* vr_eff1
133+
= v_eff.nc * v_eff.nr > 0 ? &(v_eff(current_spin, 0)) : nullptr;
134+
if (!PARAM.globalv.gamma_only_local)
135+
{
136+
ModuleGint::cal_dvlocal_R_sparseMatrix(
137+
PARAM.inp.nspin, PARAM.globalv.npol, current_spin, PARAM.globalv.nlocal,
138+
sparse_thr, vr_eff1, pv, ucell, grid, HS_Arrays);
139+
}
140+
#endif
141+
}
111142
return;
112143
}
113144

source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void cal_dH(const UnitCell& ucell,
1919
const LCAO_Orbitals& orb,
2020
const int& current_spin,
2121
const double& sparse_thr,
22+
const ModuleBase::matrix& v_eff,
2223
Gint_k& gint_k);
2324

2425
// calculated the derivative of the overlap matrix: <phi|dphi>

source/module_hamilt_lcao/module_gint/CMakeLists.txt

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
if(ENABLE_LCAO)
33

44
list(APPEND objects
5-
gint.cpp
5+
gint_old.cpp
66
gint_gamma_env.cpp
77
gint_gamma_vl.cpp
8-
gint_fvl.cpp
9-
gint_rho.cpp
10-
gint_tau.cpp
11-
gint_vl.cpp
8+
gint_fvl_old.cpp
9+
gint_rho_old.cpp
10+
gint_tau_old.cpp
11+
gint_vl_old.cpp
1212
gint_k_env.cpp
1313
gint_k_sparse1.cpp
1414
gint_k_pvpr.cpp
@@ -29,7 +29,7 @@ list(APPEND objects
2929
init_orb.cpp
3030
)
3131

32-
if(NEW_GINT)
32+
if(NOT DEFINED OLD_GINT)
3333
list(APPEND objects
3434
temp_gint/biggrid_info.cpp
3535
temp_gint/big_grid.cpp
@@ -45,13 +45,34 @@ if(NEW_GINT)
4545
temp_gint/gint_tau.cpp
4646
temp_gint/gint_fvl.cpp
4747
temp_gint/gint_fvl_meta.cpp
48+
temp_gint/gint_env_gamma.cpp
49+
temp_gint/gint_env_k.cpp
50+
temp_gint/gint_dvlocal.cpp
4851
temp_gint/localcell_info.cpp
4952
temp_gint/phi_operator.cpp
5053
temp_gint/set_ddphi.cpp
5154
temp_gint/unitcell_info.cpp
5255
temp_gint/gint_common.cpp
5356
temp_gint/gint_interface.cpp
5457
)
58+
if(USE_CUDA)
59+
list(APPEND objects
60+
temp_gint/kernel/gint_gpu_vars.cpp
61+
temp_gint/kernel/phi_operator_gpu.cu
62+
temp_gint/kernel/phi_operator_kernel.cu
63+
temp_gint/kernel/set_const_mem.cu
64+
temp_gint/batch_biggrid.cpp
65+
temp_gint/gint_vl_gpu.cpp
66+
temp_gint/gint_rho_gpu.cpp
67+
temp_gint/gint_fvl_gpu.cpp
68+
temp_gint/gint_vl_metagga_gpu.cpp
69+
temp_gint/gint_vl_nspin4_gpu.cpp
70+
temp_gint/gint_vl_metagga_nspin4_gpu.cpp
71+
temp_gint/gint_tau_gpu.cpp
72+
temp_gint/gint_fvl_meta_gpu.cpp
73+
temp_gint/kernel/dgemm_vbatch.cu
74+
)
75+
endif()
5576
endif()
5677

5778
if(USE_CUDA)

source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ void Gint_k::cal_dvlocal_R_sparseMatrix(const int& current_spin,
337337
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>>
338338
pvdpRz_soc_sparseMatrix;
339339

340-
int lgd = 0;
341340
double temp_value_double;
342341
std::complex<double> temp_value_complex;
343342

0 commit comments

Comments
 (0)