Skip to content

Commit

Permalink
Merge branch 'develop' into refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ErjieWu authored Jan 6, 2025
2 parents 66be275 + cdf1c04 commit 454816b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 12 deletions.
11 changes: 9 additions & 2 deletions source/module_basis/module_pw/module_fft/fft_bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ void FFT_Bundle::initfft(int nx_in,

if (this->precision=="single")
{
#ifndef __ENABLE_FLOAT_FFTW
float_define = false;
#if not defined (__ENABLE_FLOAT_FFTW)
if (this->device == "cpu"){
float_define = false;
}
#endif
#if defined(__CUDA) || defined (__ROCM)
if (this->device == "gpu"){
float_flag = float_define;
}
#endif
float_flag = float_define;
double_flag = true;
Expand Down
18 changes: 14 additions & 4 deletions source/module_hsolver/test/diago_bpcg_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ void lapackEigen(int &npw, std::vector<std::complex<double>> &hm, double *e, boo
char tmp_c1 = 'V', tmp_c2 = 'U';
zheev_(&tmp_c1, &tmp_c2, &npw, hm.data(), &npw, e, work2, &lwork, rwork, &info);
end = clock();
if (outtime)
if (outtime) {
std::cout << "Lapack Run time: " << (double)(end - start) / CLOCKS_PER_SEC << " S" << std::endl;
}
delete[] rwork;
delete[] work2;
}
Expand Down Expand Up @@ -78,7 +79,8 @@ class DiagoBPCGPrepare
// calculate eigenvalues by LAPACK;
double *e_lapack = new double[npw];
auto ev = DIAGOTEST::hmatrix;
if(mypnum == 0) lapackEigen(npw, ev, e_lapack, false);
if(mypnum == 0) { lapackEigen(npw, ev, e_lapack, false);
}
// initial guess of psi by perturbing lapack psi
ModuleBase::ComplexMatrix psiguess(nband, npw);
std::default_random_engine p(1);
Expand Down Expand Up @@ -248,7 +250,14 @@ TEST(DiagoBPCGTest, readH)
// read Hamilt matrix from file data-H
std::vector<std::complex<double>> hm;
std::ifstream ifs;
ifs.open("H-KPoints-Si64.dat");
std::string filename = "H-KPoints-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hm);
ifs.close();
int dim = DIAGOTEST::npw;
Expand Down Expand Up @@ -280,7 +289,8 @@ int main(int argc, char **argv)

testing::InitGoogleTest(&argc, argv);
::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners();
if (myrank != 0) delete listeners.Release(listeners.default_result_printer());
if (myrank != 0) { delete listeners.Release(listeners.default_result_printer());
}

int result = RUN_ALL_TESTS();
if (myrank == 0 && result != 0)
Expand Down
9 changes: 8 additions & 1 deletion source/module_hsolver/test/diago_cg_float_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ TEST(DiagoCGFloatTest, readH)
// read Hamilt matrix from file data-H
std::vector<std::complex<float>> hm;
std::ifstream ifs;
ifs.open("H-KPoints-Si64.dat");
std::string filename = "H-KPoints-Si64.dat";
// open file and check status
ifs.open(filename);
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hm);
ifs.close();
int dim = DIAGOTEST::npw;
Expand Down
9 changes: 8 additions & 1 deletion source/module_hsolver/test/diago_cg_real_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,14 @@ TEST(DiagoCGTest, readH)
// read Hamilt matrix from file data-H
std::vector<double> hm;
std::ifstream ifs;
ifs.open("H-GammaOnly-Si64.dat");
std::string filename = "H-GammaOnly-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hm);
ifs.close();
int dim = DIAGOTEST::npw;
Expand Down
9 changes: 8 additions & 1 deletion source/module_hsolver/test/diago_cg_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,14 @@ TEST(DiagoCGTest, readH)
// read Hamilt matrix from file data-H
std::vector<std::complex<double>> hm;
std::ifstream ifs;
ifs.open("H-KPoints-Si64.dat");
std::string filename = "H-KPoints-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hm);
ifs.close();
int dim = DIAGOTEST::npw;
Expand Down
10 changes: 9 additions & 1 deletion source/module_hsolver/test/diago_david_float_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ INSTANTIATE_TEST_SUITE_P(VerifyDiag,DiagoDavTest,::testing::Values(
TEST(DiagoDavRealSystemTest,dataH)
{
std::vector<std::complex<float>> hmatrix;
std::ifstream ifs("H-KPoints-Si64.dat");
std::ifstream ifs;
std::string filename = "H-KPoints-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs,hmatrix);
ifs.close();
DIAGOTEST::hmatrix_f = hmatrix;
Expand Down
10 changes: 9 additions & 1 deletion source/module_hsolver/test/diago_david_real_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,15 @@ INSTANTIATE_TEST_SUITE_P(VerifyDiag, DiagoDavTest, ::testing::Values(
TEST(DiagoDavRealSystemTest, dataH)
{
std::vector<double> hmatrix;
std::ifstream ifs("H-GammaOnly-Si64.dat");
std::ifstream ifs;
std::string filename = "H-GammaOnly-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs, hmatrix);
ifs.close();
DIAGOTEST::hmatrix_d = hmatrix;
Expand Down
10 changes: 9 additions & 1 deletion source/module_hsolver/test/diago_david_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,15 @@ INSTANTIATE_TEST_SUITE_P(VerifyDiag,DiagoDavTest,::testing::Values(
TEST(DiagoDavRealSystemTest, dataH)
{
std::vector<std::complex<double>> hmatrix;
std::ifstream ifs("H-KPoints-Si64.dat");
std::ifstream ifs;
std::string filename = "H-KPoints-Si64.dat";
ifs.open(filename);
// open file and check status
if (!ifs.is_open())
{
std::cout << "Error opening file " << filename << std::endl;
exit(1);
}
DIAGOTEST::readh(ifs,hmatrix);
ifs.close();
DIAGOTEST::hmatrix = hmatrix;
Expand Down

0 comments on commit 454816b

Please sign in to comment.