CHROMA
t_sumr.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_g5eps_bj");
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 
109  psi = zero;
110  swatch.reset();
111  swatch.start();
112  S.qprop(psi,
113  connect_state,
114  chi,
115  SUMR_INVERTER,
116  input.param.invParam.RsdCG,
117  input.param.invParam.MaxCG,
118  n_count);
119 
120  swatch.stop();
121 
122  double t = swatch.getTimeInSeconds();
123 
124  QDPIO::cout << "CG on point source took: " << n_count << " iterations" << std::endl;
125  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
126  push(xml_out, "CGPointSource");
127  write(xml_out, "n_count", n_count);
128  write(xml_out, "t", t);
129  pop(xml_out);
130 
131  psi = zero;
132  swatch.reset();
133  swatch.start();
134  S.qprop(psi,
135  connect_state,
136  chi,
137  REL_SUMR_INVERTER,
138  input.param.invParam.RsdCG,
139  input.param.invParam.MaxCG,
140  n_count);
141  swatch.stop();
142  t = swatch.getTimeInSeconds();
143  QDPIO::cout << "SUMR on point source took: " << n_count << " iterations" << std::endl;
144  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
145  push(xml_out, "SUMRPointSource");
146  write(xml_out, "n_count", n_count);
147  write(xml_out, "t", t);
148  pop(xml_out);
149 
150 #if 0
151  // Solve on non chiral sources
152  gaussian(chi);
153  chi /= sqrt(norm2(chi));
154 
155  psi = zero;
156  swatch.reset();
157  swatch.start();
158  S.qprop(psi,
159  connect_state,
160  chi,
161  CG_INVERTER,
162  input.param.invParam.RsdCG,
163  input.param.invParam.MaxCG,
164  n_count);
165  swatch.stop();
166  t = swatch.getTimeInSeconds();
167 
168  QDPIO::cout << "CG on gaussian source took: " << n_count << " iterations" << std::endl;
169  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
170  push(xml_out, "CGGaussianSource");
171  write(xml_out, "n_count", n_count);
172  write(xml_out, "t", t);
173  pop(xml_out);
174 
175  psi = zero;
176  swatch.reset();
177  swatch.start();
178  S.qprop(psi,
179  connect_state,
180  chi,
181  SUMR_INVERTER,
182  input.param.invParam.RsdCG,
183  input.param.invParam.MaxCG,
184  n_count);
185  swatch.stop();
186  t = swatch.getTimeInSeconds();
187 
188  QDPIO::cout << "SUMR on gaussian source took: " << n_count << " iterations" << std::endl;
189  QDPIO::cout << "Wall clock time : " << t << " seconds" << std::endl;
190  push(xml_out, "SUMRGaussianSource");
191  write(xml_out, "n_count", n_count);
192  write(xml_out, "t", t);
193  pop(xml_out);
194 #endif
195 
196  pop(xml_out);
198 
199  exit(0);
200 }
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_sumr.cc:44