Bridge++  Ver. 2.0.2
action_F_Ratio_lex_alt-tmpl.h
Go to the documentation of this file.
1 
10 template<typename AFIELD>
12  = "Action_F_Ratio_lex_alt";
13 
14 //====================================================================
15 template<typename AFIELD>
17 {
18  m_vl = CommonParameters::Vlevel();
19 }
20 
21 
22 //====================================================================
23 template<typename AFIELD>
25 {
26  // do nothing.
27 }
28 
29 
30 //====================================================================
31 template<typename AFIELD>
33 {
35  set_parameter_verboselevel(vl);
36 }
37 
38 
39 //====================================================================
40 template<typename AFIELD>
42 {
43  vout.general(m_vl, "%s:\n", class_name.c_str());
44 }
45 
46 
47 //====================================================================
48 template<typename AFIELD>
50 {
51  m_U = U;
52 
53  m_fopr_prec->set_config(U);
54  m_fopr_prec_force->set_config(U);
55 
56  m_fopr->set_config(U);
57  m_fopr_force->set_config(U);
58 }
59 
60 
61 //====================================================================
62 template<typename AFIELD>
64 {
65  const int Nvol = CommonParameters::Nvol();
66  const int Ndim = CommonParameters::Ndim();
67 
68  const int NinF = m_fopr_prec->field_nin();
69  const int NvolF = m_fopr_prec->field_nvol();
70  const int NexF = m_fopr_prec->field_nex();
71  const int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
72 
73  assert(NvolF == Nvol);
74  m_psf.reset(NinF, NvolF, NexF);
75 
76  Timer timer;
77  double elapsed_time;
78  timer.start();
79 
80  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
81 
82  Field xi(NinF, NvolF, NexF);
83  rand->gauss_lex_global(xi);
84 
85  AFIELD xiA(NinF, NvolF, NexF);
86 
87  Index_lex_alt<real_t, AFIELD::IMPL> index_alt;
88 
89 #pragma omp parallel
90  {
91  if (m_fopr->needs_convert()) {
92  m_fopr->convert(xiA, xi);
93  } else {
94  convert(index_alt, xiA, xi);
95  }
96  }
97 
98  m_fopr_prec->set_config(m_U);
99  m_fopr->set_config(m_U);
100 
101  AFIELD v2(NinF, NvolF, NexF);
102  m_fopr->set_mode("H");
103  m_fopr->mult_dag(v2, xiA);
104 
105  AFIELD v1(NinF, NvolF, NexF);
106  m_fopr_prec->set_mode("H");
107  m_fopr_prec->mult_dag(v1, v2);
108 
109  int Nconv;
110  double diff;
111  m_fprop_H_prec->set_config(m_U);
112  m_fprop_H_prec->set_mode("DdagD");
113  m_fprop_H_prec->invert(m_psf, v1, Nconv, diff);
114  vout.general(m_vl, " Fprop_H_prec: %6d %18.15e\n", Nconv, diff);
115 
116  const double xi2 = xi.norm();
117  const double H_psf = xi2 * xi2;
118 
119  timer.stop();
120  elapsed_time = timer.elapsed_sec();
121 
122  vout.general(m_vl, " H_Fratio = %18.8f\n", H_psf);
123  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
124  vout.general(m_vl, " elapsed time: %12.6f [sec]\n", elapsed_time);
125 
126  return H_psf;
127 }
128 
129 
130 //====================================================================
131 template<typename AFIELD>
133 {
134  const int Nvol = CommonParameters::Nvol();
135  const int Ndim = CommonParameters::Ndim();
136 
137  const int NinF = m_fopr_prec->field_nin();
138  const int NvolF = m_fopr_prec->field_nvol();
139  const int NexF = m_fopr_prec->field_nex();
140  const int size_psf = NinF * NvolF * NexF * CommonParameters::NPE();
141 
142  Timer timer;
143  double elapsed_time;
144  timer.start();
145 
146  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
147 
148  m_fopr_prec->set_config(m_U);
149  m_fopr->set_config(m_U);
150 
151  AFIELD v1(NinF, NvolF, NexF);
152  m_fopr_prec->set_mode("H");
153  m_fopr_prec->mult(v1, m_psf);
154 
155  AFIELD v2(NinF, NvolF, NexF);
156  int Nconv;
157  double diff;
158 
159  m_fprop_H->set_config(m_U);
160  m_fprop_H->reset_performance();
161  m_fprop_H->set_mode("DdagD");
162  m_fprop_H->invert(v2, v1, Nconv, diff);
163 
164  double flop_count, elapsed_time2, gflops;
165  m_fprop_H->get_performance(flop_count, elapsed_time2);
166  if (elapsed_time2 > 0.0) {
167  gflops = (flop_count / elapsed_time2) * 1.0e-9;
168  } else {
169  gflops = 0.0;
170  }
171 
172  vout.general(m_vl, " Fprop_H: %6d %12.4e %12.4e [GFlops]\n",
173  Nconv, diff, gflops);
174 
175  double H_psf = dot(v1, v2);
176 
177  timer.stop();
178  elapsed_time = timer.elapsed_sec();
179 
180  vout.general(m_vl, " H_Fratio = %18.8f\n", H_psf);
181  vout.general(m_vl, " H_F/dof = %18.8f\n", H_psf / size_psf);
182  vout.general(m_vl, " elapsed time: %12.6f [sec]\n", elapsed_time);
183 
184  return H_psf;
185 }
186 
187 
188 //====================================================================
189 template<typename AFIELD>
191 {
192  const int Nin = m_U->nin();
193  const int Nvol = m_U->nvol();
194  const int Nex = m_U->nex();
195  const int Nc = CommonParameters::Nc();
196  const int Ndim = CommonParameters::Ndim();
197 
198  assert(force.nin() == Nin);
199  assert(force.nvol() == Nvol);
200  assert(force.nex() == Nex);
201 
202  AFIELD force1(Nin, Nvol, Nex);
203 
204  int NinF = m_fopr_prec->field_nin();
205  int NvolF = m_fopr_prec->field_nvol();
206  int NexF = m_fopr_prec->field_nex();
207 
208  Timer timer;
209  double elapsed_time;
210  timer.start();
211 
212  vout.general(m_vl, " %s: %s\n", class_name.c_str(), m_label.c_str());
213 
214  m_fopr_prec->set_config(m_U);
215  m_fopr->set_config(m_U);
216  m_fopr_prec_force->set_config(m_U);
217  m_fopr_force->set_config(m_U);
218 
219  AFIELD v1(NinF, NvolF, NexF);
220  m_fopr_prec->set_mode("H");
221 #pragma omp parallel
222  {
223  m_fopr_prec->mult(v1, m_psf);
224  }
225 
226  AFIELD v2(NinF, NvolF, NexF);
227  int Nconv;
228  double diff;
229  m_fprop_MD->set_config(m_U);
230  m_fprop_MD->set_mode("DdagD");
231  m_fprop_MD->invert(v2, v1, Nconv, diff);
232  vout.general(m_vl, " Fprop_MD: %6d %18.15e\n", Nconv, diff);
233 
234  m_fopr_force->force_core(force1, v2);
235 
236  AFIELD force_tmp(Nin, Nvol, Nex);
237  m_fopr_prec_force->set_mode("H");
238  m_fopr_prec_force->force_core1(force_tmp, v2, m_psf);
239 
240 #pragma omp parallel
241  {
242  axpy(force1, -1.0, force_tmp);
243  }
244 
245  m_fopr_prec_force->set_mode("Hdag");
246  m_fopr_prec_force->force_core1(force_tmp, m_psf, v2);
247 
248 #pragma omp parallel
249  {
250  axpy(force1, -1.0, force_tmp);
251  }
252 
253  Index_lex_alt<real_t, AFIELD::IMPL> index_lex;
254 #pragma omp parallel
255  {
256  reverse_gauge(index_lex, force, force1);
257  }
258 
259  double Fave, Fmax, Fdev;
260  force.stat(Fave, Fmax, Fdev);
261 
262  timer.stop();
263  elapsed_time = timer.elapsed_sec();
264 
265  vout.general(m_vl, " Fave = %12.6f Fmax = %12.6f Fdev = %12.6f\n",
266  Fave, Fmax, Fdev);
267  vout.general(m_vl, " elapsed time: %12.6f [sec]\n", elapsed_time);
268 
269  vout.paranoiac(m_vl, " Fratio::force end\n");
270 }
271 
272 
273 //============================================================END=====
Action_F_Ratio_lex_alt::tidyup
void tidyup()
Definition: action_F_Ratio_lex_alt-tmpl.h:24
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Parameters
Class for parameters.
Definition: parameters.h:46
convert
void convert(INDEX &index, AFIELD &v, const Field &w)
Definition: afield-inc.h:129
Field::nex
int nex() const
Definition: field.h:128
RandomNumbers
Base class of random number generators.
Definition: randomNumbers.h:43
Action_F_Ratio_lex_alt::calcH
double calcH()
calculate Hamiltonian of this action term.
Definition: action_F_Ratio_lex_alt-tmpl.h:132
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field::stat
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
Definition: field.cpp:169
reverse_gauge
void reverse_gauge(INDEX &index, Field &v, FIELD &w)
Definition: afield-inc.h:417
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
dot
double dot(const Field &y, const Field &x)
Definition: field.cpp:576
Field::nin
int nin() const
Definition: field.h:126
Timer
Definition: timer.h:31
Bridge::BridgeIO::paranoiac
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:238
Action_F_Ratio_lex_alt::init
void init()
Definition: action_F_Ratio_lex_alt-tmpl.h:16
Timer::start
void start()
Definition: timer.cpp:44
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
Action_F_Ratio_lex_alt::set_parameters
void set_parameters()
Definition: action_F_Ratio_lex_alt-tmpl.h:41
Field::norm
double norm() const
Definition: field.h:226
Action_F_Ratio_lex_alt::force
void force(Field &)
returns force for molcular dynamical update of conjugate momenta.
Definition: action_F_Ratio_lex_alt-tmpl.h:190
Action_F_Ratio_lex_alt
HMC action for Hasenbusch preconditioned fermions.
Definition: action_F_Ratio_lex_alt.h:33
Field::nvol
int nvol() const
Definition: field.h:127
CommonParameters::NPE
static int NPE()
Definition: commonParameters.h:101
Action_F_Ratio_lex_alt::langevin
double langevin(RandomNumbers *)
Langevis step.
Definition: action_F_Ratio_lex_alt-tmpl.h:63
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition: commonParameters.h:122
Parameters::get_VerboseLevel
Bridge::VerboseLevel get_VerboseLevel() const
Definition: parameters.cpp:320
Field
Container of Field-type object.
Definition: field.h:46
RandomNumbers::gauss_lex_global
virtual void gauss_lex_global(Field &)
gaussian random number defined on global lattice.
Definition: randomNumbers.cpp:95
Timer::elapsed_sec
double elapsed_sec() const
Definition: timer.cpp:107
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Action_F_Ratio_lex_alt::set_config
void set_config(Field *U)
setting pointer to the gauge configuration.
Definition: action_F_Ratio_lex_alt-tmpl.h:49
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Timer::stop
void stop()
Definition: timer.cpp:69
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512