Skip to content

Commit 7f6bf84

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into math-sphbes
2 parents fa16019 + 6975edd commit 7f6bf84

File tree

103 files changed

+7280
-3260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+7280
-3260
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ trim_trailing_whitespace = true
1010

1111
[*.yaml]
1212
indent_size = 2
13+
14+
[CMakeLists.txt]
15+
indent_style = space
16+
indent_size = 2

.github/workflows/build_test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ jobs:
2727
- name: Build
2828
run: |
2929
cmake -B build -DBUILD_TESTING=ON ${{ matrix.build_args }}
30-
cmake --build build -j4
31-
cmake --install build
30+
cmake --build build -j2

.github/workflows/container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- develop
77
- reconstruction
88
- newelpa
9-
9+
1010
jobs:
1111
build_container_and_push:
1212
runs-on: ubuntu-latest

.github/workflows/dynamic.yml

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,16 @@ on:
1111
default: '2'
1212

1313
jobs:
14-
start-runner:
15-
name: Start self-hosted EC2 runner
16-
runs-on: ubuntu-latest
17-
outputs:
18-
label: ${{ steps.start-ec2-runner.outputs.label }}
19-
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
20-
steps:
21-
- name: Configure AWS credentials
22-
uses: aws-actions/configure-aws-credentials@v1
23-
with:
24-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26-
aws-region: ${{ secrets.AWS_REGION }}
27-
- name: Start EC2 runner
28-
id: start-ec2-runner
29-
uses: machulav/ec2-github-runner@v2
30-
with:
31-
mode: start
32-
github-token: ${{ secrets.PAT }}
33-
ec2-image-id: ami-07758124f42f794bf
34-
ec2-instance-type: c5.4xlarge
35-
subnet-id: subnet-f7edb991
36-
security-group-id: sg-fd5185e7
3714
test:
3815
name: Do the job on the runner
39-
needs: start-runner # required to start the main job when the runner is ready
40-
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
16+
runs-on: self-hosted
4117
container: ghcr.io/deepmodeling/abacus-development-kit:gnu
4218
steps:
4319
- name: Checkout
4420
uses: actions/checkout@v2
4521
- name: Build and Test
4622
run: |
47-
cmake -B build -DENABLE_ASAN=1 -DBUILD_TESTING=ON
23+
cmake -B build -DENABLE_ASAN=1 -DBUILD_TESTING=ON -DENABLE_DEEPKS=1
4824
cmake --build build -j16
4925
cmake --install build
5026
cmake --build build --target test ARGS="-V"
@@ -55,24 +31,3 @@ jobs:
5531
build_dir: html
5632
env:
5733
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
stop-runner:
59-
name: Stop self-hosted EC2 runner
60-
needs:
61-
- start-runner # required to get output from the start-runner job
62-
- test # required to wait when the main job is done
63-
runs-on: ubuntu-latest
64-
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
65-
steps:
66-
- name: Configure AWS credentials
67-
uses: aws-actions/configure-aws-credentials@v1
68-
with:
69-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
70-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
71-
aws-region: ${{ secrets.AWS_REGION }}
72-
- name: Stop EC2 runner
73-
uses: machulav/ec2-github-runner@v2
74-
with:
75-
mode: stop
76-
github-token: ${{ secrets.PAT }}
77-
label: ${{ needs.start-runner.outputs.label }}
78-
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}

.github/workflows/static.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
clang-tidy:
8-
runs-on: ubuntu-latest
8+
runs-on: self-hosted
99
container: ghcr.io/deepmodeling/abacus-development-kit:gnu
1010
steps:
1111
- name: Checkout Pull Request

.github/workflows/test.yml

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,9 @@ on:
1010
- planewave
1111
jobs:
1212

13-
start-runner:
14-
name: Start self-hosted EC2 runner
15-
runs-on: ubuntu-latest
16-
outputs:
17-
label: ${{ steps.start-ec2-runner.outputs.label }}
18-
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
19-
steps:
20-
- name: Configure AWS credentials
21-
uses: aws-actions/configure-aws-credentials@v1
22-
with:
23-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
24-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
25-
aws-region: ${{ secrets.AWS_REGION }}
26-
- name: Start EC2 runner
27-
id: start-ec2-runner
28-
uses: machulav/ec2-github-runner@v2
29-
with:
30-
mode: start
31-
github-token: ${{ secrets.PAT }}
32-
ec2-image-id: ami-07758124f42f794bf
33-
ec2-instance-type: c5.2xlarge
34-
subnet-id: subnet-f7edb991
35-
security-group-id: sg-fd5185e7
3613
test:
3714
name: Do the job on the runner
38-
needs: start-runner # required to start the main job when the runner is ready
39-
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
15+
runs-on: self-hosted
4016
container: ghcr.io/deepmodeling/abacus-development-kit:gnu
4117
steps:
4218
- name: Checkout
@@ -48,27 +24,6 @@ jobs:
4824
GTEST_COLOR: 'yes'
4925
run: |
5026
cmake -B build -DBUILD_TESTING=ON
51-
cmake --build build -j16
27+
cmake --build build -j8
5228
cmake --install build
5329
cmake --build build --target test ARGS="-V"
54-
stop-runner:
55-
name: Stop self-hosted EC2 runner
56-
needs:
57-
- start-runner # required to get output from the start-runner job
58-
- test # required to wait when the main job is done
59-
runs-on: ubuntu-latest
60-
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
61-
steps:
62-
- name: Configure AWS credentials
63-
uses: aws-actions/configure-aws-credentials@v1
64-
with:
65-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
66-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
67-
aws-region: ${{ secrets.AWS_REGION }}
68-
- name: Stop EC2 runner
69-
uses: machulav/ec2-github-runner@v2
70-
with:
71-
mode: stop
72-
github-token: ${{ secrets.PAT }}
73-
label: ${{ needs.start-runner.outputs.label }}
74-
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}

CMakeLists.txt

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ find_package(MPI REQUIRED)
4242
include_directories(${MPI_CXX_INCLUDE_PATH})
4343
target_link_libraries(${ABACUS_BIN_NAME} MPI::MPI_CXX)
4444
add_compile_definitions(__MPI)
45+
list(APPEND math_libs MPI::MPI_CXX)
4546

4647
find_package(Threads REQUIRED)
4748
target_link_libraries(${ABACUS_BIN_NAME} Threads::Threads)
@@ -132,48 +133,41 @@ if(ENABLE_ASAN)
132133
-fsanitize=address
133134
)
134135
# `add_link_options` only affects executables added after.
135-
target_link_libraries(${ABACUS_BIN_NAME}
136-
-fsanitize=address
137-
)
136+
target_link_libraries(${ABACUS_BIN_NAME} -fsanitize=address)
138137
endif()
139138

140139
if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT)
141140
set(MKLROOT "$ENV{MKLROOT}")
142141
endif()
143142
if(MKLROOT)
144143
find_package(IntelMKL REQUIRED)
145-
add_definitions(-D__MKL -DMKL_ILP64)
144+
add_definitions(-D__MKL)
146145
include_directories(${MKL_INCLUDE_DIRS} ${MKL_INCLUDE_DIRS}/fftw)
147146

148147
# Since libtorch will find its own MKL, the fftw part conflicts with the original one.
149148
# When enable deepks, mkl will be linked within ${TORCH_LIBRARIES}.
150-
if(ENABLE_DEEPKS)
151-
target_link_libraries(${ABACUS_BIN_NAME}
152-
-lifcore
153-
# IntelMKL::MKL
154-
)
155-
else()
156-
target_link_libraries(${ABACUS_BIN_NAME}
157-
-lifcore
158-
IntelMKL::MKL
159-
)
149+
if(NOT ENABLE_DEEPKS)
150+
list(APPEND math_libs IntelMKL::MKL)
160151
endif()
161152
else()
162153
find_package(FFTW3 REQUIRED)
163154
find_package(LAPACK REQUIRED)
164155
find_package(ScaLAPACK REQUIRED)
165156
include_directories(${FFTW3_INCLUDE_DIRS})
166-
target_link_libraries(${ABACUS_BIN_NAME}
157+
list(APPEND math_libs
167158
FFTW3::FFTW3
168159
LAPACK::LAPACK
169160
ScaLAPACK::ScaLAPACK
170161
)
171-
if(CMAKE_COMPILER_IS_GNUCXX)
172-
target_link_libraries(${ABACUS_BIN_NAME}
173-
-lgfortran
174-
)
162+
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
163+
list(APPEND math_libs -lgfortran)
164+
elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel)
165+
list(APPEND math_libs -lifcore)
166+
else()
167+
message(WARNING "Cannot find the correct library for Fortran.")
175168
endif()
176169
endif()
170+
target_link_libraries(${ABACUS_BIN_NAME} ${math_libs})
177171

178172
if(ENABLE_DEEPKS)
179173
set(CMAKE_CXX_STANDARD 14)
@@ -245,22 +239,19 @@ IF (BUILD_TESTING)
245239
# https://cmake.org/cmake/help/latest/module/GoogleTest.html
246240
add_subdirectory(tests) # Contains integration tests
247241

242+
function(AddTest) # function for UT
243+
cmake_parse_arguments(UT "DYN" "TARGET" "LIBS;DYN_LIBS;STATIC_LIBS;SOURCES;DEPENDS" ${ARGN})
244+
add_executable(${UT_TARGET} ${UT_SOURCES})
245+
#dependencies & link library
246+
target_link_libraries(${UT_TARGET} ${UT_LIBS}
247+
OpenMP::OpenMP_CXX pthread GTest::gtest_main GTest::gmock_main)
248+
install(TARGETS ${UT_TARGET} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests )
249+
add_test(NAME ${UT_TARGET}
250+
COMMAND ${UT_TARGET}
251+
WORKING_DIRECTORY $<TARGET_FILE_DIR:${UT_TARGET}>
252+
)
253+
endfunction(AddTest)
248254
endif()
249-
function(AddTest)
250-
cmake_parse_arguments(UT "DYN" "TARGET" "LIBS;DYN_LIBS;STATIC_LIBS;SOURCES;DEPENDS" ${ARGN})
251-
add_executable(${UT_TARGET} ${UT_SOURCES})
252-
#dependencies & link library
253-
get_target_property(ABACUS_LINK_LIBRARIES ${ABACUS_BIN_NAME} LINK_LIBRARIES)
254-
target_link_libraries(${UT_TARGET} ${UT_LIBS} ${ABACUS_LINK_LIBRARIES}
255-
base cell symmetry md
256-
neighbor orb io ions lcao parallel mrrr pdiag pw ri driver
257-
pthread GTest::gtest_main GTest::gmock_main)
258-
install(TARGETS ${UT_TARGET} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests )
259-
add_test(NAME ${UT_TARGET}
260-
COMMAND ${UT_TARGET}
261-
WORKING_DIRECTORY $<TARGET_FILE_DIR:${UT_TARGET}>
262-
)
263-
endfunction(AddTest)
264255

265256
add_subdirectory(source)
266257

source/Makefile.Objects

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ run_lcao.o\
2121

2222
OBJS_PW=xc_type.o \
2323
xc_functional.o\
24-
xc_1.o\
25-
xc_2.o\
2624
xc_3.o \
2725
vdwd2.o\
2826
vdwd2_parameters.o\

source/src_pdiag/Cblacs.h renamed to source/module_base/blacs_connector.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,9 @@ extern "C"
3030
{
3131
void Cblacs_pinfo(int *myid, int *nprocs);
3232
void Cblacs_get(int icontxt, int what, int *val);
33-
void Cblacs_gridinit(int* icontxt, char *layout, int nprow, int npcol);
3433
void Cblacs_gridmap(int* icontxt, int *usermap, int ldumap, int nprow, int npcol);
35-
// Destruction
36-
void Cblacs_gridexit(int icontxt);
3734
// Informational and Miscellaneous
3835
void Cblacs_gridinfo(int icontxt, int* nprow, int *npcol, int *myprow, int *mypcol);
39-
int Cblacs_pnum(int icontxt, int prow, int pcol);
36+
int Cblacs_pnum(int icontxt, int prow, int pcol);
4037
void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol);
41-
void Cblacs_barrier(int icontxt, char *scope);
42-
// Point to Point
43-
void Cdgesd2d(int icontxt, int m, int n, double *a, int lda, int rdest, int cdest);
44-
void Cdgerv2d(int icontxt, int m, int n, double *a, int lda, int rsrc, int csrc);
45-
// Combine
46-
//void Cdgamx2d(int icontxt, int scope, int top, int m, int n,
47-
// double *a, int lda, int *ra, int *ca, int rcflag, int rdest, int cdest);
4838
}

source/module_base/blas_connector.h

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
extern "C"
77
{
8-
// level 1: std::vector-std::vector operations
8+
// level 1: std::vector-std::vector operations, O(n) data and O(n) work.
99

1010
// Peize Lin add ?scal 2016-08-04, to compute x=a*x
1111
void sscal_(const int *N, const float *alpha, float *X, const int *incX);
@@ -22,14 +22,20 @@ extern "C"
2222
void dcopy_(long const *n, const double *a, int const *incx, double *b, int const *incy);
2323
void zcopy_(long const *n, const std::complex<double> *a, int const *incx, std::complex<double> *b, int const *incy);
2424

25+
//reason for passing results as argument instead of returning it:
26+
//see https://www.numbercrunch.de/blog/2014/07/lost-in-translation/
2527
void zdotc_(std::complex<double> *result, const int *n, const std::complex<double> *zx,
2628
const int *incx, const std::complex<double> *zy, const int *incy);
27-
2829
// Peize Lin add ?dot 2017-10-27, to compute d=x*y
2930
float sdot_(const int *N, const float *X, const int *incX, const float *Y, const int *incY);
3031
double ddot_(const int *N, const double *X, const int *incX, const double *Y, const int *incY);
3132

32-
// level 2: matrix-std::vector operations
33+
// Peize Lin add ?nrm2 2018-06-12, to compute out = ||x||_2 = \sqrt{ \sum_i x_i**2 }
34+
float snrm2_( const int *n, const float *X, const int *incX );
35+
double dnrm2_( const int *n, const double *X, const int *incX );
36+
double dznrm2_( const int *n, const std::complex<double> *X, const int *incX );
37+
38+
// level 2: matrix-std::vector operations, O(n^2) data and O(n^2) work.
3339
void dgemv_(const char *transa, const int *m, const int *n, const double *alpha, const double *a,
3440
const int *lda, const double *x, const int *incx, const double *beta, double *y, const int *incy);
3541

@@ -41,10 +47,15 @@ extern "C"
4147
const double *alpha, const double *a, const int *lda,
4248
const double *x, const int *incx,
4349
const double *beta, double *y, const int *incy);
44-
45-
// level 3: matrix-matrix operations
50+
51+
// A := alpha x * y.T + A
52+
void dger_(int *m, int *n, double *alpha, double *x, int *incx, double *y, int *incy, double *a, int *lda);
53+
void zgerc_(int *m, int *n, std::complex<double> *alpha,std::complex<double> *x, int *incx, std::complex<double> *y, int *incy,std::complex<double> *a, int *lda);
54+
55+
// level 3: matrix-matrix operations, O(n^2) data and O(n^3) work.
4656

47-
// Peize Lin add ?gemm 2017-10-27, to compute C = a * A.? * B.? + b * C
57+
// Peize Lin add ?gemm 2017-10-27, to compute C = a * A.? * B.? + b * C
58+
// A is general
4859
void sgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k,
4960
const float *alpha, const float *a, const int *lda, const float *b, const int *ldb,
5061
const float *beta, float *c, const int *ldc);
@@ -54,27 +65,21 @@ extern "C"
5465
void zgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k,
5566
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda, const std::complex<double> *b, const int *ldb,
5667
const std::complex<double> *beta, std::complex<double> *c, const int *ldc);
57-
68+
69+
//a is symmetric
5870
void dsymm_(const char *side, const char *uplo, const int *m, const int *n,
5971
const double *alpha, const double *a, const int *lda, const double *b, const int *ldb,
6072
const double *beta, double *c, const int *ldc);
61-
73+
//a is hermitian
6274
void zhemm_(char *side, char *uplo, int *m, int *n,std::complex<double> *alpha,
6375
std::complex<double> *a, int *lda, std::complex<double> *b, int *ldb, std::complex<double> *beta, std::complex<double> *c, int *ldc);
6476

77+
//solving triangular matrix with multiple right hand sides
6578
void dtrsm_(char *side, char* uplo, char *transa, char *diag, int *m, int *n,
6679
double* alpha, double* a, int *lda, double*b, int *ldb);
67-
6880
void ztrsm_(char *side, char* uplo, char *transa, char *diag, int *m, int *n,
6981
std::complex<double>* alpha, std::complex<double>* a, int *lda, std::complex<double>*b, int *ldb);
7082

71-
// Peize Lin add ?nrm2 2018-06-12, to compute out = ||x||_2 = \sqrt{ \sum_i x_i**2 }
72-
float snrm2_( const int *n, const float *X, const int *incX );
73-
double dnrm2_( const int *n, const double *X, const int *incX );
74-
double dznrm2_( const int *n, const std::complex<double> *X, const int *incX );
75-
// Peize Lin add zherk 2019-04-14
76-
// if trans=='N': C = a * A * A.H + b * C
77-
// if trans=='C': C = a * A.H * A + b * C
7883
};
7984

8085
// Class BlasConnector provide the connector to fortran lapack routine.
@@ -137,7 +142,6 @@ class BlasConnector
137142
{
138143
return sdot_(&n, X, &incX, Y, &incY);
139144
}
140-
141145
static inline
142146
double dot( const int n, const double *X, const int incX, const double *Y, const int incY)
143147
{
@@ -191,7 +195,8 @@ class BlasConnector
191195
{
192196
return dznrm2_( &n, X, &incX );
193197
}
194-
198+
199+
// copies a into b
195200
static inline
196201
void copy(const long n, const double *a, const int incx, double *b, const int incy)
197202
{

0 commit comments

Comments
 (0)