Skip to content

Commit a18f0f2

Browse files
authored
Merge branch 'deepmodeling:develop' into develop
2 parents 3aa510e + 6b91689 commit a18f0f2

79 files changed

Lines changed: 1644 additions & 2993 deletions

File tree

Some content is hidden

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

.github/workflows/devcontainer.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
matrix:
1818
dockerfile: ["gnu","intel","cuda"]
1919
steps:
20+
- name: Force Clean Workspace
21+
run: |
22+
sudo chattr -i -R ${{ github.workspace }} 2>/dev/null || true
23+
sudo chown -R $USER:$USER ${{ github.workspace }}
24+
sudo find ${{ github.workspace }} -mindepth 1 -delete
25+
2026
- name: Checkout
2127
uses: actions/checkout@v6
2228

doxygen/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ HAVE_DOT = YES
23122312
# Minimum value: 0, maximum value: 32, default value: 0.
23132313
# This tag requires that the tag HAVE_DOT is set to YES.
23142314

2315-
DOT_NUM_THREADS = 0
2315+
DOT_NUM_THREADS = 2
23162316

23172317
# When you want a differently looking font in the dot files that doxygen
23182318
# generates you can specify the font name using DOT_FONTNAME. You need to make

python/pyabacus/src/ModuleBase/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ list(APPEND pymodule_base
55
${BASE_PATH}/kernels/math_kernel_op_vec.cpp
66
${BASE_PATH}/module_device/memory_op.cpp
77
${BASE_PATH}/module_device/device.cpp
8+
${BASE_PATH}/module_device/device_helpers.cpp
89
)
910

1011
pybind11_add_module(_base_pack MODULE ${pymodule_base})

python/pyabacus/src/ModuleNAO/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# add nao shared library
1+
# add nao shared library
22
list(APPEND _naos
33
${NAO_PATH}/atomic_radials.cpp
44
${NAO_PATH}/beta_radials.cpp
@@ -19,6 +19,7 @@ list(APPEND _naos
1919
# ${ABACUS_SOURCE_DIR}/source_psi/kernels/psi_memory_op.cpp
2020
${ABACUS_SOURCE_DIR}/source_base/module_device/memory_op.cpp
2121
${ABACUS_SOURCE_DIR}/source_base/module_device/device.cpp
22+
${ABACUS_SOURCE_DIR}/source_base/module_device/device_helpers.cpp
2223
)
2324
add_library(naopack SHARED
2425
${_naos}

python/pyabacus/src/hsolver/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ list(APPEND _diago
1616
${BASE_PATH}/kernels/math_kernel_op_vec.cpp
1717
${BASE_PATH}/kernels/math_ylm_op.cpp
1818
${BASE_PATH}/module_device/device.cpp
19+
${BASE_PATH}/module_device/device_helpers.cpp
1920
${BASE_PATH}/module_device/memory_op.cpp
20-
21+
2122
${PSI_PATH}/psi.cpp
2223
)
2324
add_library(diagopack SHARED

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ list(APPEND device_srcs
4343
# source_psi/kernels/device.cpp
4444

4545
source_base/module_device/device.cpp
46+
source_base/module_device/device_helpers.cpp
4647
source_base/module_device/output_device.cpp
4748
source_base/module_device/memory_op.cpp
4849
source_base/kernels/math_kernel_op.cpp

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ OBJS_BASE=abfs-vector3_order.o\
176176
broyden_mixing.o\
177177
memory_op.o\
178178
device.o\
179+
device_helpers.o\
179180
output_device.o\
180181
parallel_2d.o\
181182

source/source_base/kernels/cuda/math_kernel_op.cu

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ struct GetTypeThrust<std::complex<double>> {
2727
static cublasHandle_t cublas_handle = nullptr;
2828

2929
void xdot_wrapper(const int &n, const float * x, const int &incx, const float * y, const int &incy, float &result) {
30-
cublasErrcheck(cublasSdot(cublas_handle, n, x, incx, y, incy, &result));
30+
CHECK_CUBLAS(cublasSdot(cublas_handle, n, x, incx, y, incy, &result));
3131
}
3232

3333
void xdot_wrapper(const int &n, const double * x, const int &incx, const double * y, const int &incy, double &result) {
34-
cublasErrcheck(cublasDdot(cublas_handle, n, x, incx, y, incy, &result));
34+
CHECK_CUBLAS(cublasDdot(cublas_handle, n, x, incx, y, incy, &result));
3535
}
3636

3737
void createGpuBlasHandle(){
3838
if (cublas_handle == nullptr) {
39-
cublasErrcheck(cublasCreate(&cublas_handle));
39+
CHECK_CUBLAS(cublasCreate(&cublas_handle));
4040
}
4141
}
4242

4343
void destoryBLAShandle(){
4444
if (cublas_handle != nullptr) {
45-
cublasErrcheck(cublasDestroy(cublas_handle));
45+
CHECK_CUBLAS(cublasDestroy(cublas_handle));
4646
cublas_handle = nullptr;
4747
}
4848
}
@@ -58,7 +58,7 @@ void scal_op<float, base_device::DEVICE_GPU>::operator()(const int& N,
5858
std::complex<float>* X,
5959
const int& incx)
6060
{
61-
cublasErrcheck(cublasCscal(cublas_handle, N, (float2*)alpha, (float2*)X, incx));
61+
CHECK_CUBLAS(cublasCscal(cublas_handle, N, (float2*)alpha, (float2*)X, incx));
6262
}
6363

6464
template <>
@@ -67,7 +67,7 @@ void scal_op<double, base_device::DEVICE_GPU>::operator()(const int& N,
6767
std::complex<double>* X,
6868
const int& incx)
6969
{
70-
cublasErrcheck(cublasZscal(cublas_handle, N, (double2*)alpha, (double2*)X, incx));
70+
CHECK_CUBLAS(cublasZscal(cublas_handle, N, (double2*)alpha, (double2*)X, incx));
7171
}
7272

7373
template <>
@@ -78,7 +78,7 @@ void axpy_op<double, base_device::DEVICE_GPU>::operator()(const int& N,
7878
double* Y,
7979
const int& incY)
8080
{
81-
cublasErrcheck(cublasDaxpy(cublas_handle, N, alpha, X, incX, Y, incY));
81+
CHECK_CUBLAS(cublasDaxpy(cublas_handle, N, alpha, X, incX, Y, incY));
8282
}
8383

8484
template <>
@@ -89,7 +89,7 @@ void axpy_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const int
8989
std::complex<float>* Y,
9090
const int& incY)
9191
{
92-
cublasErrcheck(cublasCaxpy(cublas_handle, N, (float2*)alpha, (float2*)X, incX, (float2*)Y, incY));
92+
CHECK_CUBLAS(cublasCaxpy(cublas_handle, N, (float2*)alpha, (float2*)X, incX, (float2*)Y, incY));
9393
}
9494

9595
template <>
@@ -100,7 +100,7 @@ void axpy_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const in
100100
std::complex<double>* Y,
101101
const int& incY)
102102
{
103-
cublasErrcheck(cublasZaxpy(cublas_handle, N, (double2*)alpha, (double2*)X, incX, (double2*)Y, incY));
103+
CHECK_CUBLAS(cublasZaxpy(cublas_handle, N, (double2*)alpha, (double2*)X, incX, (double2*)Y, incY));
104104
}
105105

106106

@@ -175,7 +175,7 @@ void gemv_op<double, base_device::DEVICE_GPU>::operator()(const char& trans,
175175
const int& incy)
176176
{
177177
cublasOperation_t cutrans = judge_trans_op(false, trans, "gemv_op");
178-
cublasErrcheck(cublasDgemv(cublas_handle, cutrans, m, n, alpha, A, lda, X, incx, beta, Y, incx));
178+
CHECK_CUBLAS(cublasDgemv(cublas_handle, cutrans, m, n, alpha, A, lda, X, incx, beta, Y, incx));
179179
}
180180

181181
template <>
@@ -194,7 +194,7 @@ void gemv_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const cha
194194
cublasOperation_t cutrans = judge_trans_op(true, trans, "gemv_op");
195195
cuFloatComplex alpha = make_cuFloatComplex(alpha_in->real(), alpha_in->imag());
196196
cuFloatComplex beta = make_cuFloatComplex(beta_in->real(), beta_in->imag());
197-
cublasErrcheck(cublasCgemv(cublas_handle, cutrans, m, n, &alpha, (cuFloatComplex*)A, lda, (cuFloatComplex*)X, incx, &beta, (cuFloatComplex*)Y, incx));
197+
CHECK_CUBLAS(cublasCgemv(cublas_handle, cutrans, m, n, &alpha, (cuFloatComplex*)A, lda, (cuFloatComplex*)X, incx, &beta, (cuFloatComplex*)Y, incx));
198198
}
199199

200200
template <>
@@ -215,7 +215,7 @@ void gemv_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const ch
215215
cuDoubleComplex beta = make_cuDoubleComplex(beta_in->real(), beta_in->imag());
216216
// icpc and nvcc have some compatible problems
217217
// We must use cuDoubleComplex instead of converting std::complex<double>* to cuDoubleComplex*
218-
cublasErrcheck(cublasZgemv(cublas_handle, cutrans, m, n, &alpha, (cuDoubleComplex*)A, lda, (cuDoubleComplex*)X, incx, &beta, (cuDoubleComplex*)Y, incx));
218+
CHECK_CUBLAS(cublasZgemv(cublas_handle, cutrans, m, n, &alpha, (cuDoubleComplex*)A, lda, (cuDoubleComplex*)X, incx, &beta, (cuDoubleComplex*)Y, incx));
219219
}
220220

221221
template <>
@@ -235,7 +235,7 @@ void gemm_op<float, base_device::DEVICE_GPU>::operator()(const char& transa,
235235
{
236236
cublasOperation_t cutransA = judge_trans_op(false, transa, "gemm_op");
237237
cublasOperation_t cutransB = judge_trans_op(false, transb, "gemm_op");
238-
cublasErrcheck(cublasSgemm(cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
238+
CHECK_CUBLAS(cublasSgemm(cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
239239
}
240240

241241
template <>
@@ -255,7 +255,7 @@ void gemm_op<double, base_device::DEVICE_GPU>::operator()(const char& transa,
255255
{
256256
cublasOperation_t cutransA = judge_trans_op(false, transa, "gemm_op");
257257
cublasOperation_t cutransB = judge_trans_op(false, transb, "gemm_op");
258-
cublasErrcheck(cublasDgemm(cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
258+
CHECK_CUBLAS(cublasDgemm(cublas_handle, cutransA, cutransB, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc));
259259
}
260260
template <>
261261
void gemm_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const char& transa,
@@ -274,7 +274,7 @@ void gemm_op<std::complex<float>, base_device::DEVICE_GPU>::operator()(const cha
274274
{
275275
cublasOperation_t cutransA = judge_trans_op(true, transa, "gemm_op");
276276
cublasOperation_t cutransB = judge_trans_op(true, transb, "gemm_op");
277-
cublasErrcheck(cublasCgemm(cublas_handle, cutransA, cutransB, m, n ,k, (float2*)alpha, (float2*)a , lda, (float2*)b, ldb, (float2*)beta, (float2*)c, ldc));
277+
CHECK_CUBLAS(cublasCgemm(cublas_handle, cutransA, cutransB, m, n ,k, (float2*)alpha, (float2*)a , lda, (float2*)b, ldb, (float2*)beta, (float2*)c, ldc));
278278
}
279279

280280
template <>
@@ -294,7 +294,7 @@ void gemm_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const ch
294294
{
295295
cublasOperation_t cutransA = judge_trans_op(true, transa, "gemm_op");
296296
cublasOperation_t cutransB = judge_trans_op(true, transb, "gemm_op");
297-
cublasErrcheck(cublasZgemm(cublas_handle, cutransA, cutransB, m, n ,k, (double2*)alpha, (double2*)a , lda, (double2*)b, ldb, (double2*)beta, (double2*)c, ldc));
297+
CHECK_CUBLAS(cublasZgemm(cublas_handle, cutransA, cutransB, m, n ,k, (double2*)alpha, (double2*)a , lda, (double2*)b, ldb, (double2*)beta, (double2*)c, ldc));
298298
}
299299

300300
template <>
@@ -311,15 +311,15 @@ void matrixTranspose_op<double, base_device::DEVICE_GPU>::operator()(const int&
311311
double ONE = 1.0, ZERO = 0.0;
312312

313313
// use 'geam' API todo transpose.
314-
cublasErrcheck(cublasDgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row, &ONE, input_matrix, col, &ZERO, input_matrix, col, device_temp, col));
314+
CHECK_CUBLAS(cublasDgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row, &ONE, input_matrix, col, &ZERO, input_matrix, col, device_temp, col));
315315
}
316316
else
317317
{
318318
int thread = 1024;
319319
int block = (row + col + thread - 1) / thread;
320320
matrix_transpose_kernel<double> <<<block, thread >>> (row, col, input_matrix, device_temp);
321321

322-
cudaCheckOnDebug();
322+
CHECK_CUDA_SYNC();
323323
}
324324

325325
base_device::memory::synchronize_memory_op<double, base_device::DEVICE_GPU, base_device::DEVICE_GPU>()(
@@ -348,7 +348,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
348348
ZERO.x = ZERO.y = 0.0;
349349

350350
// use 'geam' API todo transpose.
351-
cublasErrcheck(cublasCgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row,
351+
CHECK_CUBLAS(cublasCgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row,
352352
reinterpret_cast<const float2 *>(&ONE), (float2*)input_matrix, col,
353353
reinterpret_cast<const float2 *>(&ZERO), (float2*)input_matrix, col, (float2*)device_temp, col));
354354
} else
@@ -357,7 +357,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
357357
int block = (row + col + thread - 1) / thread;
358358
matrix_transpose_kernel<thrust::complex<float>> <<<block, thread >>> (row, col, (thrust::complex<float>*)input_matrix, (thrust::complex<float>*)device_temp);
359359

360-
cudaCheckOnDebug();
360+
CHECK_CUDA_SYNC();
361361
}
362362

363363
base_device::memory::synchronize_memory_op<std::complex<float>, base_device::DEVICE_GPU, base_device::DEVICE_GPU>()(
@@ -367,7 +367,7 @@ void matrixTranspose_op<std::complex<float>, base_device::DEVICE_GPU>::operator(
367367

368368
base_device::memory::delete_memory_op<std::complex<float>, base_device::DEVICE_GPU>()(device_temp);
369369

370-
cudaCheckOnDebug();
370+
CHECK_CUDA_SYNC();
371371

372372
}
373373

@@ -389,13 +389,13 @@ void matrixTranspose_op<std::complex<double>, base_device::DEVICE_GPU>::operator
389389
ZERO.x = ZERO.y = 0.0;
390390

391391
// use 'geam' API todo transpose.
392-
cublasErrcheck(cublasZgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row, &ONE, (double2*)input_matrix, col, &ZERO, (double2*)input_matrix, col, (double2*)device_temp, col));
392+
CHECK_CUBLAS(cublasZgeam(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N, col, row, &ONE, (double2*)input_matrix, col, &ZERO, (double2*)input_matrix, col, (double2*)device_temp, col));
393393
} else
394394
{
395395
int thread = 1024;
396396
int block = (row + col + thread - 1) / thread;
397397
matrix_transpose_kernel<thrust::complex<double>> <<<block, thread >>> (row, col, (thrust::complex<double>*)input_matrix, (thrust::complex<double>*)device_temp);
398-
cudaCheckOnDebug();
398+
CHECK_CUDA_SYNC();
399399
}
400400

401401
base_device::memory::synchronize_memory_op<std::complex<double>,
@@ -416,7 +416,7 @@ void matrixCopy<double, base_device::DEVICE_GPU>::operator()(const int& n1,
416416
const dim3 blockSize(16, 16);
417417
const dim3 gridSize((n1 + blockSize.x - 1) / blockSize.x, (n2 + blockSize.y - 1) / blockSize.y);
418418
matrix_copy_kernel<double> <<<gridSize, blockSize >>> (n1, n2, A, LDA, B, LDB);
419-
cudaCheckOnDebug();
419+
CHECK_CUDA_SYNC();
420420
}
421421
template <>
422422
void matrixCopy<std::complex<float>, base_device::DEVICE_GPU>::operator()(const int& n1,
@@ -429,7 +429,7 @@ void matrixCopy<std::complex<float>, base_device::DEVICE_GPU>::operator()(const
429429
const dim3 blockSize(16, 16);
430430
const dim3 gridSize((n1 + blockSize.x - 1) / blockSize.x, (n2 + blockSize.y - 1) / blockSize.y);
431431
matrix_copy_kernel<thrust::complex<float>> <<<gridSize, blockSize >>> (n1, n2, reinterpret_cast<const thrust::complex<float>*>(A), LDA, reinterpret_cast<thrust::complex<float>*>(B), LDB);
432-
cudaCheckOnDebug();
432+
CHECK_CUDA_SYNC();
433433

434434
}
435435
template <>
@@ -443,7 +443,7 @@ void matrixCopy<std::complex<double>, base_device::DEVICE_GPU>::operator()(const
443443
const dim3 blockSize(16, 16);
444444
const dim3 gridSize((n1 + blockSize.x - 1) / blockSize.x, (n2 + blockSize.y - 1) / blockSize.y);
445445
matrix_copy_kernel<thrust::complex<double>> <<<gridSize, blockSize >>> (n1, n2, reinterpret_cast<const thrust::complex<double>*>(A), LDA, reinterpret_cast<thrust::complex<double>*>(B), LDB);
446-
cudaCheckOnDebug();
446+
CHECK_CUDA_SYNC();
447447
}
448448

449449
template <>
@@ -453,7 +453,7 @@ void matrix_mul_vector_op<double, base_device::DEVICE_GPU>::operator()(const int
453453
dim3 block((m + thread.x - 1) / thread.x, (n + thread.y - 1) / thread.y, 1);
454454
matrix_multiply_vector_kernel<double, double> <<<block, thread >>>(m, n, a, lda,
455455
b, alpha, c, ldc);
456-
cudaCheckOnDebug();
456+
CHECK_CUDA_SYNC();
457457
}
458458

459459
template <>
@@ -463,7 +463,7 @@ void matrix_mul_vector_op<std::complex<float>, base_device::DEVICE_GPU>::operato
463463
dim3 block((m + thread.x - 1) / thread.x, (n + thread.y - 1) / thread.y, 1);
464464
matrix_multiply_vector_kernel<thrust::complex<float>, float> <<<block, thread >>>(m, n, reinterpret_cast<thrust::complex<float>*>(a), lda,
465465
b, alpha, reinterpret_cast<thrust::complex<float>*>(c), ldc);
466-
cudaCheckOnDebug();
466+
CHECK_CUDA_SYNC();
467467
}
468468

469469
template <>
@@ -474,7 +474,7 @@ void matrix_mul_vector_op<std::complex<double>, base_device::DEVICE_GPU>::operat
474474
dim3 block((m + thread.x - 1) / thread.x, (n + thread.y - 1) / thread.y, 1);
475475
matrix_multiply_vector_kernel<thrust::complex<double>, double> <<<block, thread >>>(m, n, reinterpret_cast<thrust::complex<double>*>(a), lda,
476476
b, alpha, reinterpret_cast<thrust::complex<double>*>(c), ldc);
477-
cudaCheckOnDebug();
477+
CHECK_CUDA_SYNC();
478478
}
479479

480480
// Explicitly instantiate functors for the types of functor registered.

0 commit comments

Comments
 (0)