CHROMA
t_invrelcg.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <sstream>
4 #include <iomanip>
5 #include <string>
6 
7 #include <cstdio>
8 
9 #include <stdlib.h>
10 #include <sys/time.h>
11 #include <math.h>
12 
13 #include "chroma.h"
15 
16 using namespace Chroma;
17 
18 struct App_input_t {
19  ChromaProp_t param;
20  Cfg_t cfg;
21 };
22 
23 // Reader for input parameters
24 void read(XMLReader& xml, const std::string& path, App_input_t& input)
25 {
26  XMLReader inputtop(xml, path);
27 
28  // Read the input
29  try
30  {
31  // The parameters holds the version number
32  read(inputtop, "Param", input.param);
33 
34  // Read in the gauge configuration info
35  read(inputtop, "Cfg", input.cfg);
36  }
37  catch (const std::string& e)
38  {
39  QDPIO::cerr << "Error reading data: " << e << std::endl;
40  throw;
41  }
42 }
43 
44 
45 int main(int argc, char **argv)
46 {
47  // Put the machine into a known state
48  Chroma::initialize(&argc, &argv);
49 
50 
51 
52  App_input_t input;
53  XMLReader xml_in(Chroma::getXMLInputFileName());
54 
55  try {
56  read(xml_in, "/ovlapTest", input);
57  }
58  catch( const std::string& e) {
59  QDPIO::cerr << "Caught Exception : " << e << std::endl;
60  QDP_abort(1);
61  }
62 
63 
64  // Setup the lattice
65  Layout::setLattSize(input.param.nrow);
66  Layout::create();
67 
68  multi1d<LatticeColorMatrix> u(Nd);
69  XMLReader gauge_file_xml, gauge_xml;
70  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
71 
72  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
73  push(xml_out,"t_msumr");
74 
75 
76  // Measure the plaquette on the gauge
77  MesPlq(xml_out, "Observables", u);
78  xml_out.flush();
79 
80  // Create a FermBC
82 
83 
84  const Zolotarev4DFermActParams& zolo4d = dynamic_cast<const Zolotarev4DFermActParams& > (*(input.param.FermActHandle));
85 
86  // Construct Fermact -- now uses constructor from the zolo4d params
87  // struct
88  Zolotarev4DFermAct S(fbc, zolo4d, xml_out);
89 
90  Handle<const ConnectState> connect_state(S.createState(u, zolo4d.StateInfo, xml_out,zolo4d.AuxFermActHandle->getMass()));
91 
92  Handle<const ApproxLinearOperator<LatticeFermion> > M( dynamic_cast<const ApproxLinearOperator<LatticeFermion>* >( S.linOp(connect_state) ) );
93 
94  Handle<const ApproxLinearOperator<LatticeFermion> > MM( dynamic_cast<const ApproxLinearOperator<LatticeFermion>* >( S.lMdagM(connect_state) ) );
95 
96 
97 
98  LatticeFermion chi;
99  LatticeFermion psi;
100 
101 
102  int n_count;
103 
104  // Solve on chiral point source
105  multi1d<int> coord(4);
106  coord[0] = 0;
107  coord[1] = 0;
108  coord[2] = 0;
109  coord[3] = 0;
110  QDP::StopWatch swatch;
111  double t;
112 
113  chi=zero;
114  srcfil(chi, coord, 0, 0);
115 
116 
117  psi = zero;
118  swatch.reset();
119  swatch.start();
120 
121  S.qprop(psi,
122  connect_state,
123  chi,
124  CG_INVERTER,
125  input.param.invParam.RsdCG,
126  input.param.invParam.MaxCG,
127  n_count);
128 
129  swatch.stop();
130  t = swatch.getTimeInSeconds();
131 
132  QDPIO::cout << "Qprop with CG on Point source: " << n_count
133  << " iters " << std::endl;
134 
135  QDPIO::cout << "Wall Clock Time (CG, Point) = " << t << " seconds" << std::endl;
136 
137  push(xml_out, "CGPoint");
138  write(xml_out, "n_count", n_count);
139  write(xml_out, "t" , t);
140  pop(xml_out);
141 
142 
143  psi = zero;
144  swatch.reset();
145  swatch.start();
146 
147  S.qprop(psi,
148  connect_state,
149  chi,
150  REL_CG_INVERTER,
151  input.param.invParam.RsdCG,
152  input.param.invParam.MaxCG,
153  n_count);
154 
155  swatch.stop();
156  t = swatch.getTimeInSeconds();
157 
158  QDPIO::cout << "Qprop with RelCG on Point source: " << n_count
159  << " iters " << std::endl;
160 
161  QDPIO::cout << "Wall Clock Time (RelCG, Point) = " << t << " seconds" << std::endl;
162 
163  push(xml_out, "CGRelPoint");
164  write(xml_out, "n_count", n_count);
165  write(xml_out, "t" , t);
166  pop(xml_out);
167 
168 
169  gaussian(chi);
170  chi /= sqrt(norm2(chi));
171 
172  psi = zero;
173  swatch.reset();
174  swatch.start();
175 
176  S.qprop(psi,
177  connect_state,
178  chi,
179  CG_INVERTER,
180  input.param.invParam.RsdCG,
181  input.param.invParam.MaxCG,
182  n_count);
183 
184  swatch.stop();
185  t = swatch.getTimeInSeconds();
186 
187  QDPIO::cout << "Qprop with CG on Gaussian source: " << n_count
188  << " iters " << std::endl;
189 
190  QDPIO::cout << "Wall Clock Time (CG, Gauss) = " << t << " seconds" << std::endl;
191 
192  push(xml_out, "CGGaussian");
193  write(xml_out, "n_count", n_count);
194  write(xml_out, "t" , t);
195  pop(xml_out);
196 
197 
198  psi = zero;
199  swatch.reset();
200  swatch.start();
201 
202  S.qprop(psi,
203  connect_state,
204  chi,
205  REL_CG_INVERTER,
206  input.param.invParam.RsdCG,
207  input.param.invParam.MaxCG,
208  n_count);
209 
210  swatch.stop();
211  t = swatch.getTimeInSeconds();
212 
213  QDPIO::cout << "Qprop with RelCG on Gaussian source: " << n_count
214  << " iters " << std::endl;
215 
216  QDPIO::cout << "Wall Clock Time (RelCG, Point) = " << t << " seconds" << std::endl;
217 
218  push(xml_out, "CGRelGauss");
219  write(xml_out, "n_count", n_count);
220  write(xml_out, "t" , t);
221  pop(xml_out);
222 
223 
224 
225  pop(xml_out);
227 
228  exit(0);
229 }
Primary include file for CHROMA in application codes.
Class for counted reference semantics.
Definition: handle.h:33
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void gaugeStartup(XMLReader &gauge_file_xml, XMLReader &gauge_xml, multi1d< LatticeColorMatrix > &u, Cfg_t &cfg)
Initialize the gauge fields.
void srcfil(LatticeFermion &a, const multi1d< int > &coord, int color_index, int spin_index)
Fill a specific color and spin index with 1.0.
Definition: srcfil.cc:23
multi1d< int > coord(Nd)
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
Conjugate-Gradient algorithm for a generic Linear Operator.
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)
std::string getXMLInputFileName()
Get input file name.
Definition: chroma_init.cc:88
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
XMLFileWriter & getXMLOutputInstance()
Get xml output instance.
Definition: chroma_init.cc:359
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
ChromaProp_t param
Definition: t_bicgstab.cc:19
Gauge configuration structure.
Definition: cfgtype_io.h:16
Propagator parameters.
Definition: qprop_io.h:75
GroupXML_t invParam
Definition: qprop_io.h:84
int main(int argc, char **argv)
Definition: t_invrelcg.cc:45