Skip to content

Commit 5b44ef2

Browse files
chengleizhengclaude
andcommitted
Switch radial_fft_q to template version in addusdens_g to fix linker error
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b1bb759 commit 5b44ef2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

source/source_estate/elecstate_pw.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ void ElecStatePW<T, Device>::addusdens_g(const Real* becsum, T** rhog)
496496
const std::complex<double> ci_tpi = ModuleBase::NEG_IMAG_UNIT * ModuleBase::TWO_PI;
497497

498498
// ---------- all on CPU ----------
499-
// Use double for CPU computations (radial_fft_q non-template version takes double)
500499
std::vector<double> qmod_host(npw);
501500
std::vector<std::complex<double>> qgm_host(npw);
502501
for (int ig = 0; ig < npw; ig++)
@@ -514,8 +513,8 @@ void ElecStatePW<T, Device>::addusdens_g(const Real* becsum, T** rhog)
514513
delmem_var_op()(g_gpu);
515514
std::vector<Real> ylmk0_host(npw * lmaxq * lmaxq);
516515
syncmem_var_d2h_op()(ylmk0_host.data(), ylmk0_gpu, npw * lmaxq * lmaxq);
517-
ModuleBase::matrix ylm_mat(lmaxq * lmaxq, npw);
518-
for (int i = 0; i < npw * lmaxq * lmaxq; i++) ylm_mat.c[i] = static_cast<double>(ylmk0_host[i]);
516+
std::vector<double> ylmk0_double(npw * lmaxq * lmaxq);
517+
for (int i = 0; i < npw * lmaxq * lmaxq; i++) ylmk0_double[i] = static_cast<double>(ylmk0_host[i]);
519518

520519
for (int it = 0; it < ucell->ntype; it++)
521520
{
@@ -566,8 +565,9 @@ void ElecStatePW<T, Device>::addusdens_g(const Real* becsum, T** rhog)
566565
{
567566
for (int jh = ih; jh < atom->ncpp.nh; jh++)
568567
{
569-
// CPU radial_fft_q (non-template version, double)
570-
this->ppcell->radial_fft_q(npw, ih, jh, it, qmod_host.data(), ylm_mat, qgm_host.data());
568+
// CPU radial_fft_q (template version, DEVICE_CPU)
569+
this->ppcell->template radial_fft_q<double, base_device::DEVICE_CPU>(
570+
nullptr, npw, ih, jh, it, qmod_host.data(), ylmk0_double.data(), qgm_host.data());
571571
for (int ig = 0; ig < npw; ig++)
572572
{
573573
rhog_host[ig] += static_cast<T>(qgm_host[ig] * aux2_host[ijh * npw + ig]);

0 commit comments

Comments
 (0)