10 template<
typename AFIELD>
12 =
"Fprop_alt_Standard_lex";
14 template<
typename AFIELD>
21 vout.
general(m_vl,
"%s: being setup (without link smearing).\n",
29 string fopr_type = params_fopr.
get_string(
"fermion_type");
30 m_fopr = AltFopr::New(fopr_type, params_fopr);
36 string solver_type = params_solver.
get_string(
"solver_type");
37 m_solver = AltSolver::New(solver_type, m_fopr);
38 m_solver->set_parameters(params_solver);
42 vout.
general(m_vl,
"%s: setup finished.\n", class_name.c_str());
47 template<
typename AFIELD>
53 vout.
general(m_vl,
"%s: being setup (with link smearing).\n",
59 m_dr_smear = dr_smear;
61 string fopr_type = params_fopr.
get_string(
"fermion_type");
62 m_kernel = AltFopr::New(fopr_type, params_fopr);
67 string solver_type = params_solver.
get_string(
"solver_type");
68 m_solver = AltSolver::New(solver_type, m_fopr);
69 m_solver->set_parameters(params_solver);
73 vout.
general(m_vl,
"%s: setup finished.\n", class_name.c_str());
78 template<
typename AFIELD>
83 if (m_kernel != 0)
delete m_kernel;
88 template<
typename AFIELD>
91 m_fopr->set_config(U);
96 template<
typename AFIELD>
98 int& nconv,
double& diff)
100 vout.
paranoiac(m_vl,
"%s: invert is called.\n", class_name.c_str());
104 invert_D(xq, b, nconv, diff);
105 }
else if (m_mode ==
"DdagD") {
106 invert_DdagD(xq, b, nconv, diff);
107 }
else if (m_mode ==
"D_prec") {
108 invert_D_prec(xq, b, nconv, diff);
109 }
else if (m_mode ==
"DdagD_prec") {
110 invert_DdagD_prec(xq, b, nconv, diff);
113 class_name.c_str(), m_mode.c_str());
120 template<
typename AFIELD>
122 int& nconv,
double& diff)
127 int nin = m_fopr->field_nin();
128 int nvol = m_fopr->field_nvol();
129 int nex = m_fopr->field_nex();
131 vout.
paranoiac(m_vl,
"nin = %d nvol = %d nex = %d\n", nin, nvol, nex);
133 AFIELD axq(nin, nvol, nex);
134 AFIELD abq(nin, nvol, nex);
140 if (m_fopr->needs_convert()) {
142 m_fopr->convert(abq, b);
149 vout.
detailed(m_vl,
"%s: convert finished.\n", class_name.c_str());
151 m_fopr->set_mode(
"D");
157 m_solver->solve(axq, abq, nconv, diff2);
159 diff = double(diff2);
163 if (m_fopr->needs_convert()) {
164 m_fopr->reverse(xq, axq);
171 m_elapsed_time += m_timer.elapsed_sec();
172 m_flop_count += m_solver->flop_count();
177 template<
typename AFIELD>
179 int& nconv,
double& diff)
184 int nin = m_fopr->field_nin();
185 int nvol = m_fopr->field_nvol();
186 int nex = m_fopr->field_nex();
188 AFIELD axq(nin, nvol, nex);
189 AFIELD abq(nin, nvol, nex);
195 if (m_fopr->needs_convert()) {
196 m_fopr->convert(abq, b);
204 m_fopr->set_mode(
"DdagD");
208 m_solver->solve(axq, abq, nconv, diff2);
210 diff = double(diff2);
214 if (m_fopr->needs_convert()) {
215 m_fopr->reverse(xq, axq);
222 m_elapsed_time += m_timer.elapsed_sec();
223 m_flop_count += m_solver->flop_count();
228 template<
typename AFIELD>
231 int& nconv,
double& diff)
236 int nin = m_fopr->field_nin();
237 int nvol = m_fopr->field_nvol();
238 int nex = m_fopr->field_nex();
240 AFIELD axq(nin, nvol, nex);
241 AFIELD abq(nin, nvol, nex);
245 if (m_fopr->needs_convert()) {
246 m_fopr->convert(abq, b);
251 m_fopr->set_mode(
"D_prec");
257 m_solver->solve(axq, abq, nconv, diff2);
259 m_flop_count += m_solver->flop_count();
261 m_fopr->mult(abq, axq,
"Prec");
263 if (m_fopr->needs_convert()) {
264 m_fopr->reverse(xq, abq);
269 diff = double(diff2);
272 m_elapsed_time += m_timer.elapsed_sec();
274 m_flop_count += 2 * m_fopr->flop_count();
279 template<
typename AFIELD>
282 int& nconv,
double& diff)
289 int nin = m_fopr->field_nin();
290 int nvol = m_fopr->field_nvol();
291 int nex = m_fopr->field_nex();
293 AFIELD axq(nin, nvol, nex);
294 AFIELD abq(nin, nvol, nex);
298 if (m_fopr->needs_convert()) {
299 m_fopr->convert(axq, b);
304 m_fopr->mult(abq, axq,
"Precdag");
306 m_fopr->set_mode(
"DdagD_prec");
312 m_solver->solve(axq, abq, nconv, diff2);
314 m_flop_count += m_solver->flop_count();
316 m_fopr->mult(abq, axq,
"Prec");
318 if (m_fopr->needs_convert()) {
319 m_fopr->reverse(xq, abq);
324 diff = double(diff2);
327 m_elapsed_time += m_timer.elapsed_sec();
329 m_flop_count += 2 * m_fopr->flop_count();
334 template<
typename AFIELD>
337 int& nconv,
double& diff)
339 vout.
paranoiac(m_vl,
"%s: invert is called.\n", class_name.c_str());
343 invert_D(xq, b, nconv, diff);
344 }
else if (m_mode ==
"DdagD") {
345 invert_DdagD(xq, b, nconv, diff);
346 }
else if (m_mode ==
"D_prec") {
347 invert_D_prec(xq, b, nconv, diff);
348 }
else if (m_mode ==
"DdagD_prec") {
349 invert_DdagD_prec(xq, b, nconv, diff);
352 class_name.c_str(), m_mode.c_str());
359 template<
typename AFIELD>
362 int& nconv,
double& diff)
367 m_fopr->set_mode(
"D");
373 m_solver->solve(axq, abq, nconv, diff2);
375 diff = double(diff2);
378 m_elapsed_time += m_timer.elapsed_sec();
379 m_flop_count += m_solver->flop_count();
384 template<
typename AFIELD>
387 int& nconv,
double& diff)
394 m_fopr->set_mode(
"DdagD");
398 m_solver->solve(axq, abq, nconv, diff2);
400 diff = double(diff2);
403 m_elapsed_time += m_timer.elapsed_sec();
404 m_flop_count += m_solver->flop_count();
409 template<
typename AFIELD>
412 int& nconv,
double& diff)
417 int nin = m_fopr->field_nin();
418 int nvol = m_fopr->field_nvol();
419 int nex = m_fopr->field_nex();
420 AFIELD atmp(nin, nvol, nex);
422 m_fopr->set_mode(
"D_prec");
428 m_solver->solve(atmp, abq, nconv, diff2);
430 m_flop_count += m_solver->flop_count();
431 m_fopr->mult(axq, atmp,
"Prec");
433 diff = double(diff2);
436 m_elapsed_time += m_timer.elapsed_sec();
438 m_flop_count += 2 * m_fopr->flop_count();
443 template<
typename AFIELD>
446 int& nconv,
double& diff)
453 int nin = m_fopr->field_nin();
454 int nvol = m_fopr->field_nvol();
455 int nex = m_fopr->field_nex();
456 AFIELD atmp(nin, nvol, nex);
458 m_fopr->mult(axq, abq,
"Precdag");
460 m_fopr->set_mode(
"DdagD_prec");
466 m_solver->solve(atmp, axq, nconv, diff2);
468 m_flop_count += m_solver->flop_count();
470 m_fopr->mult(axq, atmp,
"Prec");
472 diff = double(diff2);
475 m_elapsed_time += m_timer.elapsed_sec();
477 m_flop_count += 2 * m_fopr->flop_count();
482 template<
typename AFIELD>
485 return m_solver->flop_count();
490 template<
typename AFIELD>
494 m_elapsed_time = 0.0;
499 template<
typename AFIELD>
501 double& elapsed_time)
503 flop_count = m_flop_count;
504 elapsed_time = m_elapsed_time;
509 template<
typename AFIELD>
512 double flops = m_flop_count / m_elapsed_time;
513 double gflops = flops * 1.0e-9;
516 vout.
general(m_vl,
"%s: solver performance:\n", class_name.c_str());
517 vout.
general(m_vl,
" Elapsed time = %14.6f sec\n", m_elapsed_time);
518 vout.
general(m_vl,
" Flop(total) = %18.0f\n", m_flop_count);
519 vout.
general(m_vl,
" Performance = %11.3f GFlops\n", gflops);
524 template<
typename AFIELD>
526 const std::string mode,
531 int nin = m_fopr->field_nin();
532 int nvol = m_fopr->field_nvol();
533 int nex = m_fopr->field_nex();
535 AFIELD axq(nin, nvol, nex), abq(nin, nvol, nex);
539 unique_ptr<Timer> timer(
new Timer);
541 std::string mode_prev = m_fopr->get_mode();
543 m_fopr->set_mode(mode);
549 for (
int i = 0; i < Nrepeat; ++i) {
550 m_fopr->mult(axq, abq);
551 m_fopr->mult(abq, axq);
557 double flop_fopr = m_fopr->flop_count();
558 double flop_total = flop_fopr * double(2 * Nrepeat);
560 double elapsed_time = timer->elapsed_sec();
561 double flops = flop_total / elapsed_time;
562 double gflops = flops * 1.0e-9;
565 vout.
general(m_vl,
"%s: mult performance:\n", class_name.c_str());
566 vout.
general(m_vl,
" mult mode = %s\n", mode.c_str());
567 vout.
general(m_vl,
" Elapsed time = %14.6f sec\n", elapsed_time);
568 vout.
general(m_vl,
" Flop(Fopr) = %18.0f\n", flop_fopr);
569 vout.
general(m_vl,
" Flop(total) = %18.0f\n", flop_total);
570 vout.
general(m_vl,
" Performance = %11.3f GFlops\n", gflops);
572 m_fopr->set_mode(mode_prev);