11 #include "qdp_map_obj.h"
12 #include "qdp_map_obj_disk.h"
13 #include "qdp_map_obj_disk_multiple.h"
14 #include "qdp_map_obj_memory.h"
15 #include "qdp_disk_map_slice.h"
43 multi1d<SubsetVectorWeight_t> readEigVals(
const std::string& meta)
45 std::istringstream xml_l(meta);
46 XMLReader eigtop(xml_l);
50 multi1d< multi1d<Real> > eigens;
53 read(eigtop, pat, eigens);
57 QDPIO::cerr << __func__ <<
": Caught Exception reading meta= XX" << meta <<
"XX with path= " << pat <<
" error= " << e << std::endl;
63 multi1d<SubsetVectorWeight_t> eigenvalues(eigens.size());
65 for(
int i=0;
i < eigens.size(); ++
i)
66 eigenvalues[
i].weights = eigens[
i];
73 namespace InlinePropAndMatElemDistillation2Env
78 XMLReader inputtop(xml, path);
101 XMLReader inputtop(xml, path);
133 XMLReader inputtop(xml, path);
135 read(inputtop,
"Propagator", input.
prop);
173 namespace InlinePropAndMatElemDistillation2Env
177 typedef QDP::MapObjectDisk<KeyTimeSliceColorVec_t, TimeSliceIO<LatticeColorVectorF> >
MOD_t;
180 typedef QDP::MapObjectDiskMultiple<KeyTimeSliceColorVec_t, TimeSliceIO<LatticeColorVectorF> >
MODS_t;
183 typedef QDP::MapObjectMemory<KeyTimeSliceColorVec_t, SubLatticeColorVectorF>
SUB_MOD_t;
205 const SubLatticeColorVectorF& getVec(
int t_source,
int colorvec_src)
const;
206 const SubLatticeColorVectorF& getVecConst(
int t_source,
int colorvec_src)
const;
207 void cacheVec(
int t_source,
int colorvec_src)
const;
222 mutable std::map< Key_t , SubLatticeColorVectorF >
sub_eigen;
225 bool operator<(
const SubEigenMap::Key_t&
l ,
const SubEigenMap::Key_t&
r )
227 if (
l.vec_num <
r.vec_num )
229 if (
l.vec_num >
r.vec_num )
231 if (
l.t_source <
r.t_source )
239 const SubLatticeColorVectorF& SubEigenMap::getVec(
int t_source,
int colorvec_src)
const
243 Key_t map_key(
t_source,colorvec_src);
248 QDPIO::cout << __func__ <<
": on t_source= " <<
t_source <<
" STL map colorvec_src= " << colorvec_src << std::endl;
250 LatticeColorVectorF vec_srce =
zero;
252 TimeSliceIO<LatticeColorVectorF> time_slice_io(vec_srce,
t_source);
255 SubLatticeColorVectorF
tmp(getSet()[
t_source], vec_srce);
264 const SubLatticeColorVectorF& SubEigenMap::getVecConst(
int t_source,
int colorvec_src)
const
266 Key_t map_key(
t_source,colorvec_src);
272 void SubEigenMap::cacheVec(
int t_source,
int colorvec_src)
const
276 Key_t map_key(
t_source,colorvec_src);
281 QDPIO::cout << __func__ <<
": on t_source= " <<
t_source <<
" STL map colorvec_src= " << colorvec_src << std::endl;
283 LatticeColorVectorF vec_srce =
zero;
285 TimeSliceIO<LatticeColorVectorF> time_slice_io(vec_srce,
t_source);
288 SubLatticeColorVectorF
tmp(getSet()[
t_source], vec_srce);
299 std::vector<bool> getActiveTSlices(
int t_source,
int Nt_forward,
int Nt_backward)
302 const int decay_dir =
Nd-1;
303 const int Lt = Layout::lattSize()[decay_dir];
305 std::vector<bool> active_t_slices(Lt);
306 for(
int t=0;
t < Lt; ++
t)
308 active_t_slices[
t] =
false;
312 for(
int dt=0;
dt < Nt_forward; ++
dt)
315 active_t_slices[
t % Lt] =
true;
319 for(
int dt=0;
dt < Nt_backward; ++
dt)
322 while (
t < 0) {
t += Lt;}
324 active_t_slices[
t % Lt] =
true;
327 return active_t_slices;
333 std::list<KeyPropElementalOperator_t> getSnkKeys(
int t_source,
int spin_source,
int Nt_forward,
int Nt_backward,
const std::string mass)
335 std::list<KeyPropElementalOperator_t> keys;
337 std::vector<bool> active_t_slices = getActiveTSlices(
t_source, Nt_forward, Nt_backward);
339 const int decay_dir =
Nd-1;
340 const int Lt = Layout::lattSize()[decay_dir];
342 for(
int spin_sink=0; spin_sink < Ns; ++spin_sink)
344 for(
int t=0;
t < Lt; ++
t)
346 if (! active_t_slices[
t]) {
continue;}
368 namespace InlinePropAndMatElemDistillation2Env
375 return new InlineMeas(Params(xml_in, path));
406 XMLReader paramtop(xml_in, path);
408 if (paramtop.count(
"Frequency") == 1)
420 if (paramtop.count(
"xml_file") != 0)
427 QDPIO::cerr << __func__ <<
": Caught Exception reading XML: " << e << std::endl;
436 template<
class T1,
class C1,
class T2,
class C2>
437 typename QDPSubTypeTrait< typename BinaryReturn<C1,C2,FnLocalInnerProduct>::Type_t >::Type_t
440 if (!
l.getOwnsMemory())
443 typename QDPSubTypeTrait< typename BinaryReturn<C1,C2,FnLocalInnerProduct>::Type_t >::Type_t ret;
444 ret.setSubset(
l.subset() );
448 const int *tab =
l.subset().siteTable().slice();
450 for(
int j=0;
j <
l.subset().numSiteTable(); ++
j)
453 FnLocalInnerProduct op;
454 ret.getF()[
j] = op(
l.getF()[
j] ,
r.elem(
i) );
461 template<
class T1,
class C1,
class T2,
class C2>
462 inline typename BinaryReturn<C1, C2, FnInnerProduct>::Type_t
469 template<
class T1,
class C1,
class T2,
class C2>
470 typename UnaryReturn< OLattice< typename BinaryReturn<T1,T2,FnLocalInnerProduct>::Type_t >, FnSum>::Type_t
473 if (!
l.getOwnsMemory())
476 typename UnaryReturn<OLattice< typename BinaryReturn<T1,T2,FnLocalInnerProduct>::Type_t >, FnSum>::Type_t ret;
478 zero_rep(ret.elem());
480 const int *tab =
l.subset().siteTable().slice();
482 for(
int j=0;
j <
l.subset().numSiteTable(); ++
j)
485 FnLocalInnerProduct op;
487 ret.elem() += op(
l.getF()[
j] ,
r.elem(
i) );
514 push(xml_out,
"PropDistillation");
515 write(xml_out,
"update_no", update_no);
516 write(xml_out,
"xml_file", xml_file);
519 XMLFileWriter xml(xml_file);
520 func(update_no, xml);
524 func(update_no, xml_out);
536 if ( Layout::numNodes() != 1 ) {
537 QDPIO::cerr <<
"This measurement does not support running on multiple nodes." << std::endl;
546 multi1d<LatticeColorMatrix>
u;
547 XMLBufferWriter gauge_xml;
553 catch( std::bad_cast )
555 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
560 QDPIO::cerr <<
name <<
": std::map call failed: " << e << std::endl;
564 push(xml_out,
"PropDistillation");
565 write(xml_out,
"update_no", update_no);
567 QDPIO::cout <<
name <<
": propagator calculation" << std::endl;
575 write(xml_out,
"Config_info", gauge_xml);
577 push(xml_out,
"Output_version");
578 write(xml_out,
"out_version", 1);
582 MesPlq(xml_out,
"Observables",
u);
586 const int Lt = Layout::lattSize()[decay_dir];
589 if (decay_dir !=
Nd-1)
591 QDPIO::cerr <<
name <<
": TimeSliceIO only supports decay_dir= " <<
Nd-1 <<
"\n";
605 QDPIO::cout <<
"Snarf the source from a std::map object disk file" << std::endl;
619 QDPIO::cout <<
"Get user data" << std::endl;
628 catch (std::bad_cast) {
629 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
633 QDPIO::cerr <<
name <<
": error extracting source_header: " << e << std::endl;
636 catch(
const char* e) {
637 QDPIO::cerr <<
name <<
": Caught some char* exception:" << std::endl;
638 QDPIO::cerr << e << std::endl;
639 QDPIO::cerr <<
"Rethrowing" << std::endl;
643 QDPIO::cout <<
"Source successfully read and parsed" << std::endl;
649 QDPIO::cerr <<
name <<
": number of available eigenvectors is too small\n";
654 QDPIO::cout <<
"Number of vecs available is large enough" << std::endl;
657 QDPIO::cout <<
"Initialize sub-lattice std::map" << std::endl;
659 QDPIO::cout <<
"Finished initializing sub-lattice std::map" << std::endl;
670 XMLBufferWriter file_xml;
672 push(file_xml,
"DBMetaData");
674 write(file_xml,
"lattSize", QDP::Layout::lattSize());
678 write(file_xml,
"Config_info", gauge_xml);
679 write(file_xml,
"Weights", readEigVals(eigen_meta_data));
683 qdp_db.setMaxUserInfoLen(file_str.size());
687 qdp_db.insertUserdata(file_str);
694 QDPIO::cout <<
"Finished opening peram file" << std::endl;
707 QDPIO::cout <<
"Try the various factories" << std::endl;
710 typedef LatticeFermion
T;
711 typedef multi1d<LatticeColorMatrix>
P;
712 typedef multi1d<LatticeColorMatrix>
Q;
718 XMLReader fermacttop(xml_s);
732 QDPIO::cout <<
"Suitable factory found: compute all the quark props" << std::endl;
745 for(
int tt=0; tt < t_sources.size(); ++tt)
748 QDPIO::cout <<
"t_source = " <<
t_source << std::endl;
751 for(
int ss=0; ss < src_spins.size(); ++ss)
753 int spin_source = src_spins[ss];
754 QDPIO::cout <<
"spin_source = " << spin_source << std::endl;
757 std::list<KeyPropElementalOperator_t> snk_keys(getSnkKeys(
t_source,
767 for(
int colorvec_src=0; colorvec_src < num_vecs; ++colorvec_src)
776 QDPIO::cout <<
"Do spin_source= " << spin_source <<
" colorvec_src= " << colorvec_src << std::endl;
779 LatticeColorVector vec_srce =
zero;
780 vec_srce = sub_eigen_map.getVec(
t_source, colorvec_src);
786 multi1d<LatticeColorVector> ferm_out(Ns);
793 LatticeFermion quark_soln =
zero;
809 if (toDouble(res.
resid) > 1.0e-3)
811 QDPIO::cerr <<
name <<
": have a resid > 1.0e-3. That is unacceptable" << std::endl;
816 if (isfinite(quark_soln))
823 QDPIO::cerr <<
name <<
": WARNING - found something not finite, may retry\n";
831 QDPIO::cerr <<
name <<
": this is bad - did not get a finite solution std::vector after num_tries= "
837 for(
int spin_sink=0; spin_sink < Ns; ++spin_sink)
839 ferm_out(spin_sink) = peekSpin(quark_soln, spin_sink);
843 QDPIO::cout <<
"Time to compute prop for spin_source= " << spin_source <<
" colorvec_src= " << colorvec_src <<
" time = "
844 << snarss1.getTimeInSeconds()
845 <<
" secs" << std::endl;
853 for(std::list<KeyPropElementalOperator_t>::const_iterator key= snk_keys.begin();
854 key != snk_keys.end();
857 if (key->t_slice !=
t_slice) {
continue;}
861 tmp.mat.resize(num_vecs,num_vecs);
865 for(
int colorvec_sink=0; colorvec_sink < num_vecs; ++colorvec_sink)
866 sub_eigen_map.cacheVec(
t_slice, colorvec_sink);
868 #pragma omp parallel for
869 for(
int colorvec_sink=0; colorvec_sink < num_vecs; ++colorvec_sink)
872 ferm_out(key->spin_snk));
876 qdp_db.insert(*key,
tmp);
882 QDPIO::cout <<
"Time to compute and assemble peram for spin_source= " << spin_source <<
" colorvec_src= " << colorvec_src <<
" time = "
883 << sniss1.getTimeInSeconds()
884 <<
" secs" << std::endl;
889 QDPIO::cout <<
"Write perambulator for spin_source= " << spin_source <<
" to disk" << std::endl;
896 for(std::list<KeyPropElementalOperator_t>::const_iterator key= snk_keys.begin();
897 key != snk_keys.end();
901 qdp_db.insert(*key, peram[*key]);
906 QDPIO::cout <<
"Time to write perambulators for spin_src= " << spin_source <<
" time = "
907 << sniss2.getTimeInSeconds()
908 <<
" secs" << std::endl;
914 QDPIO::cout <<
"Propagators computed: time= "
915 << swatch.getTimeInSeconds()
916 <<
" secs" << std::endl;
920 QDPIO::cout <<
name <<
": caught exception around qprop: " << e << std::endl;
924 push(xml_out,
"Relaxation_Iterations");
925 write(xml_out,
"ncg_had", ncg_had);
931 QDPIO::cout <<
name <<
": total time = "
932 << snoop.getTimeInSeconds()
933 <<
" secs" << std::endl;
935 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
Class for counted reference semantics.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Serializable value harness.
Builds time slice subsets.
const Set & getSet() const
The set to be used in sumMulti.
Basis rotation matrix from Dirac to Degrand-Rossi (and reverse)
Class structure for fermion actions.
Fermion action factories.
All Wilson-type fermion actions.
void CvToFerm(const LatticeColorVectorF &a, LatticeFermionF &b, int spin_index)
Convert (insert) a LatticeColorVector into a LatticeFermion.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams ¶m)
Read parameters.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
TimeSliceSet time_slice_set
MODS_t & eigen_source
Eigenvectors.
std::map< Key_t, SubLatticeColorVectorF > sub_eigen
Where we store the sublattice versions.
Compute the propagator from distillation.
Key for propagator colorstd::vector sources.
Key for vanilla distillation propagator sources and solutions.
Key for propagator colorstd::vector matrix elements.
Key for time-sliced color eigenvectors.
Named object function std::map.
static bool registered
Local registration flag.
multi1d< LatticeColorMatrix > P
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
UnaryReturn< OLattice< typename BinaryReturn< T1, T2, FnLocalInnerProduct >::Type_t >, FnSum >::Type_t sumLocalInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPSubType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Propagator input.
QDP::MapObjectDisk< KeyTimeSliceColorVec_t, TimeSliceIO< LatticeColorVectorF > > MOD_t
QDP::MapObjectMemory< KeyTimeSliceColorVec_t, SubLatticeColorVectorF > SUB_MOD_t
bool registerAll()
Register all the factories.
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Propagator output.
QDP::MapObjectDiskMultiple< KeyTimeSliceColorVec_t, TimeSliceIO< LatticeColorVectorF > > MODS_t
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
bool operator<(const KeyDispColorVector_t &a, const KeyDispColorVector_t &b)
Support for the keys of smeared and displaced color vectors.
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
Print out basic info about this program.
Fourier transform phase factor support.
Sparse matrix representation of spin matrices.
std::vector< std::string > colorvec_files
Holds return info from SystemSolver call.
Holds of vectors and weights.
Convenience for building time-slice subsets.
Contraction operators for two quarks.