Skip to content

symmetrize_rho slow on large systems for OFDFT #7724

Description

@Cstandardlib

Details

When calculating with esolver ofdft, a large part of total time is consumed by Symmetry::rhog_symmetry (up to 90%+ for large systems).
Symmetry::rhog_symmetry is called exactly once in ESolver_OF::before_opt:

    Symmetry_rho::symmetrize_rho(PARAM.inp.nspin, this->chr, this->pw_rho, ucell.symm);

    for (int is = 0; is < PARAM.inp.nspin; ++is)
    {
        if (PARAM.inp.init_chg != "file")
        {
            for (int ibs = 0; ibs < this->pw_rho->nrxx; ++ibs)
            {
                // Here we initialize rho to be uniform,
                // because the rho got by pot.init_pot -> Charge::atomic_rho may contain minus elements.
                this->chr.rho[is][ibs] = this->nelec_[is] / ucell.omega;
                this->pphi_[is][ibs] = sqrt(this->chr.rho[is][ibs]);
            }
        }
        else
        {
            for (int ibs = 0; ibs < this->pw_rho->nrxx; ++ibs)
            {
                this->pphi_[is][ibs] = sqrt(this->chr.rho[is][ibs]);
            }
        }
    }

When init_chg is set by default, i.e. the first if-branch, symmetrize_rho will be called anyway and the chr.rho is overwritten immediately.

Task list for Issue attackers (only for developers)

  • Reproduce the performance issue on a similar system or environment.
  • Identify the specific section of the code causing the performance issue.
  • Investigate the issue and determine the root cause.
  • Research best practices and potential solutions for the identified performance issue.
  • Implement the chosen solution to address the performance issue.
  • Test the implemented solution to ensure it improves performance without introducing new issues.
  • Optimize the solution if necessary, considering trade-offs between performance and other factors (e.g., code complexity, readability, maintainability).
  • Review and incorporate any relevant feedback from users or developers.
  • Merge the improved solution into the main codebase and notify the issue reporter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PerformanceIssues related to fail running ABACUS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions