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

Refactor: new gint module #5869

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open

Conversation

dzzz2001
Copy link
Collaborator

Background

The original module_gint was disorganized, with input and output for different grid integration tasks mixed together. Additionally, the overall framework for grid integration was poorly structured. This PR rewrites the grid integration framework. The new code is located under source/module_hamilt_lcao/module_gint/new_gint.

Since the new code is not yet complete—GPU version grid integration, for example, has not been implemented in this PR—it is considered an experimental PR. Only a portion of the old grid integration interfaces have been replaced with the new grid integration interfaces and the old grid integration code will be retained until the new grid integration code is fully completed, at which point it will be removed. Moreover, the new grid integration code will only be compiled when -DNEW_GINT is set during CMake configuration.

Unit Tests and/or Case Tests for my changes

  • unit test is in progress.

What's changed?

  • add new module_gint code, if -DNEW_GINT is set during CMake configuration, some interfaces of old version of module_gint will be replaced with new version.
  • the commit 414446a is not appropriate. After discussing with the commit author @A-006, I revert this commit in this PR.

Performance Comparison

Based on current testing, the new grid integration code shows slightly higher efficiency due to more detailed optimizations。 Below are the results from running the si64 in tests/performance on my computer using OMP_NUM_THREADS=4 mpirun -n 4 abacus:

cal_gint_vl cal_gint_rho cal_gint_force
old module_gint 10.44 9.62 2.91
new module_gint 8.83 8.85 2.36

@dzzz2001 dzzz2001 requested a review from mohanchen January 18, 2025 14:07
@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes labels Jan 19, 2025
source/module_base/vector3.h Show resolved Hide resolved
source/module_esolver/esolver_ks_lcao.cpp Show resolved Hide resolved
source/module_esolver/esolver_ks_lcao.h Outdated Show resolved Hide resolved
source/module_hamilt_lcao/module_gint/new_gint/biggrid.cpp Outdated Show resolved Hide resolved
source/module_hamilt_lcao/module_gint/new_gint/gint.h Outdated Show resolved Hide resolved
void Veff<OperatorLCAO<TK, TR>>::contributeHR()
if(this->nspin == 2)
{
this->current_spin = 1 - this->current_spin;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is a bit strange, may need to rewrite

std::vector<double> ddphi_zz;
ModuleBase::matrix* fvl_thread = nullptr;
ModuleBase::matrix* svl_thread = nullptr;
if(isforce_)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it is a better design to let 'isforce_' and 'isstress_' parameters to be input parameters of this function 'cal_fvl_svl_()', and enforce them to be 'const'

dphi_x.resize(phi_len);
dphi_y.resize(phi_len);
dphi_z.resize(phi_len);
dphi_x_DM.resize(phi_len);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to use 'dm' instead of 'DM' in the new grid integral code.

phi_op.set_phi_dphi(nullptr, dphi_x.data(), dphi_y.data(), dphi_z.data());
for (int is = 0; is < nspin_; is++)
{
phi_op.phi_mul_dm(dphi_x.data(), *DMRGint_vec_[is], true, dphi_x_DM.data());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to use 'dmr_gint' instead of 'DMRGint'

//========================
double dr3_;

std::shared_ptr<HContainer<double>> hRGint_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use 'hr_gint_'instead of 'hRGint_'?

public:
// constructor
UnitCellInfo(
Vec3d unitcell_vec1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to 'const Vec3d &unitcell_vec1'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants