CHROMA
t_preccfz.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <cstdio>
4 
5 #include <stdlib.h>
6 #include <sys/time.h>
7 
8 #include "chroma.h"
9 
10 using namespace Chroma;
11 
12 typedef multi1d<LatticeFermion> MLF;
13 typedef multi1d<LatticeColorMatrix> LCM;
14 
15 typedef void (EvenOddPrecLinearOperator< MLF, LCM >::* EO_mem)(MLF&, const MLF&, enum PlusMinus) const;
16 
17 enum func { EE, EO, OE, OO, EEI, TOT };
19  MLF& chi, const MLF& psi,
20  enum PlusMinus isign)
21 {
22  clock_t myt1, myt2;
23  double mydt;
24  int iter = 1;
25  for(iter=1; ; iter <<= 1)
26  {
27  QDPIO::cout << "Applying D " << iter << " times" << std::endl;
28 
29  switch ( which ) {
30  case EE:
31  {
32  myt1=clock();
33  for(int i=iter; i-- > 0; ) {
34  p.evenEvenLinOp(chi, psi, isign);
35  }
36  myt2=clock();
37  }
38  break;
39  case EO:
40  {
41  myt1=clock();
42  for(int i=iter; i-- > 0; ) {
43  p.evenOddLinOp(chi, psi, isign);
44  }
45  myt2=clock();
46  }
47  break;
48 
49  case OE:
50  {
51  myt1=clock();
52  for(int i=iter; i-- > 0; ) {
53  p.oddEvenLinOp(chi, psi, isign);
54  }
55  myt2=clock();
56  }
57  break;
58 
59  case OO:
60  {
61  myt1=clock();
62  for(int i=iter; i-- > 0; ) {
63  p.oddOddLinOp(chi, psi, isign);
64  }
65  myt2=clock();
66  }
67  break;
68 
69  case EEI:
70  {
71  myt1=clock();
72  for(int i=iter; i-- > 0; ) {
73  p.evenEvenInvLinOp(chi, psi, isign);
74  }
75  myt2=clock();
76  }
77  break;
78 
79  case TOT:
80  {
81  myt1=clock();
82  for(int i=iter; i-- > 0; ) {
83  p(chi, psi, isign);
84  }
85  myt2=clock();
86  }
87  break;
88 
89  default:
90  break;
91  }
92 
93  mydt=double(myt2-myt1)/double(CLOCKS_PER_SEC);
94  QDPInternal::globalSum(mydt);
95  mydt /= Layout::numNodes();
96 
97  if (mydt > 1)
98  break;
99  }
100 
101  switch ( which ) {
102  case EE:
103  {
104  myt1=clock();
105  for(int i=iter; i-- > 0; ) {
106  p.evenEvenLinOp(chi, psi, isign);
107  }
108  myt2=clock();
109  }
110  break;
111  case EO:
112  {
113  myt1=clock();
114  for(int i=iter; i-- > 0; ) {
115  p.evenOddLinOp(chi, psi, isign);
116  }
117  myt2=clock();
118  }
119  break;
120 
121  case OE:
122  {
123  myt1=clock();
124  for(int i=iter; i-- > 0; ) {
125  p.oddEvenLinOp(chi, psi, isign);
126  }
127  myt2=clock();
128  }
129  break;
130 
131  case OO:
132  {
133  myt1=clock();
134  for(int i=iter; i-- > 0; ) {
135  p.oddOddLinOp(chi, psi, isign);
136  }
137  myt2=clock();
138  }
139  break;
140 
141  case EEI:
142  {
143  myt1=clock();
144  for(int i=iter; i-- > 0; ) {
145  p.evenEvenInvLinOp(chi, psi, isign);
146  }
147  myt2=clock();
148  }
149  break;
150  case TOT:
151  {
152  myt1=clock();
153  for(int i=iter; i-- > 0; ) {
154  p(chi, psi, isign);
155  }
156  myt2=clock();
157  }
158  break;
159 
160  default:
161  break;
162  }
163 
164  mydt = (double)(myt2-myt1)/((double)(CLOCKS_PER_SEC));
165  mydt *= 1.0e6/((double)(iter*(Layout::sitesOnNode()/2)));
166  QDPInternal::globalSum(mydt);
167  mydt /= Layout::numNodes();
168  return mydt;
169 }
170 
171 
172 int main(int argc, char **argv)
173 {
174  // Put the machine into a known state
175  Chroma::initialize(&argc, &argv);
176 
177  // Setup the layout
178  const int foo[] = {8,8,16,16};
179  multi1d<int> nrow(Nd);
180  nrow = foo; // Use only Nd elements
181  Layout::setLattSize(nrow);
182  Layout::create();
183 
184  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
185 
186  //! Test out dslash
187  multi1d<LatticeColorMatrix> u(Nd);
188  for(int m=0; m < u.size(); ++m)
189  gaussian(u[m]);
190 
191  //! Create a linear operator
192  QDPIO::cout << "Constructing CFZ Op" << std::endl;
193 
194  // Create a FermBC with only periodic BC. Note the handle is on an abstract type.
196 
197  // DWDslash class can be optimised
198 
200  p.Mass =Real(0.06);
201  p.RatPolyDeg=6;
202  p.approximation_type=COEFF_TYPE_ZOLOTAREV;
203  p.OverMass = Real(1.4);
204  p.ApproxMin = 0.66;
205  p.ApproxMax = 6.4635;
206 
208 
210  const EvenOddPrecLinearOperator< MLF, LCM >* D_pdwf = S_pdwf.linOp(state);
211  const EvenOddPrecLinearOperator< MLF, LCM >* D_pv = S_pdwf.linOpPV(state);
212 
213  QDPIO::cout << "Done" << std::endl;
214 
215  MLF psi(S_pdwf.size()), chi(S_pdwf.size());
216  for(int n=0; n < S_pdwf.size(); ++n)
217  random(psi[n]);
218  chi = zero;
219  int N5 = S_pdwf.size();
220 
221  for(int isign = 1; isign >= -1; isign -= 2)
222  {
223  QDPIO::cout << "Applying D" << std::endl;
224  QDPIO::cout << " isign = " << isign << std::endl;
225 
226  PlusMinus is = (isign == 1 ? PLUS : MINUS);
227  clock_t myt1;
228  clock_t myt2;
229  double mydt;
230 
231  int Ndiag = (10*N5-8)*Nc*Ns;
232  int NdiagInv = (10*N5-8)*Nc*Ns;
233  int Neo = (N5-1)*(1320 + 2*Nc*Ns);
234  int Nflops = 2*Ndiag + 2*Neo + NdiagInv;
235 
236 
237  // even-even-inv piece
238  mydt = time_func(*D_pdwf, EEI, chi, psi, is);
239  QDPIO::cout << "EvenEvenInv: The time per lattice point is "<< mydt << " micro sec"
240  << " (" << ((double)(NdiagInv)/mydt) << ") Mflops " << std::endl;
241 
242  mydt = time_func(*D_pdwf, EE, chi, psi, is);
243  QDPIO::cout << "EvenEven: The time per lattice point is "<< mydt << " micro sec"
244  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
245 
246  // odd-odd piece
247  mydt = time_func(*D_pdwf, OO, chi, psi, is);
248  QDPIO::cout << "OddOdd: The time per lattice point is "<< mydt << " micro sec"
249  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
250 
251  // even-odd
252  mydt = time_func(*D_pdwf, EO, chi, psi, is);
253  QDPIO::cout << "EvenOdd: The time per lattice point is "<< mydt << " micro sec"
254  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
255  // odd-even
256  mydt = time_func(*D_pdwf, OE, chi, psi, is);
257  QDPIO::cout << "Odd-Even: The time per lattice point is "<< mydt << " micro sec"
258  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
259 
260  // Total thing
261  mydt = time_func(*D_pdwf, TOT, chi, psi, is);
262  QDPIO::cout << "Total: The time per lattice point is "<< mydt << " micro sec"
263  << " (" << ((double)(Nflops)/mydt) << ") Mflops " << std::endl;
264  }
265 
266  for(int n=0; n < S_pdwf.size(); ++n)
267  random(psi[n]);
268  chi = zero;
269  N5 = S_pdwf.size();
270 
271  for(int isign = 1; isign >= -1; isign -= 2)
272  {
273  QDPIO::cout << "Applying D" << std::endl;
274  QDPIO::cout << " isign = " << isign << std::endl;
275 
276  PlusMinus is = (isign == 1 ? PLUS : MINUS);
277  clock_t myt1;
278  clock_t myt2;
279  double mydt;
280 
281  int Ndiag = (10*N5-18)*Nc*Ns;
282  int NdiagInv = (10*N5-18)*Nc*Ns;
283  int Neo = (N5-2)*(1320 + 2*Nc*Ns);
284  int Nflops = 2*Ndiag + 2*Neo + NdiagInv;
285 
286  // even-even-inv piece
287  mydt = time_func(*D_pv, EEI, chi, psi, is);
288  QDPIO::cout << "EvenEvenInvPV: The time per lattice point is "<< mydt << " micro sec"
289  << " (" << ((double)(NdiagInv)/mydt) << ") Mflops " << std::endl;
290 
291  mydt = time_func(*D_pv, EE, chi, psi, is);
292  QDPIO::cout << "EvenEvenPV: The time per lattice point is "<< mydt << " micro sec"
293  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
294 
295  // odd-odd piece
296  mydt = time_func(*D_pv, OO, chi, psi, is);
297  QDPIO::cout << "OddOddPV: The time per lattice point is "<< mydt << " micro sec"
298  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
299 
300  // even-odd
301  mydt = time_func(*D_pv, EO, chi, psi, is);
302  QDPIO::cout << "EvenOddPV: The time per lattice point is "<< mydt << " micro sec"
303  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
304  // odd-even
305  mydt = time_func(*D_pv, OE, chi, psi, (isign == 1 ? PLUS : MINUS));
306  QDPIO::cout << "Odd-EvenPV: The time per lattice point is "<< mydt << " micro sec"
307  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
308 
309  // Total thing
310  mydt = time_func(*D_pv, TOT, chi, psi, is);
311  QDPIO::cout << "TotalPV: The time per lattice point is "<< mydt << " micro sec"
312  << " (" << ((double)(Nflops)/mydt) << ") Mflops " << std::endl;
313  }
314 
315  delete D_pdwf;
316  delete D_pv;
317  // Time to bolt
319 
320  exit(0);
321 }
Primary include file for CHROMA in application codes.
Even-odd preconditioned linear operator.
Definition: eoprec_linop.h:92
5D continued fraction overlap action (Borici,Wenger, Edwards)
EvenOddPrecConstDetLinearOperatorArray< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Produce a linear operator for this action.
EvenOddPrecConstDetLinearOperatorArray< T, P, Q > * linOpPV(Handle< FermState< T, P, Q > > state) const
Produce a Pauli-Villars linear operator for this action.
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
Concrete class for all fermionic actions with trivial boundary conditions.
@ COEFF_TYPE_ZOLOTAREV
unsigned n
Definition: ldumul_w.cc:36
static int m[4]
Definition: make_seeds.cc:16
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
static multi1d< LatticeColorMatrix > u
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
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
multi1d< LatticeColorMatrix > LCM
Definition: asqtad_qprop.cc:20
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
Double zero
Definition: invbicg.cc:106
multi1d< LatticeFermion > MLF
Definition: t_preccfz.cc:12
func
Definition: t_preccfz.cc:17
@ OE
Definition: t_preccfz.cc:17
@ OO
Definition: t_preccfz.cc:17
@ TOT
Definition: t_preccfz.cc:17
@ EEI
Definition: t_preccfz.cc:17
@ EO
Definition: t_preccfz.cc:17
@ EE
Definition: t_preccfz.cc:17
int main(int argc, char **argv)
Definition: t_preccfz.cc:172
double time_func(const EvenOddPrecLinearOperator< MLF, LCM > &p, func which, MLF &chi, const MLF &psi, enum PlusMinus isign)
Definition: t_preccfz.cc:18
void(EvenOddPrecLinearOperator< MLF, LCM >::* EO_mem)(MLF &, const MLF &, enum PlusMinus) const
Definition: t_preccfz.cc:15