Skip to content

Commit 30bc4ad

Browse files
committed
make sdft+bpcg support GPU
1 parent 65e4ba1 commit 30bc4ad

File tree

11 files changed

+93
-8
lines changed

11 files changed

+93
-8
lines changed

source/module_base/para_gemm.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,17 @@ void PGemmCN<T, Device>::multiply_col(const T alpha, const T* A, const T* B, con
241241
{
242242
T* Cglobal_cpu = nullptr;
243243
T* Clocal_cpu = C_tmp.data();
244-
;
244+
std::vector<T> cpu_tmp;
245+
245246
if (std::is_same<Device, base_device::DEVICE_GPU>::value)
246247
{
247248
delmem_dev_op()(Atmp_device);
248249

249250
syncmem_d2h_op()(Clocal_cpu, C_local, size_C_local);
250251
delmem_dev_op()(C_local);
251252

252-
resmem_dev_op()(Cglobal_cpu, size_C_global);
253+
cpu_tmp.resize(size_C_global);
254+
Cglobal_cpu = cpu_tmp.data();
253255
}
254256
else
255257
{
@@ -269,7 +271,6 @@ void PGemmCN<T, Device>::multiply_col(const T alpha, const T* A, const T* B, con
269271
if (std::is_same<Device, base_device::DEVICE_GPU>::value)
270272
{
271273
syncmem_h2d_op()(C, Cglobal_cpu, size_C_global);
272-
delmem_dev_op()(Cglobal_cpu);
273274
}
274275
}
275276
else

tests/integrate/102_PW_BPCG_GPU/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ smearing_sigma 0.02
1515
ecutwfc 40
1616
scf_thr 1e-7
1717
scf_nmax 100
18+
bndpar 2
1819

1920
#Parameters (LCAO)
2021
basis_type pw
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
etotref -4869.7470518350019120
2-
etotperatomref -2434.8735259175
3-
totalforceref 5.207670
4-
totalstressref 37241.465646
1+
etotref -4869.7470520365577613
2+
etotperatomref -2434.8735260183
3+
totalforceref 5.202524
4+
totalstressref 37241.827525
55
pointgroupref C_1
66
spacegroupref C_1
77
nksibzref 8
8-
totaltimeref 4.25
8+
totaltimeref 4.25
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
INPUT_PARAMETERS
2+
#Parameters (1.General)
3+
suffix autotest
4+
calculation scf
5+
esolver_type sdft
6+
method_sto 2
7+
device gpu
8+
ks_solver bpcg
9+
10+
symmetry 0
11+
pseudo_dir ../../PP_ORB
12+
13+
kpar 1
14+
bndpar 2
15+
16+
nbands 9
17+
nbands_sto all
18+
19+
nche_sto 120
20+
seed_sto 20000
21+
cal_force 1
22+
cal_stress 1
23+
24+
#Parameters (2.Iteration)
25+
ecutwfc 30
26+
scf_thr 1e-6
27+
scf_nmax 20
28+
29+
30+
#Parameters (3.Basis)
31+
basis_type pw
32+
33+
#Parameters (4.Smearing)
34+
smearing_method fd
35+
smearing_sigma 0.6
36+
37+
#Parameters (5.Mixing)
38+
mixing_type plain
39+
mixing_beta 0.7
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
1 1 1 0 0 0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This test for:
2+
*SDFT
3+
*Si
4+
*kpoints 1*1*1
5+
*10 KS + complete orbitals
6+
*ks_solver bpcg
7+
*mixing_type plain
8+
*mixing_beta 0.7
9+
*sto_method 2
10+
*seed_sto > 0
11+
*bndpar 2
12+
*kpar 1
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ATOMIC_SPECIES
2+
Si 28 Si.pz-vbc.UPF
3+
4+
LATTICE_CONSTANT
5+
5 // add lattice constant
6+
7+
LATTICE_VECTORS
8+
0.5 0 0.5
9+
0.5 0.5 0
10+
0 0.5 0.5
11+
12+
ATOMIC_POSITIONS
13+
Direct
14+
15+
Si // Element type
16+
0.0 // magnetism
17+
2
18+
0.10 0.00 0.20 1 1 1
19+
0.5 0.5 0.5 1 1 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test parallel method bndpar with BPCG and GPU
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
etotref -96.9361135992121490
2+
etotperatomref -48.4680567996
3+
totalforceref 248.977364
4+
totalstressref 230452.899030
5+
totaltimeref 7.19

tests/integrate/CASES_CPU.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
101_PW_GTH_CF_CS_Si
2525
102_PW_DA_davidson
2626
102_PW_BPCG
27+
102_PW_BPCG_BP
2728
102_PW_CG
2829
102_PW_DS_davsubspace
2930
102_PW_DS_davsubspace_sca
@@ -123,6 +124,7 @@
123124
184_PW_BNDKPAR_SDFT_MALL
124125
184_PW_BNDPAR_SDFT_10S
125126
184_PW_BNDPAR_SDFT_5D10S
127+
184_PW_BPCG_SDFT_5D10S
126128
184_PW_KPAR_SDFT_ALL
127129
185_PW_SDFT_10D10S_METHD2
128130
185_PW_SDFT_10S_METHD2

0 commit comments

Comments
 (0)