Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion source/source_lcao/module_gint/gint.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Gint {
std::vector<hamilt::HContainer<double>*> DMRGint;

//! tmp tools used in transfer_DM2DtoGrid
hamilt::HContainer<double>* DMRGint_full = nullptr;
hamilt::HContainer<double>* DM2D_tmp = nullptr;

std::vector<hamilt::HContainer<double>> pvdpRx_reduced;
std::vector<hamilt::HContainer<double>> pvdpRy_reduced;
Expand Down
100 changes: 60 additions & 40 deletions source/source_lcao/module_gint/gint_old.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Gint::~Gint() {
delete this->hRGint_tmp[is];
}
#ifdef __MPI
delete this->DMRGint_full;
delete this->DM2D_tmp;
Comment thread
zgn-26714 marked this conversation as resolved.
Outdated
#endif
}

Expand Down Expand Up @@ -171,10 +171,9 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons
this->hRGint_tmp[is] = new hamilt::HContainer<double>(ucell_in.nat);
}
#ifdef __MPI
if (this->DMRGint_full != nullptr) {
delete this->DMRGint_full;
if (this->DM2D_tmp != nullptr) {
delete this->DM2D_tmp;
}
this->DMRGint_full = new hamilt::HContainer<double>(ucell_in.nat);
#endif
}

Expand Down Expand Up @@ -210,12 +209,6 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons
ModuleBase::Memory::record("Gint::DMRGint",
this->DMRGint[0]->get_memory_size()
* this->DMRGint.size()*nspin);
#ifdef __MPI
this->DMRGint_full->insert_ijrs(this->gridt->get_ijr_info(), ucell_in, npol);
this->DMRGint_full->allocate(nullptr, true);
ModuleBase::Memory::record("Gint::DMRGint_full",
this->DMRGint_full->get_memory_size());
#endif
}
}

Expand All @@ -231,9 +224,7 @@ void Gint::reset_DMRGint(const int& nspin)
{
for (auto& d : this->DMRGint) { d->allocate(nullptr, false); }
#ifdef __MPI
delete this->DMRGint_full;
this->DMRGint_full = new hamilt::HContainer<double>(*this->hRGint);
this->DMRGint_full->allocate(nullptr, false);
delete this->DM2D_tmp;
#endif
}
}
Expand Down Expand Up @@ -262,37 +253,66 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
} else // NSPIN=4 case
{
#ifdef __MPI
hamilt::transferParallels2Serials(*DM2D[0], this->DMRGint_full);
#else
this->DMRGint_full = DM2D[0];
#endif
std::vector<double*> tmp_pointer(4, nullptr);
for (int iap = 0; iap < this->DMRGint_full->size_atom_pairs(); ++iap) {
auto& ap = this->DMRGint_full->get_atom_pair(iap);
int iat1 = ap.get_atom_i();
int iat2 = ap.get_atom_j();
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
for (int is = 0; is < 4; is++) {
tmp_pointer[is] = this->DMRGint[is]
->find_matrix(iat1, iat2, r_index)
->get_pointer();
}
double* data_full = ap.get_pointer(ir);
for (int irow = 0; irow < ap.get_row_size(); irow += 2) {
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer[0])++ = data_full[icol];
*(tmp_pointer[1])++ = data_full[icol + 1];
}
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer[2])++ = data_full[icol];
*(tmp_pointer[3])++ = data_full[icol + 1];
int mg = DM2D[0]->get_paraV()->get_global_row_size()/2;
int ng = DM2D[0]->get_paraV()->get_global_col_size()/2;
int nb = DM2D[0]->get_paraV()->get_block_size()/2;
int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt;
int *iat2iwt = new int[ucell->nat];
for (int iat = 0; iat < ucell->nat; iat++) {
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
}
Parallel_Orbitals *pv = new Parallel_Orbitals();
pv->set(mg, ng, nb, blacs_ctxt);
pv->set_atomic_trace(iat2iwt, ucell->nat, mg);
auto ijr_info = DM2D[0]->get_ijr_info();
this-> DM2D_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
for (int is = 0; is < 4; is++){
for (int iap = 0; iap < DM2D[0]->size_atom_pairs(); ++iap) {
auto& ap = DM2D[0]->get_atom_pair(iap);
int iat1 = ap.get_atom_i();
int iat2 = ap.get_atom_j();
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
double* tmp_pointer = this -> DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
double* data_full = ap.get_pointer(ir);
for (int irow = 0; irow < ap.get_row_size(); irow += 2) {
switch (is) {//todo: It can be written more compactly
case 0:
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol];
}
data_full += ap.get_col_size() * 2;
break;
case 1:
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol + 1];
}
data_full += ap.get_col_size() * 2;
break;
case 2:
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol];
}
data_full += ap.get_col_size();
break;
case 3:
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol + 1];
}
data_full += ap.get_col_size();
break;
}
}
data_full += ap.get_col_size();
}
}
hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]);
}
#else
//this->DMRGint_full = DM2D[0];
#endif
}
ModuleBase::timer::tick("Gint", "transfer_DMR");
}
91 changes: 57 additions & 34 deletions source/source_lcao/module_gint/temp_gint/gint_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,44 +163,67 @@ void transfer_dm_2d_to_gint(
} else // NSPIN=4 case
{
#ifdef __MPI
const int npol = 2;
HContainer<T> dm_full = gint_info.get_hr<T>(npol);
hamilt::transferParallels2Serials(*dm[0], &dm_full);
#else
HContainer<T>& dm_full = *(dm[0]);
#endif
std::vector<T*> tmp_pointer(4, nullptr);
for (int iap = 0; iap < dm_full.size_atom_pairs(); iap++)
{
auto& ap = dm_full.get_atom_pair(iap);
const int iat1 = ap.get_atom_i();
const int iat2 = ap.get_atom_j();
for (int ir = 0; ir < ap.get_R_size(); ir++)
{
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
for (int is = 0; is < 4; is++)
{
tmp_pointer[is] =
dm_gint[is].find_matrix(iat1, iat2, r_index)->get_pointer();
}
T* data_full = ap.get_pointer(ir);
for (int irow = 0; irow < ap.get_row_size(); irow += 2)
{
for (int icol = 0; icol < ap.get_col_size(); icol += 2)
{
*(tmp_pointer[0])++ = data_full[icol];
*(tmp_pointer[1])++ = data_full[icol + 1];
}
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2)
{
*(tmp_pointer[2])++ = data_full[icol];
*(tmp_pointer[3])++ = data_full[icol + 1];
int mg = dm[0]->get_paraV()->get_global_row_size()/2;
int ng = dm[0]->get_paraV()->get_global_col_size()/2;
int nb = dm[0]->get_paraV()->get_block_size()/2;
int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt;
const UnitCell* ucell = gint_info.get_ucell();
int *iat2iwt = new int[ucell->nat];
Comment thread
zgn-26714 marked this conversation as resolved.
Outdated
for (int iat = 0; iat < ucell->nat; iat++) {
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
}
Parallel_Orbitals *pv = new Parallel_Orbitals();
pv->set(mg, ng, nb, blacs_ctxt);
pv->set_atomic_trace(iat2iwt, ucell->nat, mg);
auto ijr_info = dm[0]->get_ijr_info();
HContainer<T>* DM2D_tmp = new hamilt::HContainer<T>(pv, nullptr, &ijr_info);
//ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
for (int is = 0; is < 4; is++){
for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) {
auto& ap = dm[0]->get_atom_pair(iap);
int iat1 = ap.get_atom_i();
int iat2 = ap.get_atom_j();
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
T* tmp_pointer = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
T* data_full = ap.get_pointer(ir);
for (int irow = 0; irow < ap.get_row_size(); irow += 2) {
switch (is) {//todo: It can be written more compactly
case 0:
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol];
}
data_full += ap.get_col_size() * 2;
break;
case 1:
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol + 1];
}
data_full += ap.get_col_size() * 2;
break;
case 2:
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol];
}
data_full += ap.get_col_size();
break;
case 3:
data_full += ap.get_col_size();
for (int icol = 0; icol < ap.get_col_size(); icol += 2) {
*(tmp_pointer)++ = data_full[icol + 1];
}
data_full += ap.get_col_size();
break;
}
}
data_full += ap.get_col_size();
}
}
hamilt::transferParallels2Serials( *DM2D_tmp, &dm_gint[is]);
}
#else
//HContainer<T>& dm_full = *(dm[0]);
#endif
}
ModuleBase::timer::tick("Gint", "transfer_dm_2d_to_gint");
}
Expand Down
1 change: 1 addition & 0 deletions source/source_lcao/module_gint/temp_gint/gint_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class GintInfo
const std::vector<int>& get_trace_lo() const{ return trace_lo_; }
int get_lgd() const { return lgd_; }
int get_nat() const { return ucell_->nat; } // return the number of atoms in the unitcell
const UnitCell* get_ucell() const { return ucell_; }
int get_local_mgrid_num() const { return localcell_info_->get_mgrids_num(); }
double get_mgrid_volume() const { return meshgrid_info_->get_volume(); }

Expand Down
4 changes: 2 additions & 2 deletions source/source_lcao/module_lr/utils/gint_move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Gint& Gint::operator=(Gint&& rhs)
this->pvdpRz_reduced = std::move(rhs.pvdpRz_reduced);
this->DMRGint = std::move(rhs.DMRGint);
this->hRGint_tmp = std::move(rhs.hRGint_tmp);
this->DMRGint_full = rhs.DMRGint_full;
rhs.DMRGint_full = nullptr;
this->DM2D_tmp = rhs.DM2D_tmp;
rhs.DM2D_tmp = nullptr;

return *this;
}
Expand Down
Loading