Skip to content

Commit 73fc8a9

Browse files
authored
Refactor: rename dngvd files (#6543)
* Rename dngvd to hegvd, add comment & docs * Update hegvd_op docs * Rename source files * Change dngv/dnev to hegv/heev in source * Rename pyabacus dngvd
1 parent bc2d287 commit 73fc8a9

30 files changed

+134
-124
lines changed

python/pyabacus/src/hsolver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ list(APPEND _diago
99
${HSOLVER_PATH}/diago_pxxxgvx.cpp
1010

1111

12-
${HSOLVER_PATH}/kernels/dngvd_op.cpp
12+
${HSOLVER_PATH}/kernels/hegvd_op.cpp
1313
${HSOLVER_PATH}/kernels/bpcg_kernel_op.cpp
1414
# dependency
1515
${BASE_PATH}/kernels/math_kernel_op.cpp

source/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ list(APPEND device_srcs
3535
source_pw/module_pwdft/kernels/meta_op.cpp
3636
source_pw/module_stodft/kernels/hpsi_norm_op.cpp
3737
source_basis/module_pw/kernels/pw_op.cpp
38-
source_hsolver/kernels/dngvd_op.cpp
38+
source_hsolver/kernels/hegvd_op.cpp
3939
source_hsolver/kernels/bpcg_kernel_op.cpp
4040
source_estate/kernels/elecstate_op.cpp
4141

@@ -70,7 +70,7 @@ if(USE_CUDA)
7070
source_pw/module_stodft/kernels/cuda/hpsi_norm_op.cu
7171
source_pw/module_pwdft/kernels/cuda/onsite_op.cu
7272
source_basis/module_pw/kernels/cuda/pw_op.cu
73-
source_hsolver/kernels/cuda/dngvd_op.cu
73+
source_hsolver/kernels/cuda/hegvd_op.cu
7474
source_hsolver/kernels/cuda/bpcg_kernel_op.cu
7575
source_estate/kernels/cuda/elecstate_op.cu
7676

@@ -101,7 +101,7 @@ if(USE_ROCM)
101101
source_pw/module_pwdft/kernels/rocm/onsite_op.hip.cu
102102
source_pw/module_stodft/kernels/rocm/hpsi_norm_op.hip.cu
103103
source_basis/module_pw/kernels/rocm/pw_op.hip.cu
104-
source_hsolver/kernels/rocm/dngvd_op.hip.cu
104+
source_hsolver/kernels/rocm/hegvd_op.hip.cu
105105
source_hsolver/kernels/rocm/bpcg_kernel_op.hip.cu
106106
source_estate/kernels/rocm/elecstate_op.hip.cu
107107

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ OBJS_HSOLVER=diago_cg.o\
395395
hsolver_lcaopw.o\
396396
hsolver_pw_sdft.o\
397397
diago_iter_assist.o\
398-
dngvd_op.o\
398+
hegvd_op.o\
399399
bpcg_kernel_op.o\
400400
diag_const_nums.o\
401401
diag_hs_para.o\

source/source_base/module_container/ATen/kernels/cuda/lapack.cu

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct lapack_potrf<T, DEVICE_GPU> {
8888
};
8989

9090
template <typename T>
91-
struct lapack_dnevd<T, DEVICE_GPU> {
91+
struct lapack_heevd<T, DEVICE_GPU> {
9292
using Real = typename GetTypeReal<T>::type;
9393
void operator()(
9494
const char& jobz,
@@ -97,12 +97,12 @@ struct lapack_dnevd<T, DEVICE_GPU> {
9797
const int& dim,
9898
Real* eigen_val)
9999
{
100-
cuSolverConnector::dnevd(cusolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
100+
cuSolverConnector::heevd(cusolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
101101
}
102102
};
103103

104104
template <typename T>
105-
struct lapack_dngvd<T, DEVICE_GPU> {
105+
struct lapack_hegvd<T, DEVICE_GPU> {
106106
using Real = typename GetTypeReal<T>::type;
107107
void operator()(
108108
const int& itype,
@@ -113,7 +113,7 @@ struct lapack_dngvd<T, DEVICE_GPU> {
113113
const int& dim,
114114
Real* eigen_val)
115115
{
116-
cuSolverConnector::dngvd(cusolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
116+
cuSolverConnector::hegvd(cusolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
117117
}
118118
};
119119

@@ -175,15 +175,15 @@ template struct lapack_potrf<double, DEVICE_GPU>;
175175
template struct lapack_potrf<std::complex<float>, DEVICE_GPU>;
176176
template struct lapack_potrf<std::complex<double>, DEVICE_GPU>;
177177

178-
template struct lapack_dnevd<float, DEVICE_GPU>;
179-
template struct lapack_dnevd<double, DEVICE_GPU>;
180-
template struct lapack_dnevd<std::complex<float>, DEVICE_GPU>;
181-
template struct lapack_dnevd<std::complex<double>, DEVICE_GPU>;
178+
template struct lapack_heevd<float, DEVICE_GPU>;
179+
template struct lapack_heevd<double, DEVICE_GPU>;
180+
template struct lapack_heevd<std::complex<float>, DEVICE_GPU>;
181+
template struct lapack_heevd<std::complex<double>, DEVICE_GPU>;
182182

183-
template struct lapack_dngvd<float, DEVICE_GPU>;
184-
template struct lapack_dngvd<double, DEVICE_GPU>;
185-
template struct lapack_dngvd<std::complex<float>, DEVICE_GPU>;
186-
template struct lapack_dngvd<std::complex<double>, DEVICE_GPU>;
183+
template struct lapack_hegvd<float, DEVICE_GPU>;
184+
template struct lapack_hegvd<double, DEVICE_GPU>;
185+
template struct lapack_hegvd<std::complex<float>, DEVICE_GPU>;
186+
template struct lapack_hegvd<std::complex<double>, DEVICE_GPU>;
187187

188188
template struct lapack_getrf<float, DEVICE_GPU>;
189189
template struct lapack_getrf<double, DEVICE_GPU>;

source/source_base/module_container/ATen/kernels/lapack.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct lapack_potrf<T, DEVICE_CPU> {
6363
};
6464

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

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

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

120-
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);
120+
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);
121121
if (info != 0) {
122-
throw std::runtime_error("dngvd failed with info = " + std::to_string(info));
122+
throw std::runtime_error("hegvd failed with info = " + std::to_string(info));
123123
}
124124
}
125125
};
@@ -194,15 +194,15 @@ template struct lapack_trtri<double, DEVICE_CPU>;
194194
template struct lapack_trtri<std::complex<float>, DEVICE_CPU>;
195195
template struct lapack_trtri<std::complex<double>, DEVICE_CPU>;
196196

197-
template struct lapack_dnevd<float, DEVICE_CPU>;
198-
template struct lapack_dnevd<double, DEVICE_CPU>;
199-
template struct lapack_dnevd<std::complex<float>, DEVICE_CPU>;
200-
template struct lapack_dnevd<std::complex<double>, DEVICE_CPU>;
197+
template struct lapack_heevd<float, DEVICE_CPU>;
198+
template struct lapack_heevd<double, DEVICE_CPU>;
199+
template struct lapack_heevd<std::complex<float>, DEVICE_CPU>;
200+
template struct lapack_heevd<std::complex<double>, DEVICE_CPU>;
201201

202-
template struct lapack_dngvd<float, DEVICE_CPU>;
203-
template struct lapack_dngvd<double, DEVICE_CPU>;
204-
template struct lapack_dngvd<std::complex<float>, DEVICE_CPU>;
205-
template struct lapack_dngvd<std::complex<double>, DEVICE_CPU>;
202+
template struct lapack_hegvd<float, DEVICE_CPU>;
203+
template struct lapack_hegvd<double, DEVICE_CPU>;
204+
template struct lapack_hegvd<std::complex<float>, DEVICE_CPU>;
205+
template struct lapack_hegvd<std::complex<double>, DEVICE_CPU>;
206206

207207
template struct lapack_getrf<float, DEVICE_CPU>;
208208
template struct lapack_getrf<double, DEVICE_CPU>;

source/source_base/module_container/ATen/kernels/lapack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct lapack_potrf {
4141

4242

4343
template <typename T, typename Device>
44-
struct lapack_dnevd {
44+
struct lapack_heevd {
4545
using Real = typename GetTypeReal<T>::type;
4646
void operator()(
4747
const char& jobz,
@@ -53,7 +53,7 @@ struct lapack_dnevd {
5353

5454

5555
template <typename T, typename Device>
56-
struct lapack_dngvd {
56+
struct lapack_hegvd {
5757
using Real = typename GetTypeReal<T>::type;
5858
void operator()(
5959
const int& itype,

source/source_base/module_container/ATen/kernels/rocm/lapack.hip.cu

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct lapack_potrf<T, DEVICE_GPU> {
9494
};
9595

9696
template <typename T>
97-
struct lapack_dnevd<T, DEVICE_GPU> {
97+
struct lapack_heevd<T, DEVICE_GPU> {
9898
using Real = typename GetTypeReal<T>::type;
9999
void operator()(
100100
const char& jobz,
@@ -103,19 +103,19 @@ struct lapack_dnevd<T, DEVICE_GPU> {
103103
const int& dim,
104104
Real* eigen_val)
105105
{
106-
// hipSolverConnector::dnevd(hipsolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
106+
// hipSolverConnector::heevd(hipsolver_handle, jobz, uplo, dim, Mat, dim, eigen_val);
107107
std::vector<T> H_Mat(dim * dim, static_cast<T>(0.0));
108108
std::vector<Real> H_eigen_val(dim, static_cast<Real>(0.0));
109109
hipMemcpy(H_Mat.data(), Mat, sizeof(T) * H_Mat.size(), hipMemcpyDeviceToHost);
110110
hipMemcpy(H_eigen_val.data(), eigen_val, sizeof(Real) * H_eigen_val.size(), hipMemcpyDeviceToHost);
111-
lapack_dnevd<T, DEVICE_CPU>()(jobz, uplo, H_Mat.data(), dim, H_eigen_val.data());
111+
lapack_heevd<T, DEVICE_CPU>()(jobz, uplo, H_Mat.data(), dim, H_eigen_val.data());
112112
hipMemcpy(Mat, H_Mat.data(), sizeof(T) * H_Mat.size(), hipMemcpyHostToDevice);
113113
hipMemcpy(eigen_val, H_eigen_val.data(), sizeof(Real) * H_eigen_val.size(), hipMemcpyHostToDevice);
114114
}
115115
};
116116

117117
template <typename T>
118-
struct lapack_dngvd<T, DEVICE_GPU> {
118+
struct lapack_hegvd<T, DEVICE_GPU> {
119119
using Real = typename GetTypeReal<T>::type;
120120
void operator()(
121121
const int& itype,
@@ -126,7 +126,7 @@ struct lapack_dngvd<T, DEVICE_GPU> {
126126
const int& dim,
127127
Real* eigen_val)
128128
{
129-
hipSolverConnector::dngvd(hipsolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
129+
hipSolverConnector::hegvd(hipsolver_handle, itype, jobz, uplo, dim, Mat_A, dim, Mat_B, dim, eigen_val);
130130
}
131131
};
132132

@@ -145,15 +145,15 @@ template struct lapack_potrf<double, DEVICE_GPU>;
145145
template struct lapack_potrf<std::complex<float>, DEVICE_GPU>;
146146
template struct lapack_potrf<std::complex<double>, DEVICE_GPU>;
147147

148-
template struct lapack_dnevd<float, DEVICE_GPU>;
149-
template struct lapack_dnevd<double, DEVICE_GPU>;
150-
template struct lapack_dnevd<std::complex<float>, DEVICE_GPU>;
151-
template struct lapack_dnevd<std::complex<double>, DEVICE_GPU>;
148+
template struct lapack_heevd<float, DEVICE_GPU>;
149+
template struct lapack_heevd<double, DEVICE_GPU>;
150+
template struct lapack_heevd<std::complex<float>, DEVICE_GPU>;
151+
template struct lapack_heevd<std::complex<double>, DEVICE_GPU>;
152152

153-
template struct lapack_dngvd<float, DEVICE_GPU>;
154-
template struct lapack_dngvd<double, DEVICE_GPU>;
155-
template struct lapack_dngvd<std::complex<float>, DEVICE_GPU>;
156-
template struct lapack_dngvd<std::complex<double>, DEVICE_GPU>;
153+
template struct lapack_hegvd<float, DEVICE_GPU>;
154+
template struct lapack_hegvd<double, DEVICE_GPU>;
155+
template struct lapack_hegvd<std::complex<float>, DEVICE_GPU>;
156+
template struct lapack_hegvd<std::complex<double>, DEVICE_GPU>;
157157

158158
} // namespace kernels
159159
} // namespace container

source/source_base/module_container/ATen/kernels/test/lapack_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ TYPED_TEST(LapackTest, Potrf) {
9292
EXPECT_EQ(A, C);
9393
}
9494

95-
TYPED_TEST(LapackTest, dnevd) {
95+
TYPED_TEST(LapackTest, heevd) {
9696
using Type = typename std::tuple_element<0, decltype(TypeParam())>::type;
9797
using Real = typename GetTypeReal<Type>::type;
9898
using Device = typename std::tuple_element<1, decltype(TypeParam())>::type;
9999

100100
blas_gemm<Type, Device> gemmCalculator;
101101
blas_axpy<Type, Device> axpyCalculator;
102-
lapack_dnevd<Type, Device> dnevdCalculator;
102+
lapack_heevd<Type, Device> heevdCalculator;
103103

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

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

141141

142-
TYPED_TEST(LapackTest, dngvd) {
142+
TYPED_TEST(LapackTest, hegvd) {
143143
using Type = typename std::tuple_element<0, decltype(TypeParam())>::type;
144144
using Real = typename GetTypeReal<Type>::type;
145145
using Device = typename std::tuple_element<1, decltype(TypeParam())>::type;
146146

147147
blas_gemm<Type, Device> gemmCalculator;
148148
blas_axpy<Type, Device> axpyCalculator;
149-
lapack_dngvd<Type, Device> dngvdCalculator;
149+
lapack_hegvd<Type, Device> hegvdCalculator;
150150

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

177177
E = E.to_device<DEVICE_CPU>();
178178
const Tensor Alpha = std::move(Tensor({

0 commit comments

Comments
 (0)