Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion python/pyabacus/src/hsolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ list(APPEND _diago
${HSOLVER_PATH}/diago_pxxxgvx.cpp


${HSOLVER_PATH}/kernels/dngvd_op.cpp
${HSOLVER_PATH}/kernels/hegvd_op.cpp
${HSOLVER_PATH}/kernels/bpcg_kernel_op.cpp
# dependency
${BASE_PATH}/kernels/math_kernel_op.cpp
Expand Down
6 changes: 3 additions & 3 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ list(APPEND device_srcs
source_pw/module_pwdft/kernels/meta_op.cpp
source_pw/module_stodft/kernels/hpsi_norm_op.cpp
source_basis/module_pw/kernels/pw_op.cpp
source_hsolver/kernels/dngvd_op.cpp
source_hsolver/kernels/hegvd_op.cpp
source_hsolver/kernels/bpcg_kernel_op.cpp
source_estate/kernels/elecstate_op.cpp

Expand Down Expand Up @@ -70,7 +70,7 @@ if(USE_CUDA)
source_pw/module_stodft/kernels/cuda/hpsi_norm_op.cu
source_pw/module_pwdft/kernels/cuda/onsite_op.cu
source_basis/module_pw/kernels/cuda/pw_op.cu
source_hsolver/kernels/cuda/dngvd_op.cu
source_hsolver/kernels/cuda/hegvd_op.cu
source_hsolver/kernels/cuda/bpcg_kernel_op.cu
source_estate/kernels/cuda/elecstate_op.cu

Expand Down Expand Up @@ -101,7 +101,7 @@ if(USE_ROCM)
source_pw/module_pwdft/kernels/rocm/onsite_op.hip.cu
source_pw/module_stodft/kernels/rocm/hpsi_norm_op.hip.cu
source_basis/module_pw/kernels/rocm/pw_op.hip.cu
source_hsolver/kernels/rocm/dngvd_op.hip.cu
source_hsolver/kernels/rocm/hegvd_op.hip.cu
source_hsolver/kernels/rocm/bpcg_kernel_op.hip.cu
source_estate/kernels/rocm/elecstate_op.hip.cu

Expand Down
2 changes: 1 addition & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ OBJS_HSOLVER=diago_cg.o\
hsolver_lcaopw.o\
hsolver_pw_sdft.o\
diago_iter_assist.o\
dngvd_op.o\
hegvd_op.o\
bpcg_kernel_op.o\
diag_const_nums.o\
diag_hs_para.o\
Expand Down
24 changes: 12 additions & 12 deletions source/source_base/module_container/ATen/kernels/cuda/lapack.cu
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct lapack_potrf<T, DEVICE_GPU> {
};

template <typename T>
struct lapack_dnevd<T, DEVICE_GPU> {
struct lapack_heevd<T, DEVICE_GPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const char& jobz,
Expand All @@ -97,12 +97,12 @@ struct lapack_dnevd<T, DEVICE_GPU> {
const int& dim,
Real* eigen_val)
{
cuSolverConnector::dnevd(cusolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
cuSolverConnector::heevd(cusolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
}
};

template <typename T>
struct lapack_dngvd<T, DEVICE_GPU> {
struct lapack_hegvd<T, DEVICE_GPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const int& itype,
Expand All @@ -113,7 +113,7 @@ struct lapack_dngvd<T, DEVICE_GPU> {
const int& dim,
Real* eigen_val)
{
cuSolverConnector::dngvd(cusolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
cuSolverConnector::hegvd(cusolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
}
};

Expand Down Expand Up @@ -175,15 +175,15 @@ template struct lapack_potrf<double, DEVICE_GPU>;
template struct lapack_potrf<std::complex<float>, DEVICE_GPU>;
template struct lapack_potrf<std::complex<double>, DEVICE_GPU>;

template struct lapack_dnevd<float, DEVICE_GPU>;
template struct lapack_dnevd<double, DEVICE_GPU>;
template struct lapack_dnevd<std::complex<float>, DEVICE_GPU>;
template struct lapack_dnevd<std::complex<double>, DEVICE_GPU>;
template struct lapack_heevd<float, DEVICE_GPU>;
template struct lapack_heevd<double, DEVICE_GPU>;
template struct lapack_heevd<std::complex<float>, DEVICE_GPU>;
template struct lapack_heevd<std::complex<double>, DEVICE_GPU>;

template struct lapack_dngvd<float, DEVICE_GPU>;
template struct lapack_dngvd<double, DEVICE_GPU>;
template struct lapack_dngvd<std::complex<float>, DEVICE_GPU>;
template struct lapack_dngvd<std::complex<double>, DEVICE_GPU>;
template struct lapack_hegvd<float, DEVICE_GPU>;
template struct lapack_hegvd<double, DEVICE_GPU>;
template struct lapack_hegvd<std::complex<float>, DEVICE_GPU>;
template struct lapack_hegvd<std::complex<double>, DEVICE_GPU>;

template struct lapack_getrf<float, DEVICE_GPU>;
template struct lapack_getrf<double, DEVICE_GPU>;
Expand Down
28 changes: 14 additions & 14 deletions source/source_base/module_container/ATen/kernels/lapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct lapack_potrf<T, DEVICE_CPU> {
};

template <typename T>
struct lapack_dnevd<T, DEVICE_CPU> {
struct lapack_heevd<T, DEVICE_CPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const char& jobz,
Expand All @@ -85,15 +85,15 @@ struct lapack_dnevd<T, DEVICE_CPU> {
Tensor iwork(DataTypeToEnum<int>::value, DeviceType::CpuDevice, {liwork});
iwork.zero();

lapackConnector::dnevd(jobz, uplo, dim, Mat, dim, eigen_val, work.data<T>(), lwork, rwork.data<Real>(), lrwork, iwork.data<int>(), liwork, info);
lapackConnector::heevd(jobz, uplo, dim, Mat, dim, eigen_val, work.data<T>(), lwork, rwork.data<Real>(), lrwork, iwork.data<int>(), liwork, info);
if (info != 0) {
throw std::runtime_error("dnevd failed with info = " + std::to_string(info));
throw std::runtime_error("heevd failed with info = " + std::to_string(info));
}
}
};

template <typename T>
struct lapack_dngvd<T, DEVICE_CPU> {
struct lapack_hegvd<T, DEVICE_CPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const int& itype,
Expand All @@ -117,9 +117,9 @@ struct lapack_dngvd<T, DEVICE_CPU> {
Tensor iwork(DataType::DT_INT, DeviceType::CpuDevice, {liwork});
iwork.zero();

lapackConnector::dngvd(itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val, work.data<T>(), lwork, rwork.data<Real>(), lrwork, iwork.data<int>(), liwork, info);
lapackConnector::hegvd(itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val, work.data<T>(), lwork, rwork.data<Real>(), lrwork, iwork.data<int>(), liwork, info);
if (info != 0) {
throw std::runtime_error("dngvd failed with info = " + std::to_string(info));
throw std::runtime_error("hegvd failed with info = " + std::to_string(info));
}
}
};
Expand Down Expand Up @@ -194,15 +194,15 @@ template struct lapack_trtri<double, DEVICE_CPU>;
template struct lapack_trtri<std::complex<float>, DEVICE_CPU>;
template struct lapack_trtri<std::complex<double>, DEVICE_CPU>;

template struct lapack_dnevd<float, DEVICE_CPU>;
template struct lapack_dnevd<double, DEVICE_CPU>;
template struct lapack_dnevd<std::complex<float>, DEVICE_CPU>;
template struct lapack_dnevd<std::complex<double>, DEVICE_CPU>;
template struct lapack_heevd<float, DEVICE_CPU>;
template struct lapack_heevd<double, DEVICE_CPU>;
template struct lapack_heevd<std::complex<float>, DEVICE_CPU>;
template struct lapack_heevd<std::complex<double>, DEVICE_CPU>;

template struct lapack_dngvd<float, DEVICE_CPU>;
template struct lapack_dngvd<double, DEVICE_CPU>;
template struct lapack_dngvd<std::complex<float>, DEVICE_CPU>;
template struct lapack_dngvd<std::complex<double>, DEVICE_CPU>;
template struct lapack_hegvd<float, DEVICE_CPU>;
template struct lapack_hegvd<double, DEVICE_CPU>;
template struct lapack_hegvd<std::complex<float>, DEVICE_CPU>;
template struct lapack_hegvd<std::complex<double>, DEVICE_CPU>;

template struct lapack_getrf<float, DEVICE_CPU>;
template struct lapack_getrf<double, DEVICE_CPU>;
Expand Down
4 changes: 2 additions & 2 deletions source/source_base/module_container/ATen/kernels/lapack.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct lapack_potrf {


template <typename T, typename Device>
struct lapack_dnevd {
struct lapack_heevd {
using Real = typename GetTypeReal<T>::type;
void operator()(
const char& jobz,
Expand All @@ -53,7 +53,7 @@ struct lapack_dnevd {


template <typename T, typename Device>
struct lapack_dngvd {
struct lapack_hegvd {
using Real = typename GetTypeReal<T>::type;
void operator()(
const int& itype,
Expand Down
26 changes: 13 additions & 13 deletions source/source_base/module_container/ATen/kernels/rocm/lapack.hip.cu
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct lapack_potrf<T, DEVICE_GPU> {
};

template <typename T>
struct lapack_dnevd<T, DEVICE_GPU> {
struct lapack_heevd<T, DEVICE_GPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const char& jobz,
Expand All @@ -103,19 +103,19 @@ struct lapack_dnevd<T, DEVICE_GPU> {
const int& dim,
Real* eigen_val)
{
// hipSolverConnector::dnevd(hipsolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
// hipSolverConnector::heevd(hipsolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
std::vector<T> H_Mat(dim * dim, static_cast<T>(0.0));
std::vector<Real> H_eigen_val(dim, static_cast<Real>(0.0));
hipMemcpy(H_Mat.data(), Mat, sizeof(T) * H_Mat.size(), hipMemcpyDeviceToHost);
hipMemcpy(H_eigen_val.data(), eigen_val, sizeof(Real) * H_eigen_val.size(), hipMemcpyDeviceToHost);
lapack_dnevd<T, DEVICE_CPU>()(jobz, uplo, H_Mat.data(), dim, H_eigen_val.data());
lapack_heevd<T, DEVICE_CPU>()(jobz, uplo, H_Mat.data(), dim, H_eigen_val.data());
hipMemcpy(Mat, H_Mat.data(), sizeof(T) * H_Mat.size(), hipMemcpyHostToDevice);
hipMemcpy(eigen_val, H_eigen_val.data(), sizeof(Real) * H_eigen_val.size(), hipMemcpyHostToDevice);
}
};

template <typename T>
struct lapack_dngvd<T, DEVICE_GPU> {
struct lapack_hegvd<T, DEVICE_GPU> {
using Real = typename GetTypeReal<T>::type;
void operator()(
const int& itype,
Expand All @@ -126,7 +126,7 @@ struct lapack_dngvd<T, DEVICE_GPU> {
const int& dim,
Real* eigen_val)
{
hipSolverConnector::dngvd(hipsolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
hipSolverConnector::hegvd(hipsolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
}
};

Expand All @@ -145,15 +145,15 @@ template struct lapack_potrf<double, DEVICE_GPU>;
template struct lapack_potrf<std::complex<float>, DEVICE_GPU>;
template struct lapack_potrf<std::complex<double>, DEVICE_GPU>;

template struct lapack_dnevd<float, DEVICE_GPU>;
template struct lapack_dnevd<double, DEVICE_GPU>;
template struct lapack_dnevd<std::complex<float>, DEVICE_GPU>;
template struct lapack_dnevd<std::complex<double>, DEVICE_GPU>;
template struct lapack_heevd<float, DEVICE_GPU>;
template struct lapack_heevd<double, DEVICE_GPU>;
template struct lapack_heevd<std::complex<float>, DEVICE_GPU>;
template struct lapack_heevd<std::complex<double>, DEVICE_GPU>;

template struct lapack_dngvd<float, DEVICE_GPU>;
template struct lapack_dngvd<double, DEVICE_GPU>;
template struct lapack_dngvd<std::complex<float>, DEVICE_GPU>;
template struct lapack_dngvd<std::complex<double>, DEVICE_GPU>;
template struct lapack_hegvd<float, DEVICE_GPU>;
template struct lapack_hegvd<double, DEVICE_GPU>;
template struct lapack_hegvd<std::complex<float>, DEVICE_GPU>;
template struct lapack_hegvd<std::complex<double>, DEVICE_GPU>;

} // namespace kernels
} // namespace container
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ TYPED_TEST(LapackTest, Potrf) {
EXPECT_EQ(A, C);
}

TYPED_TEST(LapackTest, dnevd) {
TYPED_TEST(LapackTest, heevd) {
using Type = typename std::tuple_element<0, decltype(TypeParam())>::type;
using Real = typename GetTypeReal<Type>::type;
using Device = typename std::tuple_element<1, decltype(TypeParam())>::type;

blas_gemm<Type, Device> gemmCalculator;
blas_axpy<Type, Device> axpyCalculator;
lapack_dnevd<Type, Device> dnevdCalculator;
lapack_heevd<Type, Device> heevdCalculator;

const int dim = 3;
Tensor A = std::move(Tensor({static_cast<Type>(4.0), static_cast<Type>(1.0), static_cast<Type>(1.0),
Expand All @@ -121,7 +121,7 @@ TYPED_TEST(LapackTest, dnevd) {
const Type beta = static_cast<Type>(0.0);
// Note all blas and lapack operators within container are column major!
// For this reason, we should employ 'L' instead of 'U' in the subsequent line.
dnevdCalculator('V', 'U', B.data<Type>(), dim, E.data<Real>());
heevdCalculator('V', 'U', B.data<Type>(), dim, E.data<Real>());

E = E.to_device<DEVICE_CPU>();
const Tensor Alpha = std::move(Tensor({
Expand All @@ -139,14 +139,14 @@ TYPED_TEST(LapackTest, dnevd) {
}


TYPED_TEST(LapackTest, dngvd) {
TYPED_TEST(LapackTest, hegvd) {
using Type = typename std::tuple_element<0, decltype(TypeParam())>::type;
using Real = typename GetTypeReal<Type>::type;
using Device = typename std::tuple_element<1, decltype(TypeParam())>::type;

blas_gemm<Type, Device> gemmCalculator;
blas_axpy<Type, Device> axpyCalculator;
lapack_dngvd<Type, Device> dngvdCalculator;
lapack_hegvd<Type, Device> hegvdCalculator;

const int dim = 3;
Tensor A = std::move(Tensor({static_cast<Type>(4.0), static_cast<Type>(1.0), static_cast<Type>(1.0),
Expand All @@ -172,7 +172,7 @@ TYPED_TEST(LapackTest, dngvd) {
const Type beta = static_cast<Type>(0.0);
// Note al<l blas and lapack operators within container are column major!
// For this reason, we should employ 'L' instead of 'U' in the subsequent line.
dngvdCalculator(1, 'V', 'U', B.data<Type>(), I.data<Type>(), dim, E.data<Real>());
hegvdCalculator(1, 'V', 'U', B.data<Type>(), I.data<Type>(), dim, E.data<Real>());

E = E.to_device<DEVICE_CPU>();
const Tensor Alpha = std::move(Tensor({
Expand Down
Loading
Loading