Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a8740c1
version 0.0
dzzz2001 Apr 16, 2025
7f06114
change gemm function
dzzz2001 Apr 26, 2025
1ef0450
enable gint_vl_gpu
dzzz2001 Apr 30, 2025
cb05e03
add new gemm function
dzzz2001 May 8, 2025
7dc0cde
support rho calculation
dzzz2001 May 8, 2025
3f1b710
enable fvl calculation
dzzz2001 May 9, 2025
5fb4dce
small change
dzzz2001 May 14, 2025
6fd248e
enable vlocal-metagga and tau calculation
dzzz2001 May 15, 2025
584d151
add set ddphi
dzzz2001 May 15, 2025
0aa783f
enable gint_vl_nspin4_gpu
dzzz2001 May 16, 2025
2566e0d
add gint_vl_metagga_nspin4_gpu
dzzz2001 May 16, 2025
f62adea
enable fvl_meta_gpu
dzzz2001 May 16, 2025
0bd2d9c
optimize dgemm_vbatch
dzzz2001 May 16, 2025
caf0415
set streams num
dzzz2001 May 19, 2025
5311224
small fix
dzzz2001 May 22, 2025
fbbbedc
optimize gint_atom
dzzz2001 May 23, 2025
ed8182b
delete virtual function
dzzz2001 May 29, 2025
226094f
add cal_env to new gint module
dzzz2001 Jun 1, 2025
d79d418
renew some notes
dzzz2001 Jun 1, 2025
14b6949
simplify cuda_mem_wrapper.h
dzzz2001 Jun 4, 2025
c2b6821
update cuda_mem_wrapper.h
dzzz2001 Jun 5, 2025
052c3c9
fix get_wf_lcao.cpp
dzzz2001 Jun 5, 2025
6a22b90
fix assert error
dzzz2001 Jun 10, 2025
f1d1946
add gint_info init for lcao_others
dzzz2001 Jun 10, 2025
81c8f6b
refactor output_dHR
dzzz2001 Jun 10, 2025
f130cde
add gint_dvlocal to new gint module
dzzz2001 Jun 11, 2025
bbfe636
add namespace
dzzz2001 Jun 12, 2025
b62e311
remove some shared_ptr
dzzz2001 Jun 12, 2025
d0d98b0
rename phi_mul_phi_vldr3
dzzz2001 Jun 13, 2025
479b0ad
small modification
dzzz2001 Jun 13, 2025
d52f745
remove some outdated comments
dzzz2001 Jun 13, 2025
5feaea5
small modification
dzzz2001 Jun 13, 2025
8a38ede
small modification
dzzz2001 Jun 14, 2025
94b522c
renew gint interface in rdmft related code
dzzz2001 Jun 15, 2025
cf73ad5
renew gint interface in get_pchg_lcao.cpp
dzzz2001 Jun 15, 2025
389c774
fully support new gint module
dzzz2001 Jun 15, 2025
0d3b292
reduce header dependency
dzzz2001 Jun 15, 2025
f8f6e31
remove redundant ";"
dzzz2001 Jun 15, 2025
86b63b8
fix cmakelist
dzzz2001 Jun 16, 2025
34b9564
add checkcudalasterror
dzzz2001 Jun 16, 2025
d86c0e3
small modification
dzzz2001 Jun 16, 2025
c0bc2a6
add some timer
dzzz2001 Jun 16, 2025
ee8a933
Revert "change gemm function"
dzzz2001 Jun 16, 2025
cabc7a0
fix a bug
dzzz2001 Jun 16, 2025
28b1dad
fix bugs
dzzz2001 Jun 16, 2025
4fecbe9
delete unused declaration
dzzz2001 Jun 16, 2025
e25e601
make new gint module the default compilation option
dzzz2001 Jun 16, 2025
abed081
add more specific debug info
dzzz2001 Jun 17, 2025
2c172e5
fix bug of gint_env_k.cpp
dzzz2001 Jun 22, 2025
435046f
fix a bug about mixing_dmr
dzzz2001 Jun 22, 2025
661ede2
small modification
dzzz2001 Jun 22, 2025
6992cb0
fix bug of mixing_dmr
dzzz2001 Jun 23, 2025
9f0cd28
modify comment
dzzz2001 Jun 23, 2025
f186829
replace pointer with std::vector in Numerical_Orbital
dzzz2001 Jun 23, 2025
52dff74
change copy assignment function in intarray
dzzz2001 Jun 24, 2025
f723858
fix error in module_lr
dzzz2001 Jun 24, 2025
28daad7
replace module with source
dzzz2001 Jun 24, 2025
57b4e7f
include missing header
dzzz2001 Jun 24, 2025
d6459d2
fix a bug
dzzz2001 Jun 24, 2025
4a60ee8
Merge branch 'develop' into gint-new-2
dzzz2001 Jun 25, 2025
12a1883
update some result.ref
dzzz2001 Jun 25, 2025
5580c34
fix compilation error when MPI is disabled
dzzz2001 Jun 25, 2025
c6547fc
add makefile support
dzzz2001 Jun 26, 2025
2ffb5a2
Merge remote-tracking branch 'origin/develop' into gint-new-2
dzzz2001 Jun 26, 2025
b165436
Merge branch 'develop' into gint-new-2
dzzz2001 Jun 26, 2025
10a1fe5
Merge remote-tracking branch 'origin/develop' into gint-new-2
dzzz2001 Jun 26, 2025
d30c7d2
Merge remote-tracking branch 'dzc/gint-new-2' into gint-new-2
dzzz2001 Jun 26, 2025
3656490
fix compilation error
dzzz2001 Jun 26, 2025
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ if(ENABLE_LCAO)
add_compile_definitions(__PEXSI)
set(CMAKE_CXX_STANDARD 14)
endif()
if(NEW_GINT)
add_compile_definitions(__NEW_GINT)
if(OLD_GINT)
add_compile_definitions(__OLD_GINT)
endif()
else()
set(ENABLE_MLALGO OFF)
Expand Down
35 changes: 30 additions & 5 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ VPATH=./src_global:\
./module_hamilt_lcao/module_deltaspin:\
./module_hamilt_lcao/hamilt_lcaodft/operator_lcao:\
./module_hamilt_lcao/module_gint:\
./module_hamilt_lcao/module_gint/temp_gint:\
./module_relax:\
./source_hamilt/module_vdw:\
./module_io:\
Expand Down Expand Up @@ -273,13 +274,13 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
lcao_others.o\
esolver_dm2rho.o\

OBJS_GINT=gint.o\
OBJS_GINT=gint_old.o\
gint_gamma_env.o\
gint_gamma_vl.o\
gint_fvl.o\
gint_rho.o\
gint_tau.o\
gint_vl.o\
gint_fvl_old.o\
gint_rho_old.o\
gint_tau_old.o\
gint_vl_old.o\
gint_k_env.o\
gint_k_sparse1.o\
gint_k_pvpr.o\
Expand All @@ -298,6 +299,30 @@ OBJS_GINT=gint.o\
cal_ddpsir_ylm.o\
mult_psi_dmr.o\
init_orb.o\
batch_biggrid.o\
big_grid.o\
biggrid_info.o\
divide_info.o\
gint_atom.o\
gint_common.o\
gint_dvlocal.o\
gint_env_gamma.o\
gint_env_k.o\
gint_fvl_meta.o\
gint_fvl.o\
gint_info.o\
gint_interface.o\
gint_rho.o\
gint_tau.o\
gint_vl_metagga_nspin4.o\
gint_vl_metagga.o\
gint_vl_nspin4.o\
gint_vl.o\
gint.o\
localcell_info.o\
phi_operator.o\
set_ddphi.o\
unitcell_info.o\

OBJS_HAMILT=hamilt_pw.o\
hamilt_sdft_pw.o\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void Veff<OperatorLCAO<double, double>>::contributeHR()
double* vr_eff1 = this->pot->get_effective_v(this->current_spin);
double* vofk_eff1 = this->pot->get_effective_vofk(this->current_spin);

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

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

#ifndef __NEW_GINT
#ifdef __OLD_GINT
double* vr_eff1 = nullptr;
double* vofk_eff1 = nullptr;
for (int is = 0; is < 4; is++)
Expand Down Expand Up @@ -187,19 +187,15 @@ void Veff<OperatorLCAO<std::complex<double>, std::complex<double>>>::contributeH
if(XC_Functional::get_ked_flag())
{
vofk_eff[is] = this->pot->get_effective_vofk(is);
if(is == 3)
{
ModuleGint::cal_gint_vl_metagga(vr_eff, vofk_eff, this->hR);
}
}
else
{
if(is == 3)
{
ModuleGint::cal_gint_vl(vr_eff, this->hR);
}
}
}
if(XC_Functional::get_ked_flag())
{
ModuleGint::cal_gint_vl_metagga(vr_eff, vofk_eff, this->hR);
} else
{
ModuleGint::cal_gint_vl(vr_eff, this->hR);
}
#endif

ModuleBase::timer::tick("Veff", "contributeHR");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class Veff<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
this->cal_type = calculation_type::lcao_gint;

this->initialize_HR(ucell_in, GridD_in);
#ifdef __OLD_GINT
GK_in->initialize_pvpR(*ucell_in, GridD_in, nspin);
#endif
}
/**
* @brief Construct a new Veff object for Gamma-only calculation
Expand All @@ -69,8 +71,9 @@ class Veff<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
{
this->cal_type = calculation_type::lcao_gint;
this->initialize_HR(ucell_in, GridD_in);

#ifdef __OLD_GINT
GG_in->initialize_pvpR(*ucell_in, GridD_in, nspin);
#endif
}

~Veff<OperatorLCAO<TK, TR>>(){};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace PulayForceStress
{
const int nspin = PARAM.inp.nspin;

#ifndef __NEW_GINT
#ifdef __OLD_GINT
if (set_dmr_gint) { gint.transfer_DM2DtoGrid(dm.get_DMR_vector()); } // 2d block to grid
for (int is = 0; is < nspin; ++is)
{
Expand Down
37 changes: 34 additions & 3 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "module_parameter/parameter.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h"
#include "module_hamilt_lcao/module_gint/temp_gint/gint_interface.h"
#include <vector>

void sparse_format::cal_dS(const UnitCell& ucell,
Expand Down Expand Up @@ -49,7 +50,6 @@ delete[] fsr_dh.DHloc_fixedR_y;
delete[] fsr_dh.DHloc_fixedR_z;
return;
}

void sparse_format::cal_dH(const UnitCell& ucell,
const Parallel_Orbitals& pv,
LCAO_HS_Arrays& HS_Arrays,
Expand All @@ -58,6 +58,7 @@ void sparse_format::cal_dH(const UnitCell& ucell,
const LCAO_Orbitals& orb,
const int& current_spin,
const double& sparse_thr,
const ModuleBase::matrix& v_eff,
Gint_k& gint_k)
{
ModuleBase::TITLE("sparse_format", "cal_dH");
Expand Down Expand Up @@ -106,8 +107,38 @@ void sparse_format::cal_dH(const UnitCell& ucell,
delete[] fsr_dh.DHloc_fixedR_y;
delete[] fsr_dh.DHloc_fixedR_z;

gint_k.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, ucell, grid);

if(PARAM.inp.nspin==2)
{
#ifdef __OLD_GINT
gint_k.allocate_pvdpR();
// note: some MPI process will not have grids when MPI cores are too
// many, v_eff in these processes are empty
const double* vr_eff1
= v_eff.nc * v_eff.nr > 0 ? &(v_eff(current_spin, 0)) : nullptr;

if (!PARAM.globalv.gamma_only_local)
{
if (PARAM.inp.vl_in_h)
{
Gint_inout inout(vr_eff1,
current_spin,
Gint_Tools::job_type::dvlocal);
gint_k.cal_gint(&inout);
}
}
gint_k.cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, ucell, grid);
gint_k.destroy_pvdpR();
#else
const double* vr_eff1
= v_eff.nc * v_eff.nr > 0 ? &(v_eff(current_spin, 0)) : nullptr;
if (!PARAM.globalv.gamma_only_local)
{
ModuleGint::cal_dvlocal_R_sparseMatrix(
PARAM.inp.nspin, PARAM.globalv.npol, current_spin, PARAM.globalv.nlocal,
sparse_thr, vr_eff1, pv, ucell, grid, HS_Arrays);
}
#endif
}
return;
}

Expand Down
1 change: 1 addition & 0 deletions source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void cal_dH(const UnitCell& ucell,
const LCAO_Orbitals& orb,
const int& current_spin,
const double& sparse_thr,
const ModuleBase::matrix& v_eff,
Gint_k& gint_k);

// calculated the derivative of the overlap matrix: <phi|dphi>
Expand Down
33 changes: 27 additions & 6 deletions source/module_hamilt_lcao/module_gint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
if(ENABLE_LCAO)

list(APPEND objects
gint.cpp
gint_old.cpp
gint_gamma_env.cpp
gint_gamma_vl.cpp
gint_fvl.cpp
gint_rho.cpp
gint_tau.cpp
gint_vl.cpp
gint_fvl_old.cpp
gint_rho_old.cpp
gint_tau_old.cpp
gint_vl_old.cpp
gint_k_env.cpp
gint_k_sparse1.cpp
gint_k_pvpr.cpp
Expand All @@ -29,7 +29,7 @@ list(APPEND objects
init_orb.cpp
)

if(NEW_GINT)
if(NOT DEFINED OLD_GINT)
list(APPEND objects
temp_gint/biggrid_info.cpp
temp_gint/big_grid.cpp
Expand All @@ -45,13 +45,34 @@ if(NEW_GINT)
temp_gint/gint_tau.cpp
temp_gint/gint_fvl.cpp
temp_gint/gint_fvl_meta.cpp
temp_gint/gint_env_gamma.cpp
temp_gint/gint_env_k.cpp
temp_gint/gint_dvlocal.cpp
temp_gint/localcell_info.cpp
temp_gint/phi_operator.cpp
temp_gint/set_ddphi.cpp
temp_gint/unitcell_info.cpp
temp_gint/gint_common.cpp
temp_gint/gint_interface.cpp
)
if(USE_CUDA)
list(APPEND objects
temp_gint/kernel/gint_gpu_vars.cpp
temp_gint/kernel/phi_operator_gpu.cu
temp_gint/kernel/phi_operator_kernel.cu
temp_gint/kernel/set_const_mem.cu
temp_gint/batch_biggrid.cpp
temp_gint/gint_vl_gpu.cpp
temp_gint/gint_rho_gpu.cpp
temp_gint/gint_fvl_gpu.cpp
temp_gint/gint_vl_metagga_gpu.cpp
temp_gint/gint_vl_nspin4_gpu.cpp
temp_gint/gint_vl_metagga_nspin4_gpu.cpp
temp_gint/gint_tau_gpu.cpp
temp_gint/gint_fvl_meta_gpu.cpp
temp_gint/kernel/dgemm_vbatch.cu
)
endif()
endif()

if(USE_CUDA)
Expand Down
1 change: 0 additions & 1 deletion source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ void Gint_k::cal_dvlocal_R_sparseMatrix(const int& current_spin,
std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, std::complex<double>>>>
pvdpRz_soc_sparseMatrix;

int lgd = 0;
double temp_value_double;
std::complex<double> temp_value_complex;

Expand Down
22 changes: 1 addition & 21 deletions source/module_hamilt_lcao/module_gint/kernels/cuda/cuda_tools.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@

#include "cuda_tools.cuh"

cudaError_t check(cudaError_t result, const char *const func, const char *const file, const int line)
{
if (result != cudaSuccess)
{
fprintf(stderr, "CUDA Runtime Error at %s:%d code=%s \"%s\" \n", file, line, cudaGetErrorString(result), func);
exit(EXIT_FAILURE);
}
return result;
}
cudaError_t __checkCudaLastError(const char *file, const int line)
{
cudaError_t result = cudaGetLastError();
if (result != cudaSuccess)
{
fprintf(stderr, "%s(%i) : getLastCudaError():%s\n", file, line, cudaGetErrorString(result));
assert(result == cudaSuccess);
}
return result;
}

void dump_cuda_array_to_file(double* cuda_array,
void dump_cuda_array_to_file(const double* cuda_array,
int width,
int hight,
const std::string& filename)
Expand Down
44 changes: 35 additions & 9 deletions source/module_hamilt_lcao/module_gint/kernels/cuda/cuda_tools.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,47 @@
#include <iostream>
#include <sstream>

#define checkCuda(val) check(val, #val, __FILE__, __LINE__)
#define checkCudaLastError() __checkCudaLastError(__FILE__, __LINE__)
#define checkCuda(val) check((val), #val, __FILE__, __LINE__)
#define checkCudaLastError() __getLastCudaError(__FILE__, __LINE__)

cudaError_t check(cudaError_t result, const char *const func, const char *const file, const int line);
cudaError_t __checkCudaLastError(const char *file, const int line);
inline void check(cudaError_t result, char const *const func, const char *const file,
int const line) {
if (result) {
fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n", file, line,
static_cast<unsigned int>(result), cudaGetErrorString(result), func);
exit(EXIT_FAILURE);
}
}

inline void __getLastCudaError(const char *file,
const int line)
{
cudaError_t err = cudaGetLastError();

if (cudaSuccess != err) {
fprintf(stderr,
"%s(%i) : getLastCudaError() CUDA error :"
" (%d) %s.\n",
file, line, static_cast<int>(err),
cudaGetErrorString(err));
exit(EXIT_FAILURE);
}
}

void dump_cuda_array_to_file(double* cuda_array,
static inline int ceildiv(int x, int y)
{
return (x + y - 1) / y;
}

void dump_cuda_array_to_file(const double* cuda_array,
int width,
int hight,
const std::string& filename);

inline int ceil_div(int a, int b)
{
return (a + b - 1) / b;
}
// inline int ceil_div(int a, int b)
// {
// return (a + b - 1) / b;
// }

/*
* @brief: A simple wrapper for cudaMalloc and cudaFree, sync and async CUDA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,6 @@ static __global__ void vbatched_gemm_kernel(int* M,
alpha_tmp);
}

static inline int ceildiv(int x, int y)
{
return (x + y - 1) / y;
}

/**
* Performs a batched matrix multiplication using the vbatched_gemm_impl
* function.
Expand Down
Loading
Loading