CHROMA
t_rel_gmresr.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"
14 
15 using namespace Chroma;
16 
17 struct App_input_t {
18  ChromaProp_t param;
19  Cfg_t cfg;
20 };
21 
22 // Reader for input parameters
23 void read(XMLReader& xml, const std::string& path, App_input_t& input)
24 {
25  XMLReader inputtop(xml, path);
26 
27  // Read the input
28  try
29  {
30  // The parameters holds the version number
31  read(inputtop, "Param", input.param);
32 
33  // Read in the gauge configuration info
34  read(inputtop, "Cfg", input.cfg);
35  }
36  catch (const std::string& e)
37  {
38  QDPIO::cerr << "Error reading data: " << e << std::endl;
39  throw;
40  }
41 }
42 
43 
44 int main(int argc, char **argv)
45 {
46  // Put the machine into a known state
47  Chroma::initialize(&argc, &argv);
48 
49 
50 
51  App_input_t input;
52  XMLReader xml_in(Chroma::getXMLInputFileName());
53 
54  try {
55  read(xml_in, "/ovlapTest", input);
56  }
57  catch( const std::string& e) {
58  QDPIO::cerr << "Caught Exception : " << e << std::endl;
59  QDP_abort(1);
60  }
61 
62 
63  // Setup the lattice
64  Layout::setLattSize(input.param.nrow);
65  Layout::create();
66 
67  multi1d<LatticeColorMatrix> u(Nd);
68  XMLReader gauge_file_xml, gauge_xml;
69  gaugeStartup(gauge_file_xml, gauge_xml, u, input.cfg);
70 
71  XMLFileWriter& xml_out = Chroma::getXMLOutputInstance();
72  push(xml_out,"t_rel_gmresr");
73 
74 
75  // Measure the plaquette on the gauge
76  MesPlq(xml_out, "Observables", u);
77  xml_out.flush();
78 
79  // Create a FermBC
81 
82 
83  QDPIO::cout << "FERM_ACT_ZOLOTAREV_4D" << std::endl;
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 
93  int G5 = Ns*Ns - 1;
94  LatticeFermion psi,chi;
95  int n_count;
96 
97 
98  // Solve on chiral point source
99  multi1d<int> coord(4);
100  coord[0] = 0;
101  coord[1] = 0;
102  coord[2] = 0;
103  coord[3] = 0;
104  QDP::StopWatch swatch;
105 
106  chi=zero;
107  srcfil(chi, coord, 0, 0);
108  double t;
109 
110 
111  psi = zero;
112  swatch.reset();
113  swatch.start();
114  S.qprop(psi,
115  connect_state,
116  chi,
117  REL_GMRESR_SUMR_INVERTER,
118  input.param.invParam.RsdCG,
119  input.param.invParam.RsdCGPrec,
120  input.param.invParam.MaxCG,
121  input.param.invParam.MaxCGPrec,
122  n_count);
123 
124  swatch.stop();
125 
126 
127  t = swatch.getTimeInSeconds();
128 
129  QDPIO::cout << "GMRESRSUMR on point source took: " << n_count << " iterations" << std::endl;
130  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
131  push(xml_out, "GMRESRSUMRPointSource");
132  write(xml_out, "n_count", n_count);
133  write(xml_out, "t", t);
134  pop(xml_out);
135 
136  psi = zero;
137  swatch.reset();
138  swatch.start();
139  S.qprop(psi,
140  connect_state,
141  chi,
142  REL_GMRESR_CG_INVERTER,
143  input.param.invParam.RsdCG,
144  input.param.invParam.RsdCGPrec,
145  input.param.invParam.MaxCG,
146  input.param.invParam.MaxCGPrec,
147  n_count);
148 
149  swatch.stop();
150 
151  t = swatch.getTimeInSeconds();
152 
153  QDPIO::cout << "GMRESRCG on point source took: " << n_count << " iterations" << std::endl;
154  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
155  push(xml_out, "GMRESRCGPointSource");
156  write(xml_out, "n_count", n_count);
157  write(xml_out, "t", t);
158  pop(xml_out);
159 
160  psi = zero;
161  swatch.reset();
162  swatch.start();
163  S.qprop(psi,
164  connect_state,
165  chi,
166  REL_CG_INVERTER,
167  input.param.invParam.RsdCG,
168  input.param.invParam.MaxCG,
169  n_count);
170  swatch.stop();
171  t = swatch.getTimeInSeconds();
172  QDPIO::cout << "SUMR on point source took: " << n_count << " iterations" << std::endl;
173  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
174  push(xml_out, "SUMRPointSource");
175  write(xml_out, "n_count", n_count);
176  write(xml_out, "t", t);
177  pop(xml_out);
178 
179 #if 0
180  // Solve on non chiral sources
181  gaussian(chi);
182  chi /= sqrt(norm2(chi));
183 
184  psi = zero;
185  swatch.reset();
186  swatch.start();
187  S.qprop(psi,
188  connect_state,
189  chi,
190  CG_INVERTER,
191  input.param.invParam.RsdCG,
192  input.param.invParam.MaxCG,
193  n_count);
194  swatch.stop();
195  t = swatch.getTimeInSeconds();
196 
197  QDPIO::cout << "CG on gaussian source took: " << n_count << " iterations" << std::endl;
198  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
199  push(xml_out, "CGGaussianSource");
200  write(xml_out, "n_count", n_count);
201  write(xml_out, "t", t);
202  pop(xml_out);
203 
204  psi = zero;
205  swatch.reset();
206  swatch.start();
207  S.qprop(psi,
208  connect_state,
209  chi,
210  SUMR_INVERTER,
211  input.param.invParam.RsdCG,
212  input.param.invParam.MaxCG,
213  n_count);
214  swatch.stop();
215  t = swatch.getTimeInSeconds();
216 
217  QDPIO::cout << "SUMR on gaussian source took: " << n_count << " iterations" << std::endl;
218  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
219  push(xml_out, "SUMRGaussianSource");
220  write(xml_out, "n_count", n_count);
221  write(xml_out, "t", t);
222  pop(xml_out);
223 #endif
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
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
int G5
Definition: pbg5p_w.cc:57
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_rel_gmresr.cc:44