CHROMA
t_precact_sse.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <cstdio>
4 
5 #include "chroma.h"
6 // #include "actions/ferm/qprop/prec_dwf_qprop_array_sse_w.h"
7 
8 #include "qdp_util.h"
9 
10 using namespace Chroma;
11 using namespace Chroma;
12 
13 
14 int main(int argc, char **argv)
15 {
16  // Put the machine into a known state
17  Chroma::initialize(&argc, &argv);
18 
19  // Setup the layout
20  const int foo[] = {4,2,2,2};
21  multi1d<int> nrow(Nd);
22  nrow = foo; // Use only Nd elements
23  Layout::setLattSize(nrow);
24  Layout::create();
25 
26  XMLFileWriter xml("t_precact.xml");
27  push(xml, "t_precact");
28 
29  // Init the gauge field
30  multi1d<LatticeColorMatrix> u(Nd);
31  HotSt(u);
32 // u = 1.0;
33 // XMLReader gauge_xml;
34 // readSzin(gauge_xml, u, "test_purgaug.cfg1");
35 
36  SysSolverCGParams invParam;
37  invParam.RsdCG = 1.0e-6;
38  invParam.MaxCG = 3000;
39  int n_count = 0;
40 
41  GroupXML_t inv_param;
42  {
43  XMLBufferWriter xml_buf;
44  write(xml_buf, "InvertParam", invParam);
45  XMLReader xml_in(xml_buf);
46  inv_param = readXMLGroup(xml_in, "/InvertParam", "invType");
47  }
48 
49  // Create the BC objects
50  const int bnd[] = {1,1,1,-1};
51  multi1d<int> boundary(Nd);
52  boundary = bnd;
53 
54  // Create a fermion BC. Note, the handle is on an ABSTRACT type
55  Handle< FermBC<multi1d<LatticeFermion> > > fbc(new SimpleFermBC<multi1d<LatticeFermion> >(boundary));
56 
57  // The standard DWF fermact
58  Real WilsonMass = 1.1;
59  int N5 = 8;
60  Real m_q = 0.3;
61  EvenOddPrecDWFermActArray S_pdwf(fbc,WilsonMass,m_q,N5);
63 
64  {
65  // Setup solvers
66 // Handle< const SystemSolver< multi1d<LatticeFermion> > > qpropT(S_pdwf.qpropT(state,inv_param));
67  Handle< const SystemSolver< multi1d<LatticeFermion> > > QDPqpropT(new PrecFermAct5DQprop<LatticeFermion, multi1d<LatticeColorMatrix> >(Handle< const EvenOddPrecLinearOperator<multi1d<LatticeFermion>, multi1d<LatticeColorMatrix> > >(S_pdwf.linOp(state)), inv_param));
68 
69  Handle< const SystemSolver< multi1d<LatticeFermion> > > SSEqpropT(new SSEDWFQpropT(state,WilsonMass,m_q,N5,inv_param));
70 
71  // Try the qpropT
72  multi1d<LatticeFermion> psi5a(N5), psi5b(N5), chi5(N5), tmp1(N5);
73  for(int m=0; m < N5; ++m)
74  {
75  gaussian(chi5[m]);
76  random(psi5a[m]);
77  }
78  psi5b = psi5a;
79 
80  QDPIO::cout << "Prec inverter: " << std::endl;
81  QDPIO::cout << " iterations = " << (*QDPqpropT)(psi5a, chi5) << std::endl;
82  QDPIO::cout << "SSE prec inverter" << std::endl;
83  QDPIO::cout << " iterations = " << (*SSEqpropT)(psi5b, chi5) << std::endl;
84 
85  for(int m=0; m < N5; ++m)
86  tmp1[m] = psi5a[m] - psi5b[m];
87 
88  QDPIO::cout << "Test eo-prec and SSE opt eo-prec DWF qpropT" << std::endl
89  << "|pDWF|^2 = " << norm2(psi5a) << std::endl
90  << "|sDWF|^2 = " << norm2(psi5b) << std::endl
91  << "|pDWF - sDWF|^2 = " << norm2(tmp1) << std::endl;
92  }
93 
94  {
95  // Setup solvers
96  Handle< const SystemSolver< LatticeFermion > > qprop(S_pdwf.qprop(state,inv_param));
97 
98  // Try the qprop
99  LatticeFermion chi, psia, psib;
100  gaussian(chi);
101  random(psia);
102  psib = psia;
103 
104  QDPIO::cout << "Prec inverter" << std::endl;
105  QDPIO::cout << " iterations = " << (*qprop)(psia, chi) << std::endl;
106  QDPIO::cout << "SSE prec inverter" << std::endl;
107  QDPIO::cout << " iterations = " << (*qprop)(psib, chi) << std::endl;
108 
109  QDPIO::cout << "Test eo-prec and SSE opt eo-prec DWF qprop" << std::endl
110  << "|pDWF|^2 = " << norm2(psia) << std::endl
111  << "|sDWF|^2 = " << norm2(psib) << std::endl
112  << "|pDWF - sDWF|^2 = " << norm2(psia-psib) << std::endl;
113  }
114 
115  QDPIO::cout << "\n\n\nDone" << std::endl;
116 
117  pop(xml);
118 
119  // Time to bolt
121 
122  exit(0);
123 }
Primary include file for CHROMA in application codes.
4D style even-odd preconditioned domain-wall fermion action
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.
SystemSolver< T > * qprop(Handle< FermState< T, P, Q > > state, const GroupXML_t &invParam) const
Define quark propagator routine for 4D fermions.
Even-odd preconditioned linear operator.
Definition: eoprec_linop.h:92
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
Propagator of a generic even-odd preconditioned 5D fermion linear operator.
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void HotSt(multi1d< LatticeColorMatrix > &u)
Set a gauge field from a sample of (almost) Haar measure.
Definition: hotst.cc:34
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
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 n_count
Definition: invbicg.cc:78
push(xml_out,"Condensates")
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
multi1d< LatticeFermion > chi(Ncb)
pop(xml_out)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
Hold group xml and type id.
Params for CG inverter.
int main(int argc, char **argv)