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
8 changes: 4 additions & 4 deletions source/source_pw/module_pwdft/hamilt_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void HamiltPW<T, Device>::sPsi(const T* psi_in, // psi
this->ppcell->nkb,
&one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
psi_in,
inc,
&zero,
Expand All @@ -288,7 +288,7 @@ void HamiltPW<T, Device>::sPsi(const T* psi_in, // psi
npw,
&one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
psi_in,
nrow,
&zero,
Expand Down Expand Up @@ -360,7 +360,7 @@ void HamiltPW<T, Device>::sPsi(const T* psi_in, // psi
this->ppcell->nkb,
&one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
ps,
inc,
&one,
Expand All @@ -376,7 +376,7 @@ void HamiltPW<T, Device>::sPsi(const T* psi_in, // psi
this->ppcell->nkb,
&one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
ps,
this->ppcell->nkb,
&one,
Expand Down
8 changes: 4 additions & 4 deletions source/source_pw/module_pwdft/op_pw_nl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void Nonlocal<OperatorPW<T, Device>>::add_nonlocal_pp(T *hpsi_in, const T *becp,
this->ppcell->nkb,
&this->one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
this->ps,
inc,
&this->one,
Expand All @@ -197,7 +197,7 @@ void Nonlocal<OperatorPW<T, Device>>::add_nonlocal_pp(T *hpsi_in, const T *becp,
this->ppcell->nkb,
&this->one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
this->ps,
npm,
&this->one,
Expand Down Expand Up @@ -251,7 +251,7 @@ void Nonlocal<OperatorPW<T, Device>>::act(
nkb,
&this->one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
tmpsi_in,
inc,
&this->zero,
Expand All @@ -276,7 +276,7 @@ void Nonlocal<OperatorPW<T, Device>>::act(
this->npw,
&this->one,
this->vkb,
this->ppcell->vkb.nc,
this->ppcell->vkbnc,
tmpsi_in,
max_npw,
&this->zero,
Expand Down
11 changes: 9 additions & 2 deletions source/source_pw/module_pwdft/vnl_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,17 @@ void pseudopot_cell_vnl::init(const UnitCell& ucell,
// dq+4)*cell_factor;
this->lmaxq = 2 * this->lmaxkb + 1;
int npwx = this->wfcpw->npwk_max;
this->vkbnc = npwx;
if (nkb > 0 && allocate_vkb)
{
vkb.create(nkb, npwx);
ModuleBase::Memory::record("VNL::vkb", nkb * npwx * sizeof(std::complex<double>));
if (!this->use_gpu_)
{
vkb.create(nkb, npwx);
ModuleBase::Memory::record("VNL::vkb", nkb * npwx * sizeof(std::complex<double>));
}
// GPU path: vkb ComplexMatrix is not allocated.
// Column dimension is stored in vkbnc for gemm/gemv leading dimension.
// Actual GPU buffers (c_vkb/z_vkb) are allocated below.
}

// this->nqx = 10000; // calculted in allocate_nlpot.f90
Expand Down
4 changes: 4 additions & 0 deletions source/source_pw/module_pwdft/vnl_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ class pseudopot_cell_vnl
std::complex<double>*** vkb_alpha;
Structure_Factor* psf = nullptr;

// Column dimension of vkb matrix (= npwx), used as leading dimension in gemm/gemv.
// On GPU path vkb ComplexMatrix is not allocated to save CPU memory; this stores the dimension.
int vkbnc = 0;

// other variables
std::complex<double> Cal_C(int alpha, int lu, int mu, int L, int M);

Expand Down
5 changes: 5 additions & 0 deletions source/source_pw/module_pwdft/vnl_pw_grad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ void pseudopot_cell_vnl::getgradq_vnl(const UnitCell& ucell,

ModuleBase::YlmReal::grad_Ylm_Real(x1, npw, gk, ylm, dylm[0], dylm[1], dylm[2]);

// GPU path skips vkb allocation in init(); allocate now if needed
if (this->vkb.nc == 0 && this->nkb > 0 && this->vkbnc > 0) {
this->vkb.create(this->nkb, this->vkbnc);
Comment thread
Cstandardlib marked this conversation as resolved.
}

int jkb = 0;
for(int it = 0;it < ucell.ntype;it++)
{
Expand Down
Loading