Skip to content

Commit 7a8a647

Browse files
committed
- test elpa by real Si system produced H/S matrix
- modify the parallel test to be only run one time
1 parent 03f119e commit 7a8a647

File tree

8 files changed

+3402
-43
lines changed

8 files changed

+3402
-43
lines changed

source/src_pdiag/test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ install(FILES H-KPoints.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
88
install(FILES H-GammaOnly.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
99
install(FILES S-KPoints.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
1010
install(FILES S-GammaOnly.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
11+
install(FILES H-KPoints-large.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
12+
install(FILES H-GammaOnly-large.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
13+
install(FILES S-KPoints-large.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
14+
install(FILES S-GammaOnly-large.dat DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
15+
install(FILES diago_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
1116
install(FILES diago_elpa_parallel_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
1217

1318
find_program(BASH bash)
1419
add_test(NAME hsolver_diago_elpa_parallel
1520
COMMAND ${BASH} diago_elpa_parallel_test.sh
1621
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
17-
)
22+
)

source/src_pdiag/test/H-GammaOnly-large.dat

Lines changed: 832 additions & 0 deletions
Large diffs are not rendered by default.

source/src_pdiag/test/H-KPoints-large.dat

Lines changed: 832 additions & 0 deletions
Large diffs are not rendered by default.

source/src_pdiag/test/S-GammaOnly-large.dat

Lines changed: 832 additions & 0 deletions
Large diffs are not rendered by default.

source/src_pdiag/test/S-KPoints-large.dat

Lines changed: 832 additions & 0 deletions
Large diffs are not rendered by default.

source/src_pdiag/test/diago_elpa_parallel_test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
55

6-
for i in 2 3 4 6;do
6+
for i in 6 3 2;do
77
if [[ $i -gt $np ]];then
8-
break
8+
continue
99
fi
1010
echo "TEST ELPA in parallel, nprocs=$i"
1111
mpirun -np $i ./hsolver_diago_elpa
12+
break
1213
done
1314

1415

source/src_pdiag/test/diago_elpa_test.cpp

Lines changed: 64 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <type_traits>
77

88
#define DETAILINFO false
9-
#define PASSTHRESHOLD 1e-4
9+
#define PASSTHRESHOLD 1e-12
1010
#define PRINT_NEW_MATRIX false // print out the H matrix after doing block-cycle distribution
11-
#define PRINT_HS false
11+
#define PRINT_HS false
1212

1313
/************************************************
1414
* unit test of ELPA
@@ -49,6 +49,7 @@ template <class T> class ElpaPrepare
4949
double *e_elpa = nullptr;
5050
double lapack_time = 0.0, elpa_time = 0.0;
5151
int mypnum = 0;
52+
std::string sfname, hfname;
5253

5354
void random_HS()
5455
{
@@ -61,17 +62,9 @@ template <class T> class ElpaPrepare
6162
bool readsfile = false;
6263
if (mypnum == 0)
6364
{
64-
std::vector<T> htmp,stmp;
65-
if (std::is_same<T, double>::value)
66-
{
67-
readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string("H-GammaOnly.dat"),htmp);
68-
readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string("S-GammaOnly.dat"),stmp);
69-
}
70-
else if ((std::is_same<T, std::complex<double>>::value))
71-
{
72-
readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string("H-KPoints.dat"),htmp);
73-
readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(std::string("S-KPoints.dat"),stmp);
74-
}
65+
std::vector<T> htmp, stmp;
66+
readhfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(hfname, htmp);
67+
readsfile = LCAO_DIAGO_TEST::read_hs<std::vector<T>>(sfname, stmp);
7568
if (htmp.size() != stmp.size())
7669
{
7770
printf("Error: dimensions of H and S are not equal, %d, %d", htmp.size(), stmp.size());
@@ -81,12 +74,12 @@ template <class T> class ElpaPrepare
8174
hmatrix = new T[htmp.size()];
8275
smatrix = new T[stmp.size()];
8376

84-
for(int i=0;i<htmp.size();i++)
77+
for (int i = 0; i < htmp.size(); i++)
8578
{
8679
hmatrix[i] = htmp[i];
8780
smatrix[i] = stmp[i];
8881
}
89-
82+
9083
n = sqrt(stmp.size());
9184
nblk = 1;
9285
}
@@ -101,8 +94,10 @@ template <class T> class ElpaPrepare
10194
e_lapack[i] = 0.0;
10295
e_elpa[i] = 1.0;
10396
}
104-
if (readhfile && readsfile) return true;
105-
else return false;
97+
if (readhfile && readsfile)
98+
return true;
99+
else
100+
return false;
106101
}
107102

108103
void new_matrix()
@@ -120,7 +115,10 @@ template <class T> class ElpaPrepare
120115

121116
void print_hs()
122117
{
123-
if(! PRINT_HS) {return;}
118+
if (!PRINT_HS)
119+
{
120+
return;
121+
}
124122
if (mypnum == 0)
125123
{
126124
std::ofstream fp("hmatrix.dat");
@@ -197,6 +195,18 @@ class ElpaComplexDoubleTest : public ::testing::TestWithParam<ElpaPrepare<std::c
197195
TEST(VerifyElpaDiaoDouble, ReadHS)
198196
{
199197
ElpaPrepare<double> edp;
198+
edp.hfname = "H-GammaOnly.dat";
199+
edp.sfname = "S-GammaOnly.dat";
200+
ASSERT_TRUE(edp.read_HS());
201+
edp.print_hs();
202+
edp.run_diago();
203+
}
204+
205+
TEST(VerifyElpaDiaoDouble, ReadLargeHS)
206+
{
207+
ElpaPrepare<double> edp;
208+
edp.hfname = "H-GammaOnly-large.dat";
209+
edp.sfname = "S-GammaOnly-large.dat";
200210
ASSERT_TRUE(edp.read_HS());
201211
edp.print_hs();
202212
edp.run_diago();
@@ -205,11 +215,24 @@ TEST(VerifyElpaDiaoDouble, ReadHS)
205215
TEST(VerifyElpaDiaoComplexDouble, ReadHS)
206216
{
207217
ElpaPrepare<std::complex<double>> edp;
218+
edp.hfname = "H-KPoints.dat";
219+
edp.sfname = "S-KPoints.dat";
208220
ASSERT_TRUE(edp.read_HS());
209221
edp.print_hs();
210222
edp.run_diago();
211223
}
212224

225+
TEST(VerifyElpaDiaoComplexDouble, ReadLargeHS)
226+
{
227+
ElpaPrepare<std::complex<double>> edp;
228+
edp.hfname = "H-KPoints-large.dat";
229+
edp.sfname = "S-KPoints-large.dat";
230+
ASSERT_TRUE(edp.read_HS());
231+
edp.print_hs();
232+
edp.run_diago();
233+
}
234+
235+
/**
213236
TEST_P(ElpaDoubleTest, RandomHS)
214237
{
215238
ElpaPrepare<double> edp = GetParam();
@@ -219,16 +242,17 @@ TEST_P(ElpaDoubleTest, RandomHS)
219242
edp.run_diago();
220243
}
221244
222-
INSTANTIATE_TEST_SUITE_P(VerifyElpaB2DDiag,
223-
ElpaDoubleTest,
224-
::testing::Values(ElpaPrepare<double>(5, 1, 0),
225-
// ElpaPrepare<double>(100,1,7),
226-
// ElpaPrepare<double>(500,1,0),
227-
ElpaPrepare<double>(500, 1, 7),
228-
ElpaPrepare<double>(500, 32, 7)
229-
// ElpaPrepare<double>(1000,64,10)
230-
// ElpaDoublePrepare<double>(2000,128,7)
231-
));
245+
INSTANTIATE_TEST_SUITE_P(
246+
VerifyElpaB2DDiag,
247+
ElpaDoubleTest,
248+
::testing::Values(ElpaPrepare<double>(5, 1, 0),
249+
// ElpaPrepare<double>(100,1,7),
250+
// ElpaPrepare<double>(500,1,0),
251+
ElpaPrepare<double>(500, 1, 7),
252+
ElpaPrepare<double>(500, 32, 7)
253+
// ElpaPrepare<double>(1000,64,10)
254+
// ElpaDoublePrepare<double>(2000,128,7)
255+
));
232256
233257
TEST_P(ElpaComplexDoubleTest, RandomHS)
234258
{
@@ -239,17 +263,18 @@ TEST_P(ElpaComplexDoubleTest, RandomHS)
239263
edp.run_diago();
240264
}
241265
242-
INSTANTIATE_TEST_SUITE_P(VerifyElpaB2DDiag,
243-
ElpaComplexDoubleTest,
244-
::testing::Values(ElpaPrepare<std::complex<double>>(5, 1, 0),
245-
// ElpaPrepare<std::complex<double>>(100,1,7),
246-
// ElpaPrepare<std::complex<double>>(500,1,0),
247-
ElpaPrepare<std::complex<double>>(500, 1, 7),
248-
ElpaPrepare<std::complex<double>>(500, 32, 7)
249-
// ElpaPrepare<std::complex<double>>(800,64,9)
250-
// ElpaDoublePrepare<double>(2000,128,7)
251-
));
252-
266+
INSTANTIATE_TEST_SUITE_P(
267+
VerifyElpaB2DDiag,
268+
ElpaComplexDoubleTest,
269+
::testing::Values(ElpaPrepare<std::complex<double>>(5, 1, 0),
270+
// ElpaPrepare<std::complex<double>>(100,1,7),
271+
// ElpaPrepare<std::complex<double>>(500,1,0),
272+
ElpaPrepare<std::complex<double>>(500, 1, 7),
273+
ElpaPrepare<std::complex<double>>(500, 32, 7)
274+
// ElpaPrepare<std::complex<double>>(800,64,9)
275+
// ElpaDoublePrepare<double>(2000,128,7)
276+
));
277+
*/
253278
int main(int argc, char **argv)
254279
{
255280
MPI_Init(&argc, &argv);

source/src_pdiag/test/diago_elpa_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int elpa_sethandle(elpa_t &handle,
216216

217217
elpa_set_integer(handle, "cannon_for_generalized", 0, &error);
218218
if (error != 0)
219-
printf("ERROR: set blacs_context error=%d!\n", error);
219+
printf("ERROR: set cannon_for_generalized error=%d!\n", error);
220220

221221
/* Setup */
222222
elpa_setup(handle); /* Set tunables */

0 commit comments

Comments
 (0)