@@ -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