12 template<
typename AFIELD>
14 =
"ASolver_BiCGStab_Precond";
16 template<
typename AFIELD>
21 int nin = m_fopr->field_nin();
22 int nvol = m_fopr->field_nvol();
23 int nex = m_fopr->field_nex();
25 m_r.reset(nin, nvol, nex);
26 m_x.reset(nin, nvol, nex);
27 m_p.reset(nin, nvol, nex);
28 m_s.reset(nin, nvol, nex);
29 m_v.reset(nin, nvol, nex);
30 m_t.reset(nin, nvol, nex);
31 m_rh.reset(nin, nvol, nex);
32 m_u.reset(nin, nvol, nex);
39 template<
typename AFIELD>
48 template<
typename AFIELD>
52 const string str_vlevel = params.
get_string(
"verbose_level");
61 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
62 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
63 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
66 vout.
crucial(m_vl,
"Error at %s: input parameter not found.\n",
71 int Niter2 = Niter * Nrestart;
72 set_parameters(Niter2, Stop_cond);
77 template<
typename AFIELD>
84 m_Stop_cond = Stop_cond;
85 std::string prec =
"double";
86 if (
sizeof(
real_t) == 4) prec =
"float";
89 vout.
general(m_vl,
" Precision: %s\n", prec.c_str());
91 vout.
general(m_vl,
" Stop_cond = %16.8e\n", m_Stop_cond);
96 template<
typename AFIELD>
101 vout.
paranoiac(m_vl,
"%s: solver start.\n", class_name.c_str());
111 m_prec->reset_flop_count();
118 for (
int iter = 0; iter < m_Niter; ++iter) {
122 if (rr * snorm < m_Stop_cond) {
123 nconv = 2 * (iter + 1);
132 m_Niter, rr * snorm);
141 m_fopr->mult(m_s, xq);
158 template<
typename AFIELD>
164 m_fopr->mult(m_v, m_x);
175 m_alpha_prev =
real_t(1.0);
176 m_omega_prev =
real_t(1.0);
181 template<
typename AFIELD>
185 real_t bet = rho * m_alpha_prev / (m_rho_prev * m_omega_prev);
188 axpy(m_p, -m_omega_prev, m_v);
191 m_prec->mult(m_u, m_p);
192 m_fopr->mult(m_v, m_u);
195 real_t alpha = rho / aden;
198 axpy(m_s, -alpha, m_v);
200 m_prec->mult(m_v, m_s);
201 m_fopr->mult(m_t, m_v);
205 real_t omega = omega_n / omega_d;
208 axpy(m_x, omega, m_v);
209 axpy(m_x, alpha, m_u);
212 axpy(m_r, -omega, m_t);
217 m_alpha_prev = alpha;
218 m_omega_prev = omega;
223 template<
typename AFIELD>
231 template<
typename AFIELD>
234 int Nin = m_fopr->field_nin();
235 int Nvol = m_fopr->field_nvol();
236 int Nex = m_fopr->field_nex();
241 double flop_field =
static_cast<double>(Nin * Nvol * Nex) * NPE;
243 double flop_vector = (6 + ninit * 4 + m_nconv * 11) * flop_field;
244 double flop_fopr = (1 + ninit + m_nconv) * m_fopr->flop_count();
245 double flop_prec = m_prec->flop_count();
247 double flop = flop_vector + flop_fopr + flop_prec;