Bridge++  Ver. 2.0.2
fprop_Standard_lex.cpp
Go to the documentation of this file.
1 
14 #include "fprop_Standard_lex.h"
15 #include "Tools/timer.h"
16 
17 const std::string Fprop_Standard_lex::class_name = "Fprop_Standard_lex";
18 
19 //====================================================================
21 {
23 }
24 
25 
26 //====================================================================
27 void Fprop_Standard_lex::invert_D(Field& xq, const Field& b, int& Nconv, double& diff)
28 {
29  m_solver->get_fopr()->set_mode("D");
30 
31 #pragma omp parallel
32  {
33  m_solver->solve(xq, b, Nconv, diff);
34  }
35 }
36 
37 
38 //====================================================================
39 void Fprop_Standard_lex::invert_DdagD(Field& xq, const Field& b, int& Nconv, double& diff)
40 {
41  m_solver->get_fopr()->set_mode("DdagD");
42 
43 #pragma omp parallel
44  {
45  m_solver->solve(xq, b, Nconv, diff);
46  }
47 }
48 
49 
50 //====================================================================
52 {
53  return m_solver->flop_count();
54 }
55 
56 
57 //====================================================================
58 void Fprop_Standard_lex::mult_performance(const std::string mode,
59  const int Nrepeat)
60 {
61  Fopr *fopr = m_solver->get_fopr();
62 
63  int nin = fopr->field_nin();
64  int nvol = fopr->field_nvol();
65  int nex = fopr->field_nex();
66 
67  Field axq(nin, nvol, nex), abq(nin, nvol, nex);
68  abq.set(0.0);
69  abq.set(0, 1.0);
70 
71  unique_ptr<Timer> timer(new Timer);
72 
73  std::string mode_prev = fopr->get_mode();
74 
75  fopr->set_mode(mode);
76 
77  timer->start();
78 
79 #pragma omp parallel
80  {
81  for (int i = 0; i < Nrepeat; ++i) {
82  fopr->mult(axq, abq);
83  fopr->mult(abq, axq);
84  }
85  }
86 
87  timer->stop();
88 
89  double flop_fopr = fopr->flop_count() * 1.e9;
90  // note that fopr->flop_count() is in units of GFlop
91  double flop_total = flop_fopr * double(2 * Nrepeat);
92 
93  double elapsed_time = timer->elapsed_sec();
94  double flops = flop_total / elapsed_time;
95  double gflops = flops * 1.0e-9;
96 
97  vout.general(m_vl, "\n");
98  vout.general(m_vl, "%s: mult performance:\n", class_name.c_str());
99  vout.general(m_vl, " mult mode = %s\n", mode.c_str());
100  vout.general(m_vl, " Elapsed time = %14.6f sec\n", elapsed_time);
101  vout.general(m_vl, " Flop(Fopr) = %18.0f\n", flop_fopr);
102  vout.general(m_vl, " Flop(total) = %18.0f\n", flop_total);
103  vout.general(m_vl, " Performance = %11.3f GFlops\n", gflops);
104 
105  fopr->set_mode(mode_prev);
106 }
107 
108 
109 //============================================================END=====
Fprop_Standard_lex::invert_D
void invert_D(Field &, const Field &, int &, double &)
Definition: fprop_Standard_lex.cpp:27
AFopr< Field >
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
AFopr::mult
virtual void mult(AFIELD &, const AFIELD &)
multiplies fermion operator to a given field.
Definition: afopr.h:95
Solver::flop_count
virtual double flop_count()=0
Fprop_Standard_lex::m_solver
Solver * m_solver
Definition: fprop_Standard_lex.h:39
AFopr::field_nex
virtual int field_nex()=0
returns the external degree of freedom of the fermion field.
fprop_Standard_lex.h
AFopr::set_mode
virtual void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr.h:81
Timer
Definition: timer.h:31
AFopr::set_config
virtual void set_config(Field *)=0
sets the gauge configuration.
Fprop_Standard_lex::set_config
void set_config(Field *)
Definition: fprop_Standard_lex.cpp:20
Solver::solve
virtual void solve(Field &solution, const Field &source, int &Nconv, double &diff)=0
AFopr::get_mode
virtual std::string get_mode() const
returns the current mult mode.
Definition: afopr.h:88
timer.h
AFopr::field_nvol
virtual int field_nvol()=0
returns the volume of the fermion field.
AFopr::flop_count
virtual double flop_count()
returns the number of floating point operations.
Definition: afopr.h:160
Fprop::m_vl
Bridge::VerboseLevel m_vl
Definition: fprop.h:37
Solver::get_fopr
virtual Fopr * get_fopr()=0
Fprop_Standard_lex::flop_count
double flop_count()
Definition: fprop_Standard_lex.cpp:51
Fprop_Standard_lex::class_name
static const std::string class_name
Definition: fprop_Standard_lex.h:36
Fprop_Standard_lex::invert_DdagD
void invert_DdagD(Field &, const Field &, int &, double &)
Definition: fprop_Standard_lex.cpp:39
Field
Container of Field-type object.
Definition: field.h:46
AFopr::field_nin
virtual int field_nin()=0
returns the on-site degree of freedom of the fermion field.
Fprop_Standard_lex::mult_performance
void mult_performance(const std::string mode, const int Nrepeat)
Definition: fprop_Standard_lex.cpp:58
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512