forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiago_params.cpp
More file actions
106 lines (96 loc) · 6.33 KB
/
diago_params.cpp
File metadata and controls
106 lines (96 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "diago_params.h"
#include "diago_iter_assist.h"
namespace hsolver
{
template <typename T, typename Device>
void setup_diago_params_pw(const int istep,
const int iter,
const double ethr,
const Input_para& inp)
{
/// choose if psi should be diag in subspace
/// be careful that istep start from 0 and iter start from 1
DiagoIterAssist<T, Device>::need_subspace = ((istep == 0 || istep == 1) && iter == 1) ? false : true;
DiagoIterAssist<T, Device>::SCF_ITER = iter;
DiagoIterAssist<T, Device>::PW_DIAG_THR = ethr;
if (inp.calculation != "nscf")
{
DiagoIterAssist<T, Device>::PW_DIAG_NMAX = inp.pw_diag_nmax;
}
}
template <typename T, typename Device>
void setup_diago_params_sdft(const int istep,
const int iter,
const double ethr,
const Input_para& inp)
{
/// choose if psi should be diag in subspace
/// be careful that istep start from 0 and iter start from 1
if (istep == 0 && iter == 1 || inp.calculation == "nscf")
{
DiagoIterAssist<T, Device>::need_subspace = false;
}
else
{
DiagoIterAssist<T, Device>::need_subspace = true;
}
DiagoIterAssist<T, Device>::PW_DIAG_THR = ethr;
DiagoIterAssist<T, Device>::PW_DIAG_NMAX = inp.pw_diag_nmax;
}
/// Template instantiation for CPU
template void setup_diago_params_pw<std::complex<float>, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_pw<std::complex<double>, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_pw<double, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
/// Template instantiation for GPU
#if ((defined __CUDA) || (defined __ROCM))
template void setup_diago_params_pw<std::complex<float>, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_pw<std::complex<double>, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_pw<double, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
#endif
/// Template instantiation for SDFT CPU
template void setup_diago_params_sdft<std::complex<float>, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_sdft<std::complex<double>, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_sdft<double, base_device::DEVICE_CPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
/// Template instantiation for SDFT GPU
#if ((defined __CUDA) || (defined __ROCM))
template void setup_diago_params_sdft<std::complex<float>, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_sdft<std::complex<double>, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
template void setup_diago_params_sdft<double, base_device::DEVICE_GPU>(const int istep,
const int iter,
const double ethr,
const Input_para& inp);
#endif
} // namespace hsolver