Skip to content

Commit 9fe07c8

Browse files
committed
fix bug
1 parent 903bf8d commit 9fe07c8

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

source/module_base/test/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ AddTest(
134134

135135
AddTest(
136136
TARGET base_math_chebyshev
137-
LIBS parameter ${math_libs} base device
138-
SOURCES math_chebyshev_test.cpp
137+
LIBS parameter ${math_libs}
138+
SOURCES math_chebyshev_test.cpp ../blas_connector.cpp ../math_chebyshev.cpp ../tool_quit.cpp ../global_variable.cpp ../timer.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp
139+
../module_container/ATen/kernels/blas.cpp ../module_device/memory_op.cpp ../module_device/device.cpp
139140
)
140141

141142
AddTest(

source/module_hamilt_pw/hamilt_stodft/sto_che.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ REAL vTMv(const REAL* v, const REAL* M, const int n)
6262
dot_device,
6363
1);
6464
base_device::memory::delete_memory_op<REAL, Device>()(ctx, y);
65+
base_device::memory::delete_memory_op<REAL, Device>()(ctx, dot_device);
6566
return result;
6667
}
6768

source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ void Stochastic_Iter<T, Device>::calPn(const int& ik, Stochastic_WF<T, Device>&
401401
const int M = npwx * nchip_ik * 2; // Do not use kv.ngk[ik]
402402
const int N = norder;
403403
const Real kweight = this->pkv->wk[ik];
404-
hsolver::gemm_op<Real, Device>()(this->ctx, trans, normal, N, M, norder, &kweight, vec_all, LDA, vec_all, LDA, &one, spolyv, N);
404+
405+
hsolver::gemm_op<Real, Device>()(this->ctx, trans, normal, N, N, M, &kweight, vec_all, LDA, vec_all, LDA, &one, spolyv, N);
405406
// dgemm_(&trans, &normal, &N, &N, &M, &kweight, vec_all, &LDA, vec_all, &LDA, &one, spolyv, &N);
406407
}
407408
ModuleBase::timer::tick("Stochastic_Iter", "calPn");

source/module_hsolver/test/test_hsolver_sdft.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,40 @@ Sto_Func<REAL>::Sto_Func()
2323
}
2424
template class Sto_Func<double>;
2525

26+
27+
template <>
28+
elecstate::ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>::ElecStatePW(ModulePW::PW_Basis_K* wfc_basis_in,
29+
Charge* chg_in,
30+
K_Vectors* pkv_in,
31+
UnitCell* ucell_in,
32+
pseudopot_cell_vnl* ppcell_in,
33+
ModulePW::PW_Basis* rhodpw_in,
34+
ModulePW::PW_Basis* rhopw_in,
35+
ModulePW::PW_Basis_Big* bigpw_in)
36+
: basis(wfc_basis_in)
37+
{
38+
}
39+
40+
template<>
41+
elecstate::ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>::~ElecStatePW()
42+
{
43+
}
44+
2645
template<>
2746
void elecstate::ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>::init_rho_data()
2847
{
2948
}
3049

50+
template<>
51+
void elecstate::ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>::psiToRho(const psi::Psi<std::complex<double>, base_device::DEVICE_CPU>& psi)
52+
{
53+
}
54+
55+
template<>
56+
void elecstate::ElecStatePW<std::complex<double>, base_device::DEVICE_CPU>::cal_tau(const psi::Psi<std::complex<double>, base_device::DEVICE_CPU>& psi)
57+
{
58+
}
59+
3160
template <typename REAL, typename Device>
3261
StoChe<REAL, Device>::StoChe(const int& nche, const int& method, const REAL& emax_sto, const REAL& emin_sto)
3362
{
@@ -141,7 +170,7 @@ Charge::~Charge(){};
141170
class TestHSolverPW_SDFT : public ::testing::Test
142171
{
143172
public:
144-
TestHSolverPW_SDFT() : stoche(8, 1, 0, 0)
173+
TestHSolverPW_SDFT() : stoche(8, 1, 0, 0), elecstate_test(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)
145174
{
146175
}
147176
ModulePW::PW_Basis_K pwbk;
@@ -175,7 +204,7 @@ class TestHSolverPW_SDFT : public ::testing::Test
175204
psi::Psi<std::complex<double>> psi_test_cd;
176205
psi::Psi<std::complex<double>> psi_test_no;
177206

178-
elecstate::ElecState elecstate_test;
207+
elecstate::ElecStatePW<std::complex<double>> elecstate_test;
179208

180209
std::string method_test = "cg";
181210

@@ -239,6 +268,8 @@ TEST_F(TestHSolverPW_SDFT, solve_noband_skipcharge)
239268
elecstate_test.charge->rho = new double*[1];
240269
elecstate_test.charge->rho[0] = new double[10];
241270
elecstate_test.charge->nrxx = 10;
271+
elecstate_test.rho = new double*[1];
272+
elecstate_test.rho[0] = new double[10];
242273
int istep = 0;
243274
int iter = 0;
244275

0 commit comments

Comments
 (0)