Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory: modify hpsi interface in diagH_subspace_init func #4167

Merged
merged 6 commits into from
May 22, 2024
Merged
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
48 changes: 37 additions & 11 deletions source/module_hsolver/diago_iter_assist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,49 @@ void DiagoIterAssist<T, Device>::diagH_subspace_init(
// std::vector<T> hpsi(psi_temp.get_nbands() * psi_temp.get_nbasis());

// do hPsi for all bands
psi::Range all_bands_range(1, psi_temp.get_current_k(), 0, psi_temp.get_nbands()-1);
hpsi_info hpsi_in(&psi_temp, all_bands_range, hpsi);
if(pHamilt->ops == nullptr)
if (base_device::get_device_type(ctx) == base_device::GpuDevice)
{
ModuleBase::WARNING("DiagoIterAssist::diagH_subspace_init",
"Severe warning: Operators in Hamilt are not allocated yet, will return value of psi to evc directly\n");
for(int iband = 0; iband < evc.get_nbands(); iband++)
for (int i = 0; i < psi_temp.get_nbands(); i++)
{
for(int ig = 0; ig < evc.get_nbasis(); ig++)
psi::Range band_by_band_range(1, psi_temp.get_current_k(), i, i);
hpsi_info hpsi_in(&psi_temp, band_by_band_range, hpsi + i * psi_temp.get_nbasis());
if(pHamilt->ops == nullptr)
{
evc(iband, ig) = psi[iband * evc.get_nbasis() + ig];
ModuleBase::WARNING("DiagoIterAssist::diagH_subspace_init",
"Severe warning: Operators in Hamilt are not allocated yet, will return value of psi to evc directly\n");
for(int iband = 0; iband < evc.get_nbands(); iband++)
{
for(int ig = 0; ig < evc.get_nbasis(); ig++)
{
evc(iband, ig) = psi[iband * evc.get_nbasis() + ig];
}
en[iband] = 0.0;
}
return;
}
en[iband] = 0.0;
pHamilt->ops->hPsi(hpsi_in);
}
return;
}
pHamilt->ops->hPsi(hpsi_in);
else if (base_device::get_device_type(ctx) == base_device::CpuDevice)
{
psi::Range all_bands_range(1, psi_temp.get_current_k(), 0, psi_temp.get_nbands()-1);
hpsi_info hpsi_in(&psi_temp, all_bands_range, hpsi);
if(pHamilt->ops == nullptr)
{
ModuleBase::WARNING("DiagoIterAssist::diagH_subspace_init",
"Severe warning: Operators in Hamilt are not allocated yet, will return value of psi to evc directly\n");
for(int iband = 0; iband < evc.get_nbands(); iband++)
{
for(int ig = 0; ig < evc.get_nbasis(); ig++)
{
evc(iband, ig) = psi[iband * evc.get_nbasis() + ig];
}
en[iband] = 0.0;
}
return;
}
pHamilt->ops->hPsi(hpsi_in);
}

gemm_op<T, Device>()(
ctx,
Expand Down