CHROMA
t_precnef.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 
19  MLF& chi, const MLF& psi,
20  enum PlusMinus isign)
21 {
22  clock_t myt1, myt2;
23  double mydt;
24  int iter = 1;
25 
26  for(iter=1; ; iter <<= 1)
27  {
28  QDPIO::cout << "Applying D " << iter << " times" << std::endl;
29 
30  myt1=clock();
31  for(int i=iter; i-- > 0; )
32  (p->*A)(chi, psi, isign);
33  myt2=clock();
34 
35  mydt=double(myt2-myt1)/double(CLOCKS_PER_SEC);
36  QDPInternal::globalSum(mydt);
37  mydt /= Layout::numNodes();
38 
39  if (mydt > 1)
40  break;
41  }
42 
43  myt1=clock();
44  for(int i=iter; i-- > 0; )
45  (p->*A)(chi, psi, isign);
46  myt2=clock();
47 
48  mydt = (double)(myt2-myt1)/((double)(CLOCKS_PER_SEC));
49  mydt *= 1.0e6/((double)(iter*(Layout::sitesOnNode()/2)));
50  QDPInternal::globalSum(mydt);
51  mydt /= Layout::numNodes();
52  return mydt;
53 }
54 
55 
56 int main(int argc, char **argv)
57 {
58  // Put the machine into a known state
59  Chroma::initialize(&argc, &argv);
60 
61  // Setup the layout
62  const int foo[] = {4,4,4,8};
63  multi1d<int> nrow(Nd);
64  nrow = foo; // Use only Nd elements
65  Layout::setLattSize(nrow);
66  Layout::create();
67 
68  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
69 
70  //! Test out dslash
71  multi1d<LatticeColorMatrix> u(Nd);
72  for(int m=0; m < u.size(); ++m)
73  gaussian(u[m]);
74 
75  //! Create a linear operator
76  QDPIO::cout << "Constructing DWDslash" << std::endl;
77 
78  // Create a FermBC with only periodic BC. Note the handle is on an abstract type.
80 
81  // DWDslash class can be optimised
82  int N5 = 8;
83  Real WilsonMass = 1.5;
84  Real m_q = 0.01;
85 
86  Real b5=Real(1);
87  Real c5=Real(0);
89  p.OverMass = WilsonMass;
90  p.b5 = b5;
91  p.c5 = c5;
92  p.Mass = m_q;
93  p.N5=N5;
94 
95  EvenOddPrecNEFFermActArray S_pdwf(fbc_a,p);
96 
98  const EvenOddPrecLinearOperator< MLF, LCM >* D_pdwf = S_pdwf.linOp(state);
99 
100  QDPIO::cout << "Done" << std::endl;
101 
102  MLF psi(S_pdwf.size()), chi(S_pdwf.size());
103  for(int n=0; n < S_pdwf.size(); ++n)
104  random(psi[n]);
105  chi = zero;
106 
107  for(int isign = 1; isign >= -1; isign -= 2)
108  {
109  QDPIO::cout << "Applying D" << std::endl;
110  QDPIO::cout << " isign = " << isign << std::endl;
111 
112  PlusMinus is = (isign == 1 ? PLUS : MINUS);
113  clock_t myt1;
114  clock_t myt2;
115  double mydt;
116 
117  int Ndiag = 6*N5*Nc*Ns; // This is my count with the blas / chiral proj ops
118  int NdiagInv = (10*N5-8)*Nc*Ns;
119  int Neo = 6*N5*Nc*Ns + N5*(1320+24);
120  int Nflops = 2*Ndiag + 2*Neo + N5*24;
121 
122  // even-even-inv piece
124  QDPIO::cout << "EvenEvenInv: The time per lattice point is "<< mydt << " micro sec"
125  << " (" << ((double)(NdiagInv)/mydt) << ") Mflops " << std::endl;
126 
128  QDPIO::cout << "EvenEven: The time per lattice point is "<< mydt << " micro sec"
129  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
130 
131  // odd-odd piece
133  QDPIO::cout << "OddOdd: The time per lattice point is "<< mydt << " micro sec"
134  << " (" << ((double)(Ndiag)/mydt) << ") Mflops " << std::endl;
135 
136  // even-odd
138  QDPIO::cout << "EvenOdd: The time per lattice point is "<< mydt << " micro sec"
139  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
140  // odd-even
142  QDPIO::cout << "Odd-Even: The time per lattice point is "<< mydt << " micro sec"
143  << " (" << ((double)(Neo)/mydt) << ") Mflops " << std::endl;
144 
145  // Total thing
147  QDPIO::cout << "Total: The time per lattice point is "<< mydt << " micro sec"
148  << " (" << ((double)(Nflops)/mydt) << ") Mflops " << std::endl;
149  }
150 
151  delete D_pdwf;
152 
153  // Time to bolt
155 
156  exit(0);
157 }
Primary include file for CHROMA in application codes.
virtual EvenOddPrecDWLikeLinOpBaseArray< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Override to produce a DWF-link even-odd prec. linear operator for this action.
Even-odd preconditioned linear operator.
Definition: eoprec_linop.h:92
4D style even-odd preconditioned domain-wall fermion action
int size() const
Length of DW flavor index/space.
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.
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
A(A, psi, r, Ncb, PLUS)
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
multi1d< LatticeFermion > MLF
Definition: t_precnef.cc:12
int main(int argc, char **argv)
Definition: t_precnef.cc:56
double time_func(const EvenOddPrecLinearOperator< MLF, LCM > *p, EO_mem A, MLF &chi, const MLF &psi, enum PlusMinus isign)
Definition: t_precnef.cc:18
void(EvenOddPrecLinearOperator< MLF, LCM >::* EO_mem)(MLF &, const MLF &, enum PlusMinus) const
Definition: t_precnef.cc:15