Skip to content

Commit e6c8391

Browse files
committed
fix bug of init_com_orbitals
1 parent 67d2ce9 commit e6c8391

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

source/module_hamilt_pw/hamilt_stodft/sto_wf.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ void Stochastic_WF<T, Device>::init_com_orbitals()
248248
delete[] npwip;
249249
}
250250
delete[] totnpw;
251+
// allocate chi0
252+
Device* ctx = {};
253+
if (base_device::get_device_type<Device>(ctx) == base_device::GpuDevice)
254+
{
255+
this->chi0 = new psi::Psi<T, Device>(nks, this->nchip_max, npwx, this->ngk);
256+
}
257+
else
258+
{
259+
this->chi0 = reinterpret_cast<psi::Psi<T, Device>*>(this->chi0_cpu);
260+
}
251261
}
252262
#else
253263
template <typename T, typename Device>
@@ -269,6 +279,17 @@ void Stochastic_WF<T, Device>::init_com_orbitals()
269279
this->chi0_cpu->operator()(ik, ichi, ichi) = 1;
270280
}
271281
}
282+
283+
// allocate chi0
284+
Device* ctx = {};
285+
if (base_device::get_device_type<Device>(ctx) == base_device::GpuDevice)
286+
{
287+
this->chi0 = new psi::Psi<T, Device>(nks, this->nchip_max, npwx, this->ngk);
288+
}
289+
else
290+
{
291+
this->chi0 = reinterpret_cast<psi::Psi<T, Device>*>(this->chi0_cpu);
292+
}
272293
}
273294
#endif
274295
template <typename T, typename Device>

0 commit comments

Comments
 (0)