diff --git a/source/Makefile.Objects b/source/Makefile.Objects index e034d476cb..fef10643cb 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -126,7 +126,9 @@ OBJS_MAIN=main.o\ OBJS_BASE=abfs-vector3_order.o\ assoc_laguerre.o\ - blas_connector.o\ + blas_connector_base.o\ + blas_connector_vector.o\ + blas_connector_matrix.o\ complexarray.o\ complexmatrix.o\ clebsch_gordan_coeff.o\ diff --git a/source/module_base/CMakeLists.txt b/source/module_base/CMakeLists.txt index e6b016b311..0d5088c28e 100644 --- a/source/module_base/CMakeLists.txt +++ b/source/module_base/CMakeLists.txt @@ -10,7 +10,9 @@ add_library( base OBJECT assoc_laguerre.cpp - blas_connector.cpp + blas_connector_base.cpp + blas_connector_vector.cpp + blas_connector_matrix.cpp clebsch_gordan_coeff.cpp complexarray.cpp complexmatrix.cpp diff --git a/source/module_base/blas_connector.h b/source/module_base/blas_connector.h index b6398bced3..7e988fd1bb 100644 --- a/source/module_base/blas_connector.h +++ b/source/module_base/blas_connector.h @@ -368,9 +368,26 @@ class BlasConnector #ifdef __CUDA +#include +#include "cublas_v2.h" + +// If you want to use cublas, you need these functions to create and destroy the cublas/hipblas handle. +// You also need to use these functions to translate the transpose parameter into cublas/hipblas datatype. + namespace BlasUtils{ - void createGpuBlasHandle(); - void destoryBLAShandle(); + + static cublasHandle_t cublas_handle = nullptr; + + void createGpuBlasHandle(); // Create a cublas/hipblas handle. + + void destoryBLAShandle(); // Destroy the cublas/hipblas handle. Do this when the software is about to end. + + cublasOperation_t judge_trans(bool is_complex, const char& trans, const char* name); // Translate a normal transpose parameter to a cublas/hipblas type. + + cublasSideMode_t judge_side(const char& trans); // Translate a normal side parameter to a cublas/hipblas type. + + cublasFillMode_t judge_fill(const char& trans); // Translate a normal fill parameter to a cublas/hipblas type. + } #endif diff --git a/source/module_base/blas_connector_base.cpp b/source/module_base/blas_connector_base.cpp new file mode 100644 index 0000000000..1d1a81db94 --- /dev/null +++ b/source/module_base/blas_connector_base.cpp @@ -0,0 +1,77 @@ +#include "blas_connector.h" +#include "macros.h" + +#ifdef __CUDA +#include +#include +#include "cublas_v2.h" +#include "module_base/kernels/math_kernel_op.h" +#include "module_base/module_device/memory_op.h" + + +namespace BlasUtils{ + + void createGpuBlasHandle(){ + if (cublas_handle == nullptr) { + cublasErrcheck(cublasCreate(&cublas_handle)); + } + } + + void destoryBLAShandle(){ + if (cublas_handle != nullptr) { + cublasErrcheck(cublasDestroy(cublas_handle)); + cublas_handle = nullptr; + } + } + + + cublasOperation_t judge_trans(bool is_complex, const char& trans, const char* name) + { + if (trans == 'N') + { + return CUBLAS_OP_N; + } + else if(trans == 'T') + { + return CUBLAS_OP_T; + } + else if(is_complex && trans == 'C') + { + return CUBLAS_OP_C; + } + return CUBLAS_OP_N; + } + + cublasSideMode_t judge_side(const char& trans) + { + if (trans == 'L') + { + return CUBLAS_SIDE_LEFT; + } + else if (trans == 'R') + { + return CUBLAS_SIDE_RIGHT; + } + return CUBLAS_SIDE_LEFT; + } + + cublasFillMode_t judge_fill(const char& trans) + { + if (trans == 'F') + { + return CUBLAS_FILL_MODE_FULL; + } + else if (trans == 'U') + { + return CUBLAS_FILL_MODE_UPPER; + } + else if (trans == 'D') + { + return CUBLAS_FILL_MODE_LOWER; + } + return CUBLAS_FILL_MODE_FULL; + } + +} // namespace BlasUtils + +#endif \ No newline at end of file diff --git a/source/module_base/blas_connector.cpp b/source/module_base/blas_connector_matrix.cpp similarity index 55% rename from source/module_base/blas_connector.cpp rename to source/module_base/blas_connector_matrix.cpp index d3b4cd4d6e..9beb7a7d59 100644 --- a/source/module_base/blas_connector.cpp +++ b/source/module_base/blas_connector_matrix.cpp @@ -12,328 +12,8 @@ #include "cublas_v2.h" #include "module_base/kernels/math_kernel_op.h" #include "module_base/module_device/memory_op.h" - - -namespace BlasUtils{ - - static cublasHandle_t cublas_handle = nullptr; - - void createGpuBlasHandle(){ - if (cublas_handle == nullptr) { - cublasErrcheck(cublasCreate(&cublas_handle)); - } - } - - void destoryBLAShandle(){ - if (cublas_handle != nullptr) { - cublasErrcheck(cublasDestroy(cublas_handle)); - cublas_handle = nullptr; - } - } - - - cublasOperation_t judge_trans(bool is_complex, const char& trans, const char* name) - { - if (trans == 'N') - { - return CUBLAS_OP_N; - } - else if(trans == 'T') - { - return CUBLAS_OP_T; - } - else if(is_complex && trans == 'C') - { - return CUBLAS_OP_C; - } - return CUBLAS_OP_N; - } - - cublasSideMode_t judge_side(const char& trans) - { - if (trans == 'L') - { - return CUBLAS_SIDE_LEFT; - } - else if (trans == 'R') - { - return CUBLAS_SIDE_RIGHT; - } - return CUBLAS_SIDE_LEFT; - } - - cublasFillMode_t judge_fill(const char& trans) - { - if (trans == 'F') - { - return CUBLAS_FILL_MODE_FULL; - } - else if (trans == 'U') - { - return CUBLAS_FILL_MODE_UPPER; - } - else if (trans == 'D') - { - return CUBLAS_FILL_MODE_LOWER; - } - return CUBLAS_FILL_MODE_FULL; - } - -} // namespace BlasUtils - -#endif - -void BlasConnector::axpy( const int n, const float alpha, const float *X, const int incX, float *Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - saxpy_(&n, &alpha, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasSaxpy(BlasUtils::cublas_handle, n, &alpha, X, incX, Y, incY)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::axpy( const int n, const double alpha, const double *X, const int incX, double *Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - daxpy_(&n, &alpha, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasDaxpy(BlasUtils::cublas_handle, n, &alpha, X, incX, Y, incY)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::axpy( const int n, const std::complex alpha, const std::complex *X, const int incX, std::complex *Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - caxpy_(&n, &alpha, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasCaxpy(BlasUtils::cublas_handle, n, (float2*)&alpha, (float2*)X, incX, (float2*)Y, incY)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::axpy( const int n, const std::complex alpha, const std::complex *X, const int incX, std::complex *Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - zaxpy_(&n, &alpha, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasZaxpy(BlasUtils::cublas_handle, n, (double2*)&alpha, (double2*)X, incX, (double2*)Y, incY)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -// x=a*x -void BlasConnector::scal( const int n, const float alpha, float *X, const int incX, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - sscal_(&n, &alpha, X, &incX); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasSscal(BlasUtils::cublas_handle, n, &alpha, X, incX)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::scal( const int n, const double alpha, double *X, const int incX, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - dscal_(&n, &alpha, X, &incX); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasDscal(BlasUtils::cublas_handle, n, &alpha, X, incX)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::scal( const int n, const std::complex alpha, std::complex *X, const int incX, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - cscal_(&n, &alpha, X, &incX); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasCscal(BlasUtils::cublas_handle, n, (float2*)&alpha, (float2*)X, incX)); - } #endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::scal( const int n, const std::complex alpha, std::complex *X, const int incX, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - zscal_(&n, &alpha, X, &incX); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - cublasErrcheck(cublasZscal(BlasUtils::cublas_handle, n, (double2*)&alpha, (double2*)X, incX)); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -// d=x*y -float BlasConnector::dot( const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - return sdot_(&n, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice){ - float result = 0.0; - cublasErrcheck(cublasSdot(BlasUtils::cublas_handle, n, X, incX, Y, incY, &result)); - return result; - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -double BlasConnector::dot( const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - return ddot_(&n, X, &incX, Y, &incY); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice){ - double result = 0.0; - cublasErrcheck(cublasDdot(BlasUtils::cublas_handle, n, X, incX, Y, incY, &result)); - return result; - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -// d=x*y -float BlasConnector::dotu(const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - return BlasConnector::dot(n, X, incX, Y, incY, device_type); -} - -double BlasConnector::dotu(const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - return BlasConnector::dot(n, X, incX, Y, incY, device_type); -} - -std::complex BlasConnector::dotu(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - const int incX2 = 2 * incX; - const int incY2 = 2 * incY; - const float*const x = reinterpret_cast(X); - const float*const y = reinterpret_cast(Y); - //Re(result)=Re(x)*Re(y)-Im(x)*Im(y) - //Im(result)=Re(x)*Im(y)+Im(x)*Re(y) - return std::complex( - BlasConnector::dot(n, x, incX2, y, incY2, device_type) - dot(n, x+1, incX2, y+1, incY2, device_type), - BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) + dot(n, x+1, incX2, y, incY2, device_type)); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} -std::complex BlasConnector::dotu(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - const int incX2 = 2 * incX; - const int incY2 = 2 * incY; - const double*const x = reinterpret_cast(X); - const double*const y = reinterpret_cast(Y); - //Re(result)=Re(x)*Re(y)-Im(x)*Im(y) - //Im(result)=Re(x)*Im(y)+Im(x)*Re(y) - return std::complex( - BlasConnector::dot(n, x, incX2, y, incY2, device_type) - dot(n, x+1, incX2, y+1, incY2, device_type), - BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) + dot(n, x+1, incX2, y, incY2, device_type)); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -// d = x.conj() * Vy -float BlasConnector::dotc(const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - return BlasConnector::dot(n, X, incX, Y, incY, device_type); -} - -double BlasConnector::dotc(const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - return BlasConnector::dot(n, X, incX, Y, incY, device_type); -} - -std::complex BlasConnector::dotc(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - const int incX2 = 2 * incX; - const int incY2 = 2 * incY; - const float*const x = reinterpret_cast(X); - const float*const y = reinterpret_cast(Y); - // Re(result)=Re(X)*Re(Y)+Im(X)*Im(Y) - // Im(result)=Re(X)*Im(Y)-Im(X)*Re(Y) - return std::complex( - BlasConnector::dot(n, x, incX2, y, incY2, device_type) + dot(n, x+1, incX2, y+1, incY2, device_type), - BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) - dot(n, x+1, incX2, y, incY2, device_type)); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -std::complex BlasConnector::dotc(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - const int incX2 = 2 * incX; - const int incY2 = 2 * incY; - const double*const x = reinterpret_cast(X); - const double*const y = reinterpret_cast(Y); - // Re(result)=Re(X)*Re(Y)+Im(X)*Im(Y) - // Im(result)=Re(X)*Im(Y)-Im(X)*Re(Y) - return std::complex( - BlasConnector::dot(n, x, incX2, y, incY2, device_type) + dot(n, x+1, incX2, y+1, incY2, device_type), - BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) - dot(n, x+1, incX2, y, incY2, device_type)); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} // C = a * A.? * B.? + b * C // Row-Major part @@ -892,209 +572,4 @@ void BlasConnector::gemv(const char trans, const int m, const int n, else { throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); } -} - -// out = ||x||_2 -float BlasConnector::nrm2( const int n, const float *X, const int incX, base_device::AbacusDevice_t device_type ) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - return snrm2_( &n, X, &incX ); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice){ - float result = 0.0; - cublasErrcheck(cublasSnrm2(BlasUtils::cublas_handle, n, X, incX, &result)); - return result; - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -double BlasConnector::nrm2( const int n, const double *X, const int incX, base_device::AbacusDevice_t device_type ) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - return dnrm2_( &n, X, &incX ); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice){ - double result = 0.0; - cublasErrcheck(cublasDnrm2(BlasUtils::cublas_handle, n, X, incX, &result)); - return result; - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -double BlasConnector::nrm2( const int n, const std::complex *X, const int incX, base_device::AbacusDevice_t device_type ) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - return dznrm2_( &n, X, &incX ); - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice){ - double result = 0.0; - cublasErrcheck(cublasDznrm2(BlasUtils::cublas_handle, n, (double2*)X, incX, &result)); - return result; - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -// copies a into b -void BlasConnector::copy(const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - dcopy_(&n, a, &incx, b, &incy); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void BlasConnector::copy(const long n, const std::complex *a, const int incx, std::complex *b, const int incy, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::AbacusDevice_t::CpuDevice) { - zcopy_(&n, a, &incx, b, &incy); - } - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -template -void vector_mul_vector(const int& dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){ - using Real = typename GetTypeReal::type; - if (device_type == base_device::AbacusDevice_t::CpuDevice) { -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 4096 / sizeof(Real)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] * vector2[i]; - } - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - ModuleBase::vector_mul_vector_op()(dim, result, vector1, vector2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - - -template -void vector_div_vector(const int& dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){ - using Real = typename GetTypeReal::type; - if (device_type == base_device::AbacusDevice_t::CpuDevice) { -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 4096 / sizeof(Real)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] / vector2[i]; - } - } -#ifdef __CUDA - else if (device_type == base_device::AbacusDevice_t::GpuDevice) { - ModuleBase::vector_div_vector_op()(dim, result, vector1, vector2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void vector_add_vector(const int& dim, float *result, const float *vector1, const float constant1, const float *vector2, const float constant2, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::CpuDevice){ -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 8192 / sizeof(float)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] * constant1 + vector2[i] * constant2; - } - } -#ifdef __CUDA - else if (device_type == base_device::GpuDevice) { - ModuleBase::vector_add_vector_op()(dim, result, vector1, constant1, vector2, constant2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void vector_add_vector(const int& dim, double *result, const double *vector1, const double constant1, const double *vector2, const double constant2, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::CpuDevice){ -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 8192 / sizeof(double)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] * constant1 + vector2[i] * constant2; - } - } -#ifdef __CUDA - else if (device_type == base_device::GpuDevice) { - ModuleBase::vector_add_vector_op()(dim, result, vector1, constant1, vector2, constant2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void vector_add_vector(const int& dim, std::complex *result, const std::complex *vector1, const float constant1, const std::complex *vector2, const float constant2, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::CpuDevice){ -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 8192 / sizeof(std::complex)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] * constant1 + vector2[i] * constant2; - } - } -#ifdef __CUDA - else if (device_type == base_device::GpuDevice) { - ModuleBase::vector_add_vector_op, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } -} - -void vector_add_vector(const int& dim, std::complex *result, const std::complex *vector1, const double constant1, const std::complex *vector2, const double constant2, base_device::AbacusDevice_t device_type) -{ - if (device_type == base_device::CpuDevice){ -#ifdef _OPENMP -#pragma omp parallel for schedule(static, 8192 / sizeof(std::complex)) -#endif - for (int i = 0; i < dim; i++) - { - result[i] = vector1[i] * constant1 + vector2[i] * constant2; - } - } -#ifdef __CUDA - else if (device_type == base_device::GpuDevice) { - ModuleBase::vector_add_vector_op, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2); - } -#endif - else { - throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); - } } \ No newline at end of file diff --git a/source/module_base/blas_connector_vector.cpp b/source/module_base/blas_connector_vector.cpp new file mode 100644 index 0000000000..e87394b652 --- /dev/null +++ b/source/module_base/blas_connector_vector.cpp @@ -0,0 +1,473 @@ +#include "blas_connector.h" +#include "macros.h" + +#ifdef __DSP +#include "module_base/kernels/dsp/dsp_connector.h" +#include "module_base/global_variable.h" +#endif + +#ifdef __CUDA +#include +#include +#include "cublas_v2.h" +#include "module_base/kernels/math_kernel_op.h" +#include "module_base/module_device/memory_op.h" +#endif + + +void BlasConnector::axpy( const int n, const float alpha, const float *X, const int incX, float *Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + saxpy_(&n, &alpha, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasSaxpy(BlasUtils::cublas_handle, n, &alpha, X, incX, Y, incY)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::axpy( const int n, const double alpha, const double *X, const int incX, double *Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + daxpy_(&n, &alpha, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasDaxpy(BlasUtils::cublas_handle, n, &alpha, X, incX, Y, incY)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::axpy( const int n, const std::complex alpha, const std::complex *X, const int incX, std::complex *Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + caxpy_(&n, &alpha, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasCaxpy(BlasUtils::cublas_handle, n, (float2*)&alpha, (float2*)X, incX, (float2*)Y, incY)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::axpy( const int n, const std::complex alpha, const std::complex *X, const int incX, std::complex *Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + zaxpy_(&n, &alpha, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasZaxpy(BlasUtils::cublas_handle, n, (double2*)&alpha, (double2*)X, incX, (double2*)Y, incY)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +// x=a*x +void BlasConnector::scal( const int n, const float alpha, float *X, const int incX, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + sscal_(&n, &alpha, X, &incX); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasSscal(BlasUtils::cublas_handle, n, &alpha, X, incX)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::scal( const int n, const double alpha, double *X, const int incX, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + dscal_(&n, &alpha, X, &incX); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasDscal(BlasUtils::cublas_handle, n, &alpha, X, incX)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::scal( const int n, const std::complex alpha, std::complex *X, const int incX, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + cscal_(&n, &alpha, X, &incX); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasCscal(BlasUtils::cublas_handle, n, (float2*)&alpha, (float2*)X, incX)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::scal( const int n, const std::complex alpha, std::complex *X, const int incX, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + zscal_(&n, &alpha, X, &incX); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + cublasErrcheck(cublasZscal(BlasUtils::cublas_handle, n, (double2*)&alpha, (double2*)X, incX)); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +// d=x*y +float BlasConnector::dot( const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + return sdot_(&n, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice){ + float result = 0.0; + cublasErrcheck(cublasSdot(BlasUtils::cublas_handle, n, X, incX, Y, incY, &result)); + return result; + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +double BlasConnector::dot( const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + return ddot_(&n, X, &incX, Y, &incY); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice){ + double result = 0.0; + cublasErrcheck(cublasDdot(BlasUtils::cublas_handle, n, X, incX, Y, incY, &result)); + return result; + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +// d=x*y +float BlasConnector::dotu(const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + return BlasConnector::dot(n, X, incX, Y, incY, device_type); +} + +double BlasConnector::dotu(const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + return BlasConnector::dot(n, X, incX, Y, incY, device_type); +} + +std::complex BlasConnector::dotu(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + const int incX2 = 2 * incX; + const int incY2 = 2 * incY; + const float*const x = reinterpret_cast(X); + const float*const y = reinterpret_cast(Y); + //Re(result)=Re(x)*Re(y)-Im(x)*Im(y) + //Im(result)=Re(x)*Im(y)+Im(x)*Re(y) + return std::complex( + BlasConnector::dot(n, x, incX2, y, incY2, device_type) - dot(n, x+1, incX2, y+1, incY2, device_type), + BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) + dot(n, x+1, incX2, y, incY2, device_type)); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +std::complex BlasConnector::dotu(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + const int incX2 = 2 * incX; + const int incY2 = 2 * incY; + const double*const x = reinterpret_cast(X); + const double*const y = reinterpret_cast(Y); + //Re(result)=Re(x)*Re(y)-Im(x)*Im(y) + //Im(result)=Re(x)*Im(y)+Im(x)*Re(y) + return std::complex( + BlasConnector::dot(n, x, incX2, y, incY2, device_type) - dot(n, x+1, incX2, y+1, incY2, device_type), + BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) + dot(n, x+1, incX2, y, incY2, device_type)); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +// d = x.conj() * Vy +float BlasConnector::dotc(const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + return BlasConnector::dot(n, X, incX, Y, incY, device_type); +} + +double BlasConnector::dotc(const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + return BlasConnector::dot(n, X, incX, Y, incY, device_type); +} + +std::complex BlasConnector::dotc(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + const int incX2 = 2 * incX; + const int incY2 = 2 * incY; + const float*const x = reinterpret_cast(X); + const float*const y = reinterpret_cast(Y); + // Re(result)=Re(X)*Re(Y)+Im(X)*Im(Y) + // Im(result)=Re(X)*Im(Y)-Im(X)*Re(Y) + return std::complex( + BlasConnector::dot(n, x, incX2, y, incY2, device_type) + dot(n, x+1, incX2, y+1, incY2, device_type), + BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) - dot(n, x+1, incX2, y, incY2, device_type)); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +std::complex BlasConnector::dotc(const int n, const std::complex*const X, const int incX, const std::complex*const Y, const int incY, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + const int incX2 = 2 * incX; + const int incY2 = 2 * incY; + const double*const x = reinterpret_cast(X); + const double*const y = reinterpret_cast(Y); + // Re(result)=Re(X)*Re(Y)+Im(X)*Im(Y) + // Im(result)=Re(X)*Im(Y)-Im(X)*Re(Y) + return std::complex( + BlasConnector::dot(n, x, incX2, y, incY2, device_type) + dot(n, x+1, incX2, y+1, incY2, device_type), + BlasConnector::dot(n, x, incX2, y+1, incY2, device_type) - dot(n, x+1, incX2, y, incY2, device_type)); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +// out = ||x||_2 +float BlasConnector::nrm2( const int n, const float *X, const int incX, base_device::AbacusDevice_t device_type ) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + return snrm2_( &n, X, &incX ); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice){ + float result = 0.0; + cublasErrcheck(cublasSnrm2(BlasUtils::cublas_handle, n, X, incX, &result)); + return result; + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +double BlasConnector::nrm2( const int n, const double *X, const int incX, base_device::AbacusDevice_t device_type ) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + return dnrm2_( &n, X, &incX ); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice){ + double result = 0.0; + cublasErrcheck(cublasDnrm2(BlasUtils::cublas_handle, n, X, incX, &result)); + return result; + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +double BlasConnector::nrm2( const int n, const std::complex *X, const int incX, base_device::AbacusDevice_t device_type ) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + return dznrm2_( &n, X, &incX ); + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice){ + double result = 0.0; + cublasErrcheck(cublasDznrm2(BlasUtils::cublas_handle, n, (double2*)X, incX, &result)); + return result; + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +// copies a into b +void BlasConnector::copy(const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + dcopy_(&n, a, &incx, b, &incy); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void BlasConnector::copy(const long n, const std::complex *a, const int incx, std::complex *b, const int incy, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::AbacusDevice_t::CpuDevice) { + zcopy_(&n, a, &incx, b, &incy); + } + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +template +void vector_mul_vector(const int& dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){ + using Real = typename GetTypeReal::type; + if (device_type == base_device::AbacusDevice_t::CpuDevice) { +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(Real)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] * vector2[i]; + } + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + ModuleBase::vector_mul_vector_op()(dim, result, vector1, vector2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + + +template +void vector_div_vector(const int& dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){ + using Real = typename GetTypeReal::type; + if (device_type == base_device::AbacusDevice_t::CpuDevice) { +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 4096 / sizeof(Real)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] / vector2[i]; + } + } +#ifdef __CUDA + else if (device_type == base_device::AbacusDevice_t::GpuDevice) { + ModuleBase::vector_div_vector_op()(dim, result, vector1, vector2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void vector_add_vector(const int& dim, float *result, const float *vector1, const float constant1, const float *vector2, const float constant2, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::CpuDevice){ +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 8192 / sizeof(float)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] * constant1 + vector2[i] * constant2; + } + } +#ifdef __CUDA + else if (device_type == base_device::GpuDevice) { + ModuleBase::vector_add_vector_op()(dim, result, vector1, constant1, vector2, constant2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void vector_add_vector(const int& dim, double *result, const double *vector1, const double constant1, const double *vector2, const double constant2, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::CpuDevice){ +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 8192 / sizeof(double)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] * constant1 + vector2[i] * constant2; + } + } +#ifdef __CUDA + else if (device_type == base_device::GpuDevice) { + ModuleBase::vector_add_vector_op()(dim, result, vector1, constant1, vector2, constant2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void vector_add_vector(const int& dim, std::complex *result, const std::complex *vector1, const float constant1, const std::complex *vector2, const float constant2, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::CpuDevice){ +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 8192 / sizeof(std::complex)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] * constant1 + vector2[i] * constant2; + } + } +#ifdef __CUDA + else if (device_type == base_device::GpuDevice) { + ModuleBase::vector_add_vector_op, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} + +void vector_add_vector(const int& dim, std::complex *result, const std::complex *vector1, const double constant1, const std::complex *vector2, const double constant2, base_device::AbacusDevice_t device_type) +{ + if (device_type == base_device::CpuDevice){ +#ifdef _OPENMP +#pragma omp parallel for schedule(static, 8192 / sizeof(std::complex)) +#endif + for (int i = 0; i < dim; i++) + { + result[i] = vector1[i] * constant1 + vector2[i] * constant2; + } + } +#ifdef __CUDA + else if (device_type == base_device::GpuDevice) { + ModuleBase::vector_add_vector_op, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2); + } +#endif + else { + throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + } +} \ No newline at end of file diff --git a/source/module_basis/module_ao/test/CMakeLists.txt b/source/module_basis/module_ao/test/CMakeLists.txt index 054ddb52c0..1cde85d51e 100644 --- a/source/module_basis/module_ao/test/CMakeLists.txt +++ b/source/module_basis/module_ao/test/CMakeLists.txt @@ -7,7 +7,9 @@ list(APPEND depend_files ../../../module_base/math_ylmreal.cpp ../../../module_base/ylm.cpp ../../../module_base/memory.cpp - ../../../module_base/blas_connector.cpp + ../../../module_base/blas_connector_base.cpp + ../../../module_base/blas_connector_vector.cpp + ../../../module_base/blas_connector_matrix.cpp ../../../module_base/complexarray.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp diff --git a/source/module_basis/module_pw/kernels/test/CMakeLists.txt b/source/module_basis/module_pw/kernels/test/CMakeLists.txt index c190ded73d..b0c35b294a 100644 --- a/source/module_basis/module_pw/kernels/test/CMakeLists.txt +++ b/source/module_basis/module_pw/kernels/test/CMakeLists.txt @@ -8,5 +8,6 @@ AddTest( ../../../../module_base/parallel_global.cpp ../../../../module_base/parallel_reduce.cpp ../../../../module_base/parallel_comm.cpp ../../../../module_base/complexmatrix.cpp ../../../../module_base/matrix.cpp ../../../../module_base/memory.cpp - ../../../../module_base/libm/branred.cpp ../../../../module_base/libm/sincos.cpp ../../../../module_base/blas_connector.cpp + ../../../../module_base/libm/branred.cpp ../../../../module_base/libm/sincos.cpp + ../../../../module_base/blas_connector_base.cpp ../../../../module_base/blas_connector_vector.cpp ../../../../module_base/blas_connector_matrix.cpp ) \ No newline at end of file diff --git a/source/module_basis/module_pw/test/CMakeLists.txt b/source/module_basis/module_pw/test/CMakeLists.txt index f0464477df..8b1038af93 100644 --- a/source/module_basis/module_pw/test/CMakeLists.txt +++ b/source/module_basis/module_pw/test/CMakeLists.txt @@ -3,7 +3,8 @@ AddTest( TARGET pw_test LIBS parameter ${math_libs} planewave device SOURCES ../../../module_base/matrix.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix3.cpp ../../../module_base/tool_quit.cpp - ../../../module_base/mymath.cpp ../../../module_base/timer.cpp ../../../module_base/memory.cpp ../../../module_base/blas_connector.cpp + ../../../module_base/mymath.cpp ../../../module_base/timer.cpp ../../../module_base/memory.cpp + ../../../module_base/blas_connector_base.cpp ../../../module_base/blas_connector_vector.cpp ../../../module_base/blas_connector_matrix.cpp ../../../module_base/libm/branred.cpp ../../../module_base/libm/sincos.cpp ../../../module_base/module_device/memory_op.cpp depend_mock.cpp pw_test.cpp test1-1-1.cpp test1-1-2.cpp test1-2.cpp test1-3.cpp test1-4.cpp test1-5.cpp diff --git a/source/module_hamilt_general/module_xc/test/CMakeLists.txt b/source/module_hamilt_general/module_xc/test/CMakeLists.txt index 0dda934ac6..8212efe463 100644 --- a/source/module_hamilt_general/module_xc/test/CMakeLists.txt +++ b/source/module_hamilt_general/module_xc/test/CMakeLists.txt @@ -42,7 +42,7 @@ AddTest( ../../../module_base/memory.cpp ../../../module_base/libm/branred.cpp ../../../module_base/libm/sincos.cpp - ../../../module_base/blas_connector.cpp + ../../../module_base/blas_connector_base.cpp ../../../module_base/blas_connector_vector.cpp ../../../module_base/blas_connector_matrix.cpp ../../../module_basis/module_pw/module_fft/fft_bundle.cpp ../../../module_basis/module_pw/module_fft/fft_cpu.cpp ${FFT_SRC} @@ -75,7 +75,7 @@ AddTest( ../xc_functional_vxc.cpp ../xc_functional_libxc_vxc.cpp ../xc_functional_libxc_tools.cpp - ../../../module_base/blas_connector.cpp + ../../../module_base/blas_connector_base.cpp ../../../module_base/blas_connector_vector.cpp ../../../module_base/blas_connector_matrix.cpp ../../../module_base/matrix.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp diff --git a/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt b/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt index c1b56517b7..f4f6ff247c 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt +++ b/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt @@ -15,7 +15,7 @@ AddTest( ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp - ../../../module_base/blas_connector.cpp + ../../../module_base/blas_connector_base.cpp ../../../module_base/blas_connector_vector.cpp ../../../module_base/blas_connector_matrix.cpp ../../../module_base/parallel_global.cpp ../../../module_base/parallel_comm.cpp ../../../module_base/parallel_common.cpp diff --git a/source/module_md/test/CMakeLists.txt b/source/module_md/test/CMakeLists.txt index 66476fcf88..861b6fcbc2 100644 --- a/source/module_md/test/CMakeLists.txt +++ b/source/module_md/test/CMakeLists.txt @@ -23,7 +23,9 @@ list(APPEND depend_files ../../module_base/matrix3.cpp ../../module_base/matrix.cpp ../../module_base/timer.cpp - ../../module_base/blas_connector.cpp + ../../module_base/blas_connector_base.cpp + ../../module_base/blas_connector_matrix.cpp + ../../module_base/blas_connector_vector.cpp ../../module_base/memory.cpp ../../module_base/global_variable.cpp ../../module_base/global_function.cpp diff --git a/source/module_relax/relax_new/test/CMakeLists.txt b/source/module_relax/relax_new/test/CMakeLists.txt index bc0240e104..fe81c8ef0a 100644 --- a/source/module_relax/relax_new/test/CMakeLists.txt +++ b/source/module_relax/relax_new/test/CMakeLists.txt @@ -17,7 +17,8 @@ AddTest( SOURCES relax_test.cpp ../relax.cpp ../line_search.cpp ../../../module_base/tool_quit.cpp ../../../module_base/global_variable.cpp ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp ../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp ../../../module_base/global_function.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp - ../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp ../../../module_base/blas_connector.cpp + ../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp + ../../../module_base/blas_connector_base.cpp ../../../module_base/blas_connector_vector.cpp ../../../module_base/blas_connector_matrix.cpp ../../../module_cell/update_cell.cpp ../../../module_cell/print_cell.cpp ../../../module_cell/bcast_cell.cpp ../../../module_io/output.cpp LIBS parameter ${math_libs} )