CHROMA
t_clover.cc
Go to the documentation of this file.
1 // t_su3.cc, 2004/11/16 velytsky
2 // velytski@csit.fsu.edu
3 // gluodynamics (su(3)) heatbath updating with measurements
4 #include <iostream>
5 #include <cstdio>
6 #include <cmath>
7 #include "chroma.h"
8 
9 using namespace Chroma;
10 
11 typedef LatticeFermion T;
12 typedef multi1d<LatticeColorMatrix> Q;
13 typedef multi1d<LatticeColorMatrix> P;
14 
15 
16 int main(int argc, char *argv[])
17 {
18  // Put the machine into a known state
19  Chroma::initialize(&argc, &argv);
20 
21  // Setup the layout
22  const int foo[]={4, 4, 4, 4};
23  multi1d<int> nrow(Nd);
24  nrow=foo;
25  Layout::setLattSize(nrow);
26  Layout::create();
27 
28  // Start up a weak field
29  struct Cfg_t config = { CFG_TYPE_WEAK_FIELD, "dummy" };
30  multi1d<LatticeColorMatrix> u(Nd);
31  XMLReader gauge_file_xml, gauge_xml;
32  gaugeStartup(gauge_file_xml, gauge_xml, u, config);
33  // Check if the gauge field configuration is unitarized
35 
36  // Need a ferm state
38 
39  // Need some clover params
41  params.clovCoeffR = Real(1.92);
42  params.clovCoeffT = Real(0.57);
43  params.Mass=Real(0);
44 
45  // Need a clover operator - reference
46  QDPCloverTerm qdp_clov;
47  qdp_clov.create(fs, params);
48 
49 
50 
51  LatticeFermion src, dest1, dest2;
52  gaussian(src);
53  dest1=zero;
54  dest2=zero;
55 
56  int n_sec=30;
57  unsigned long iters=1;
58  double time;
59 
60  QDPIO::cout << "Calibrating QDPCloverTerm" << std::endl;
61  do {
62  iters *= 2;
63  StopWatch swatch;
64  swatch.reset();
65  swatch.start();
66  for(unsigned long i=0; i < iters; i++) {
67  qdp_clov.apply(dest1, src, PLUS, 0);
68  }
69  swatch.stop();
70  time=swatch.getTimeInSeconds();
71  QDPInternal::globalSum(time);
72  time /= (double)Layout::numNodes();
73  QDPIO::cout << "." << std::flush;
74  }
75  while(time < (double)n_sec );
76 
77 
78  QDPIO::cout << std::endl;
79 
80  {
81  QDPIO::cout << "Timing with " << iters << " iterations" << std::endl;
82  StopWatch swatch;
83  swatch.reset();
84  swatch.start();
85  for(unsigned long i=0; i < iters; i++) {
86  qdp_clov.apply(dest1, src, PLUS, 0);
87  }
88  swatch.stop();
89  time=swatch.getTimeInSeconds();
90  QDPInternal::globalSum(time);
91  time /= (double)Layout::numNodes();
92 
93  // Flopcount
94  QDPIO::cout << "Layout volume=" << Layout::vol() << std::endl;
95  QDPIO::cout << "FLOPS=" << qdp_clov.nFlops() << std::endl;
96  QDPIO::cout << "iters=" << iters <<std::endl;
97  QDPIO::cout << "time=" << time << std::endl;
98  double flops=(double)qdp_clov.nFlops();
99  flops *= (double)(Layout::sitesOnNode())/(double)2;
100  flops *= (double)(iters);
101  FlopCounter fc;
102  fc.addFlops((unsigned long long)floor(flops));
103  fc.report("QDPCloverTerm", time);
104 
105  }
106 
107  CloverTerm opt_clov;
108  opt_clov.create(fs, params);
109 
110  iters = 1;
111  QDPIO::cout << "Calibrating CloverTerm" << std::endl;
112  do {
113  iters *= 2;
114  StopWatch swatch;
115  swatch.reset();
116  swatch.start();
117  for(unsigned long i=0; i < iters; i++) {
118  opt_clov.apply(dest1, src, PLUS, 0);
119  }
120  swatch.stop();
121  time=swatch.getTimeInSeconds();
122  QDPInternal::globalSum(time);
123  time /= (double)Layout::numNodes();
124  QDPIO::cout << "." << std::flush;
125  }
126  while(time < (double)n_sec );
127 
128 
129  QDPIO::cout << std::endl;
130 
131  {
132  QDPIO::cout << "Timing with " << iters << " iterations" << std::endl;
133  StopWatch swatch;
134  swatch.reset();
135  swatch.start();
136  for(unsigned long i=0; i < iters; i++) {
137  opt_clov.apply(dest1, src, PLUS, 0);
138  }
139  swatch.stop();
140  time=swatch.getTimeInSeconds();
141  QDPInternal::globalSum(time);
142  time /= (double)Layout::numNodes();
143 
144  // Flopcount
145  QDPIO::cout << "Layout volume=" << Layout::vol() << std::endl;
146  QDPIO::cout << "FLOPS=" << qdp_clov.nFlops() << std::endl;
147  QDPIO::cout << "iters=" << iters <<std::endl;
148  QDPIO::cout << "time=" << time << std::endl;
149  double flops=(double)qdp_clov.nFlops();
150  flops *= (double)(Layout::sitesOnNode())/(double)2;
151  flops *= (double)(iters);
152  FlopCounter fc;
153  fc.addFlops((unsigned long long)floor(flops));
154  fc.report("CloverTerm", time);
155 
156  }
157 
158 
159 
160 
161  iters=1;
163  D.create(fs, params);
164 
165  QDPIO::cout << "Calibrating Possibly optimized EOPREC Clov Op" << std::endl;
166  do {
167  iters *= 2;
168  StopWatch swatch;
169  swatch.reset();
170  swatch.start();
171  for(int i=0; i < iters; i++) {
172  D(dest1, src, PLUS);
173  D(dest1, src, MINUS);
174  }
175  swatch.stop();
176  time=swatch.getTimeInSeconds();
177  QDPInternal::globalSum(time);
178  time /= (double)Layout::numNodes();
179  QDPIO::cout << "." << std::flush;
180  }
181  while(time < (double)n_sec );
182  QDPIO::cout << std::endl;
183 
184  {
185  QDPIO::cout << "Timing with " << iters << " iterations" << std::endl;
186  StopWatch swatch;
187  swatch.reset();
188  swatch.start();
189  for(int i=0; i < iters; i++) {
190  D(dest1, src, PLUS);
191  D(dest1, src, MINUS);
192  }
193  swatch.stop();
194  time=swatch.getTimeInSeconds();
195  QDPInternal::globalSum(time);
196  time /= (double)Layout::numNodes();
197 
198  FlopCounter fc;
199  fc.reset();
200  unsigned long long flops = (unsigned long long)2;
201  flops *= (unsigned long long)iters;
202  flops *= (unsigned long long)D.nFlops();
203 
204  fc.addFlops(flops);
205  fc.report("EOPrecCloverOp", time);
206  }
207 
208 
209 
211  return 1;
212 }
Primary include file for CHROMA in application codes.
unsigned long nFlops() const
Return flops performed by the operator()
Even-odd preconditioned Clover-Dirac operator.
unsigned long nFlops() const
Return flops performed by the operator()
void create(Handle< FermState< T, P, Q > > fs, const CloverFermActParams &param_)
Creation routine.
Class for counted reference semantics.
Definition: handle.h:33
Periodic version of FermState.
void create(Handle< FermState< T, multi1d< U >, multi1d< U > > > fs, const CloverFermActParams &param_)
Creation routine.
void apply(T &chi, const T &psi, enum PlusMinus isign, int cb) const
void unitarityCheck(const multi1d< LatticeColorMatrixF3 > &u)
Check the unitarity of color matrix in SU(N)
Definition: unit_check.cc:20
void gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
@ CFG_TYPE_WEAK_FIELD
Params params
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
Double zero
Definition: invbicg.cc:106
Gauge configuration structure.
Definition: cfgtype_io.h:16
Params for clover ferm acts.
int main(int argc, char *argv[])
Definition: t_clover.cc:16
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13