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

Feature: Add PEXSI Support for Gamma Only LCAO Calculation #3561

Merged
merged 73 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
69ad6a7
feat pexsi
zhangzh-pku Apr 30, 2023
3c57992
fix : diag not completed
zhangzh-pku Apr 30, 2023
7326a00
Merge branch 'deepmodeling:develop' into develop
zhangzh-pku May 2, 2023
c3babb7
feat
zhangzh-pku May 3, 2023
43d743d
feat: pexsi hsolver
zhangzh-pku May 11, 2023
51e4df2
Merge branch 'deepmodeling:develop' into develop
zhangzh-pku May 11, 2023
ef1ff1a
CMake building implemented
Flying-dragon-boxing Nov 17, 2023
48c03ab
Merge remote-tracking branch 'upstream/develop' into develop
Flying-dragon-boxing Dec 7, 2023
2529afe
Works
Flying-dragon-boxing Dec 7, 2023
09da6b1
adapt to the new container
Flying-dragon-boxing Jan 15, 2024
f52bd99
Turn off USE_PEXSI
Flying-dragon-boxing Jan 15, 2024
682d19b
Update LibRI to 553c91c
Flying-dragon-boxing Jan 16, 2024
a5ea7e1
Merge remote-tracking branch into develop
Flying-dragon-boxing Jan 17, 2024
90f600e
modify include files
Flying-dragon-boxing Jan 17, 2024
3d8c366
namespace-ize
Flying-dragon-boxing Jan 22, 2024
8075b14
new inputs added
Flying-dragon-boxing Jan 24, 2024
1e428d2
Configure Makefile Compiling, fix typos
Flying-dragon-boxing Jan 26, 2024
1264b64
Fix Makefile Intel toolchains compile errors
Flying-dragon-boxing Jan 26, 2024
a694146
Fix even more PEXSI related Makefile compiling issues
Flying-dragon-boxing Jan 26, 2024
4c4bd76
Merge remote-tracking branch 'upstream/develop' into modify_inputs
Flying-dragon-boxing Jan 28, 2024
cd3a028
Modify inputs and update to latest version (#2)
Flying-dragon-boxing Jan 28, 2024
6aa019c
Revert "Modify inputs and update to latest version"
Flying-dragon-boxing Jan 28, 2024
7561bfa
Merge pull request #3 from Flying-dragon-boxing/revert-2-modify_inputs
Flying-dragon-boxing Jan 28, 2024
3202786
Merge pull request #4 from Flying-dragon-boxing/modify_inputs
Flying-dragon-boxing Jan 28, 2024
c4c5272
Update FindPEXSI.cmake to fix Comments
Flying-dragon-boxing Jan 28, 2024
f3e18a4
Fix CI errors
Flying-dragon-boxing Jan 29, 2024
4d16f56
Fix CI Errors and Merge with Upstream
Flying-dragon-boxing Jan 29, 2024
86217fd
Merge branch 'develop' into develop
Flying-dragon-boxing Jan 29, 2024
4857553
Resolve Pull Request Reviews
Flying-dragon-boxing Feb 1, 2024
89ff055
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 1, 2024
494c661
Merge remote-tracking branch 'origin/develop' into develop
Flying-dragon-boxing Feb 1, 2024
70d68d9
Fix parallel communication related issue
Flying-dragon-boxing Feb 1, 2024
c0066fe
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 2, 2024
5b4a6cf
Fix vars in Makefile.vars, add input tests and comments for pexsi vars
Flying-dragon-boxing Feb 3, 2024
43ca04b
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 3, 2024
493f713
Fix nspin > 1 cases
Flying-dragon-boxing Feb 3, 2024
c7efb18
Merge remote-tracking branch 'origin/develop' into develop
Flying-dragon-boxing Feb 3, 2024
7f4e526
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 3, 2024
26685cd
Improvement: take calculated mu as new initial guess, may slightly im…
Flying-dragon-boxing Feb 3, 2024
2cf6773
Fix mistakes in the last commit
Flying-dragon-boxing Feb 3, 2024
7298c41
Fix: params and features
Flying-dragon-boxing Feb 6, 2024
9ee7aec
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 6, 2024
ce18c08
fix empty lines
Flying-dragon-boxing Feb 6, 2024
c4d86a4
Fix: move params to pexsi_solver, rename USE_PEXSI to ENABLE_PEXSI
Flying-dragon-boxing Feb 7, 2024
5b406b9
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 7, 2024
b33a37b
Docs: added docs for pexsi inputs
Flying-dragon-boxing Feb 7, 2024
8da04fc
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 19, 2024
b5ad8af
Merge branch 'develop' into develop
Flying-dragon-boxing Feb 26, 2024
0829198
Merge branch 'develop' into develop
Flying-dragon-boxing Mar 30, 2024
94ff925
Fix unit test issues in input_conv
Flying-dragon-boxing Mar 30, 2024
11f0a12
Change default pexsi_npole from 80 to 40
Flying-dragon-boxing Mar 31, 2024
fd19b2c
Place pexsi_EDM in DensityMatrix, set size of pexsi_dm = 1 when Globa…
Flying-dragon-boxing Mar 31, 2024
aec57c0
An unit test added for DiagoPexsi
Flying-dragon-boxing Mar 31, 2024
a4efc59
Merge branch 'develop' into develop
mohanchen Apr 8, 2024
2167ba5
Merge branch 'develop' into develop
Flying-dragon-boxing Apr 9, 2024
70f9a54
modify for changed gint interface
Flying-dragon-boxing Apr 9, 2024
5a891f7
correct nspin related behaviors
Flying-dragon-boxing Apr 9, 2024
d7b402d
add efermi passthrough
Flying-dragon-boxing Apr 9, 2024
76774f6
Revert "add efermi passthrough"
Flying-dragon-boxing Apr 9, 2024
9f8532a
Merge branch 'develop' into resolve_conflict
Flying-dragon-boxing Apr 13, 2024
9e8c724
commits to resolve conversations related to codes
Flying-dragon-boxing Apr 13, 2024
569269b
DM and EDM pointers in pexsi now handled by diagopexsi, and copying h…
Flying-dragon-boxing Apr 13, 2024
f8352cb
add pexsi examples
Flying-dragon-boxing Apr 13, 2024
b0ef9ad
fix pexsi unit test (original version shouldn't run)
Flying-dragon-boxing Apr 13, 2024
5b53d6f
add building docs for pexsi
Flying-dragon-boxing Apr 17, 2024
3e5fea8
Merge branch 'develop' into resolve_conflict
Flying-dragon-boxing Apr 17, 2024
69b774a
Merge branch 'develop' into resolve_conflict
Flying-dragon-boxing Apr 18, 2024
110e5b0
set cxx standard to c++14, which is required in make_unique
Flying-dragon-boxing Apr 18, 2024
1ced552
Merge branch 'develop' into resolve_conflict
Flying-dragon-boxing May 3, 2024
e874a84
Merge branch 'develop' into resolve_conflict
Flying-dragon-boxing May 11, 2024
696d01c
Merge branch 'develop' into resolve_conflict
mohanchen May 12, 2024
04db1c1
Merge branch 'develop' into resolve_conflict
WHUweiqingzhou May 14, 2024
29f1efc
Merge branch 'develop' into resolve_conflict
mohanchen May 14, 2024
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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(COMMIT_INFO "Print commit information in log" ON)
option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method." ON)
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage." OFF)
option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF)
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)



Expand Down Expand Up @@ -208,6 +209,13 @@ if(ENABLE_LCAO)
if (ENABLE_FFT_TWO_CENTER)
add_compile_definitions(USE_NEW_TWO_CENTER)
endif()

if(ENABLE_PEXSI)
find_package(PEXSI REQUIRED)
target_link_libraries(${ABACUS_BIN_NAME} ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} pexsi)
include_directories(${PEXSI_INCLUDE_DIR} ${ParMETIS_INCLUDE_DIR})
add_compile_definitions(__PEXSI)
endif()
else()
set(ENABLE_DEEPKS OFF)
set(ENABLE_LIBRI OFF)
Expand Down
57 changes: 57 additions & 0 deletions cmake/FindPEXSI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
###############################################################################
# - Find PEXSI
# Find PEXSI and its dependencies.
#
# PEXSI_FOUND - True if pexsi is found.
# PEXSI_INCLUDE_DIR - Where to find pexsi headers.
# PEXSI_LIBRARY - pexsi library.
# ParMETIS_INCLUDE_DIR - Where to find pexsi headers.
# ParMETIS_LIBRARY - parmetis library.
# METIS_LIBRARY - metis library.
# SuperLU_DIST_LIBRARY - superlu_dist library.

find_path(PEXSI_INCLUDE_DIR
NAMES c_pexsi_interface.h
HINTS ${PEXSI_DIR}
PATH_SUFFIXES "include"
)

find_library(PEXSI_LIBRARY
NAMES pexsi
HINTS ${PEXSI_DIR}
PATH_SUFFIXES "lib"
)

find_path(ParMETIS_INCLUDE_DIR
NAMES metis.h parmetis.h
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "include"
)

find_library(METIS_LIBRARY
NAMES metis
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "lib"
)

find_library(ParMETIS_LIBRARY
NAMES parmetis
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "lib"
)

find_library(SuperLU_DIST_LIBRARY
NAMES superlu_dist
HINTS ${SuperLU_DIST_DIR}
PATH_SUFFIXES "lib"
)

# Handle the QUIET and REQUIRED arguments and
# set PEXSI_FOUND to TRUE if all variables are non-zero.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PEXSI DEFAULT_MSG PEXSI_LIBRARY PEXSI_INCLUDE_DIR ParMETIS_LIBRARY METIS_LIBRARY SuperLU_DIST_LIBRARY)


# Copy the results to the output variables and target.
mark_as_advanced(PEXSI_LIBRARY PEXSI_INCLUDE_DIR ParMETIS_LIBRARY SuperLU_DIST_LIBRARY)

165 changes: 165 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,30 @@
- [qo\_strategy](#qo_strategy)
- [qo\_screening\_coeff](#qo_screening_coeff)
- [qo\_thr](#qo_thr)
- [PEXSI](#PEXSI)
- [pexsi_npole](#pexsi_npole)
- [pexsi_inertia](#pexsi_inertia)
- [pexsi_nmax](#pexsi_nmax)
- [pexsi_comm](#pexsi_comm)
- [pexsi_storage](#pexsi_storage)
- [pexsi_ordering](#pexsi_ordering)
- [pexsi_row_ordering](#pexsi_row_ordering)
- [pexsi_nproc](#pexsi_nproc)
- [pexsi_symm](#pexsi_symm)
- [pexsi_trans](#pexsi_trans)
- [pexsi_method](#pexsi_method)
- [pexsi_nproc_pole](#pexsi_nproc_pole)
- [pexsi_temp](#pexsi_temp)
- [pexsi_gap](#pexsi_gap)
- [pexsi_delta_e](#pexsi_delta_e)
- [pexsi_mu_lower](#pexsi_mu_lower)
- [pexsi_mu_upper](#pexsi_mu_upper)
- [pexsi_mu](#pexsi_mu)
- [pexsi_mu_thr](#pexsi_mu_thr)
- [pexsi_mu_expand](#pexsi_mu_expand)
- [pexsi_mu_guard](#pexsi_mu_guard)
- [pexsi_elec_thr](#pexsi_elec_thr)
- [pexsi_zero_thr](#pexsi_zero_thr)

[back to top](#full-list-of-input-keywords)

Expand Down Expand Up @@ -3549,5 +3573,146 @@ These variables are used to control the usage of QO analysis. Please note presen
- **Description**: the convergence threshold determining the cutoff of generated orbital. Lower threshold will yield orbital with larger cutoff radius.
- **Default**: 1.0e-6

## PEXSI

These variables are used to control the usage of PEXSI (Pole Expansion and Selected Inversion) method in calculations.

### pexsi_npole

- **Type**: Integer
- **Description**: the number of poles used in the pole expansion method, should be a even number.
- **Default**: 80

### pexsi_inertia

- **Type**: Boolean
- **Description**: whether inertia counting is used at the very beginning.
- **Default**: True

### pexsi_nmax

- **Type**: Integer
- **Description**: maximum number of PEXSI iterations after each inertia counting procedure.
- **Default**: 80

### pexsi_comm

- **Type**: Boolean
- **Description**: whether to construct PSelInv communication pattern.
- **Default**: True

### pexsi_storage

- **Type**: Boolean
- **Description**: whether to use symmetric storage space used by the Selected Inversion algorithm for symmetric matrices.
- **Default**: True

### pexsi_ordering

- **Type**: Integer
- **Description**: ordering strategy for factorization and selected inversion. 0: Parallel ordering using ParMETIS, 1: Sequential ordering using METIS, 2: Multiple minimum degree ordering
- **Default**: 0

### pexsi_row_ordering

- **Type**: Integer
- **Description**: row permutation strategy for factorization and selected inversion, 0: No row permutation, 1: Make the diagonal entry of the matrix larger than the off-diagonal entries.
- **Default**: 1

### pexsi_nproc

- **Type**: Integer
- **Description**: number of processors for PARMETIS. Only used if pexsi_ordering == 0.
- **Default**: 1

### pexsi_symm

- **Type**: Boolean
- **Description**: whether the matrix is symmetric.
- **Default**: True

### pexsi_trans

- **Type**: Boolean
- **Description**: whether to factorize the transpose of the matrix.
- **Default**: False

### pexsi_method

- **Type**: Integer
- **Description**: the pole expansion method to be used. 1 for Cauchy Contour Integral method, 2 for Moussa optimized method.
- **Default**: 1

### pexsi_nproc_pole

- **Type**: Integer
- **Description**: the point parallelizaion of PEXSI. Recommend two points parallelization.
- **Default**: 1

### pexsi_temp

- **Type**: Real
- **Description**: temperature in Fermi-Dirac distribution, in Ry, should have the same effect as the smearing sigma when smearing method is set to Fermi-Dirac.
- **Default**: 0.015

### pexsi_gap

- **Type**: Real
- **Description**: spectral gap, this can be set to be 0 in most cases.
- **Default**: 0

### pexsi_delta_e

- **Type**: Real
- **Description**: an upper bound for the spectral radius of $S^{-1} H$.
- **Default**: 20

### pexsi_mu_lower

- **Type**: Real
- **Description**: initial guess of lower bound for mu.
- **Default**: -10

### pexsi_mu_upper

- **Type**: Real
- **Description**: initial guess of upper bound for mu.
- **Default**: 10

### pexsi_mu

- **Type**: Real
- **Description**: initial guess for mu (for the solver).
- **Default**: 0

### pexsi_mu_thr

- **Type**: Real
- **Description**: stopping criterion in terms of the chemical potential for the inertia counting procedure.
- **Default**: 0.05

### pexsi_mu_expand

- **Type**: Real
- **Description**: if the chemical potential is not in the initial interval, the interval is expanded by this value.
- **Default**: 0.3

### pexsi_mu_guard

- **Type**: Real
- **Description**: safe guard criterion in terms of the chemical potential to reinvoke the inertia counting procedure.
- **Default**: 0.2

### pexsi_elec_thr

- **Type**: Real
- **Description**: stopping criterion of the PEXSI iteration in terms of the number of electrons compared to numElectronExact.
- **Default**: 0.001

### pexsi_zero_thr

- **Type**: Real
- **Description**: if the absolute value of CCS matrix element is less than this value, it will be considered as zero.
- **Default**: 1e-10

[back to top](#full-list-of-input-keywords)
7 changes: 7 additions & 0 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ ifdef DeePMD_DIR
INCLUDES += -I${TensorFlow_INCLUDE_DIR}
endif

ifdef PEXSI_DIR
OBJS_ABACUS += ${OBJS_HSOLVER_PEXSI}
INCLUDES += -I${PEXSI_DIR}/include -I${PARMETIS_DIR}/include -I${DSUPERLU_DIR}/include
LIBS += -L${PEXSI_DIR}/lib -lpexsi -L${DSUPERLU_DIR}/lib -lsuperlu_dist -L${PARMETIS_DIR}/lib -lparmetis -lmetis
HONG += -D__PEXSI
endif

include Makefile.Objects

#==========================
Expand Down
11 changes: 10 additions & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ VPATH=./src_global:\
./module_hsolver:\
./module_hsolver/kernels:\
./module_hsolver/genelpa:\
./module_hsolver/module_pexsi:\
./module_elecstate:\
./module_elecstate/kernels:\
./module_elecstate/potentials:\
Expand Down Expand Up @@ -102,6 +103,7 @@ ${OBJS_VDW}\
${OBJS_DFTU}\
${OBJS_DELTASPIN}\
${OBJS_TENSOR}\
${OBJS_HSOLVER_PEXSI}\

OBJS_MAIN=main.o\
driver.o\
Expand Down Expand Up @@ -292,7 +294,7 @@ OBJS_HSOLVER=diago_cg.o\
diago_iter_assist.o\
math_kernel_op.o\
dngvd_op.o\

OBJS_HSOLVER_LCAO=hsolver_lcao.o\
diago_blas.o\
diago_elpa.o\
Expand All @@ -301,6 +303,13 @@ OBJS_HSOLVER_LCAO=hsolver_lcao.o\
elpa_new_complex.o\
utils.o\

OBJS_HSOLVER_PEXSI=diago_pexsi.o\
pexsi_solver.o\
simple_pexsi.o\
dist_bcd_matrix.o\
dist_ccs_matrix.o\
dist_matrix_transformer.o\

OBJS_MD=fire.o\
langevin.o\
md_base.o\
Expand Down
5 changes: 5 additions & 0 deletions source/Makefile.vars
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ CEREAL_DIR = /usr/local/include/cereal
## To use LIBXC: set LIBXC_DIR which contains include and lib/libxc.a (>5.1.7)
## To use DeePMD: set DeePMD_DIR and TensorFlow_DIR
## To use LibRI: set LIBRI_DIR and LIBCOMM_DIR
## To use PEXSI: set PEXSI_DIR DSUPERLU_DIR and PARMETIS_DIR
##---------------------------------------------------------------------

# LIBTORCH_DIR = /usr/local
Expand All @@ -72,6 +73,10 @@ CEREAL_DIR = /usr/local/include/cereal
# LIBRI_DIR = /public/software/LibRI
# LIBCOMM_DIR = /public/software/LibComm

# PEXSI_DIR = /public/software/pexsi
# DSUPERLU_DIR = /public/software/superlu_dist
# PARMETIS_DIR = /public/software/parmetis

##---------------------------------------------------------------------
# NP = 14 # It is not supported. use make -j14 or make -j to parallelly compile
# DEBUG = OFF
Expand Down
2 changes: 1 addition & 1 deletion source/module_base/global_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ T ddot_real(
//==========================================================
static inline bool IS_COLUMN_MAJOR_KS_SOLVER()
{
return GlobalV::KS_SOLVER=="genelpa" || GlobalV::KS_SOLVER=="scalapack_gvx" || GlobalV::KS_SOLVER=="cusolver" || GlobalV::KS_SOLVER=="cg_in_lcao";
return GlobalV::KS_SOLVER=="genelpa" || GlobalV::KS_SOLVER=="scalapack_gvx" || GlobalV::KS_SOLVER=="cusolver" || GlobalV::KS_SOLVER=="cg_in_lcao" || GlobalV::KS_SOLVER=="pexsi";
}

}//namespace GlobalFunc
Expand Down
6 changes: 3 additions & 3 deletions source/module_basis/module_ao/ORB_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void ORB_control::setup_2d_division(std::ofstream& ofs_running,
ofs_running << "\n SETUP THE DIVISION OF H/S MATRIX" << std::endl;

// (1) calculate nrow, ncol, nloc.
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao")
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao" || ks_solver == "pexsi")
{
ofs_running << " divide the H&S matrix using 2D block algorithms." << std::endl;
#ifdef __MPI
Expand All @@ -205,7 +205,7 @@ void ORB_control::setup_2d_division(std::ofstream& ofs_running,
bool div_2d;
if (ks_solver == "lapack" || ks_solver == "cg" || ks_solver == "dav") div_2d = false;
#ifdef __MPI
else if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao") div_2d = true;
else if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao" || ks_solver == "pexsi") div_2d = true;
#endif
else
{
Expand Down Expand Up @@ -382,7 +382,7 @@ assert(nb2d > 0);
}

// init blacs context for genelpa
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao")
if (ks_solver == "genelpa" || ks_solver == "scalapack_gvx" || ks_solver == "cusolver" || ks_solver == "cg_in_lcao" || ks_solver == "pexsi")
{
pv->set_desc(nlocal, nlocal, pv->nrow);
pv->set_desc_wfc_Eij(nlocal, nbands, pv->nrow);
Expand Down
Loading