7 #ifndef QDP_IS_QDPJIT_NO_NVPTX
9 #include "qdp_map_obj_memory.h"
10 #include "qdp_map_obj_disk.h"
11 #include "qdp_map_obj_disk_multiple.h"
12 #include "qdp_disk_map_slice.h"
45 namespace InlineUnsmearedHadronNodeDistillationEnv
50 XMLReader inputtop(xml, path);
73 XMLReader inputtop(xml, path);
77 read(inputtop,
"mom", input.
mom);
96 XMLReader inputtop(xml, path);
123 XMLReader inputtop(xml, path);
147 XMLReader inputtop(xml, path);
174 XMLReader inputtop(xml, path);
177 read(inputtop,
"Propagator", input.
prop);
224 namespace InlineUnsmearedHadronNodeDistillationEnv
228 typedef QDP::MapObjectDisk<KeyTimeSliceColorVec_t, TimeSliceIO<LatticeColorVectorF> >
MOD_t;
231 typedef QDP::MapObjectDiskMultiple<KeyTimeSliceColorVec_t, TimeSliceIO<LatticeColorVectorF> >
MODS_t;
234 typedef QDP::MapObjectMemory<KeyTimeSliceColorVec_t, SubLatticeColorVectorF>
SUB_MOD_t;
240 namespace InlineUnsmearedHadronNodeDistillationEnv
248 return new InlineMeas(Params(xml_in, path));
275 StandardOutputStream&
operator<<(StandardOutputStream& os,
const multi1d<int>&
d)
281 for(
int i=1;
i <
d.size(); ++
i)
288 StandardOutputStream&
operator<<(StandardOutputStream& os,
const std::vector<int>&
d)
294 for(
int i=1;
i <
d.size(); ++
i)
312 XMLReader paramtop(xml_in, path);
314 if (paramtop.count(
"Frequency") == 1)
326 if (paramtop.count(
"xml_file") != 0)
333 QDPIO::cerr << __func__ <<
": Caught Exception reading XML: " << e << std::endl;
378 multi3d<ComplexD>
op;
403 readDesc(bin, param.
mass);
417 writeDesc(bin, param.
mass);
423 XMLReader paramtop(xml, path);
432 read(paramtop,
"mom", param.
mom);
544 LatticeFermion quark_soln =
zero;
550 for(
int nn = 1; nn <= num_tries; ++nn)
561 if (toDouble(res.
resid) > 1.0e-3)
563 QDPIO::cerr <<
name <<
": have a resid > 1.0e-3. That is unacceptable" << std::endl;
568 if (isfinite(quark_soln))
575 QDPIO::cerr <<
name <<
": WARNING - found something not finite, may retry\n";
583 QDPIO::cerr <<
name <<
": this is bad - did not get a finite solution vector after num_tries= " << num_tries << std::endl;
602 const LatticeColorVectorSpinMatrix&
getSoln(
int t_source,
int colorvec_src);
615 std::map<int, Params::Param_t::KeySolnProp_t>
keys;
618 MapObjectMemory<Params::Param_t::KeySolnProp_t, std::map<int, LatticeColorVectorSpinMatrix> >
cache;
632 QDPIO::cout << __func__ <<
": initialize the prop cache" << std::endl;
635 typedef LatticeFermion
T;
636 typedef multi1d<LatticeColorMatrix>
P;
637 typedef multi1d<LatticeColorMatrix>
Q;
642 std::istringstream xml_s(
prop.fermact.xml);
643 XMLReader fermacttop(xml_s);
644 QDPIO::cout <<
"FermAct = " <<
prop.fermact.id << std::endl;
657 QDPIO::cout << __func__ <<
": finished initializing the prop cache"
658 <<
" time = " << swatch.getTimeInSeconds()
659 <<
" secs" << std::endl;
667 if (
cache.exist(key)) {
668 QDPIO::cerr << __func__ <<
": cache entry already exists" << std::endl;
672 QDPIO::cout << __func__ <<
": new t_source = " << key.
t_source << std::endl;
678 cache.insert(key, std::map<int, LatticeColorVectorSpinMatrix>());
687 QDPIO::cerr << __func__ <<
": t_ind does not exist in cache = " <<
t_slice << std::endl;
694 if (
cache[key].find(colorvec_ind) !=
cache[key].end()) {
696 return cache[key].at(colorvec_ind);
699 QDPIO::cout << __func__ <<
": CREATING KEY: t_slice = " <<
t_slice <<
" colorvec_ind = " << colorvec_ind << std::endl;
700 cache[key].insert(std::make_pair(colorvec_ind, LatticeColorVectorSpinMatrix(
zero)));
708 LatticeColorVectorF vec_srce =
zero;
710 TimeSliceIO<LatticeColorVectorF> time_slice_io(vec_srce,
t_slice);
714 for(
int spin_ind=0; spin_ind < Ns; ++spin_ind)
716 QDPIO::cout << __func__ <<
": do t_slice= " <<
t_slice <<
" spin_ind= " << spin_ind <<
" colorvec_ind= " << colorvec_ind << std::endl;
732 QDPIO::cout << __func__ <<
": time to compute prop for t_slice= " <<
t_slice
733 <<
" spin_ind= " << spin_ind
734 <<
" colorvec_ind= " << colorvec_ind
735 <<
" time = " << snarss1.getTimeInSeconds()
736 <<
" secs" << std::endl;
740 QDPIO::cout << __func__ <<
": FINISHED: total time for t_slice = " <<
t_slice <<
" colorvec_ind = " << colorvec_ind
741 <<
" time= " << swatch.getTimeInSeconds() <<
" secs" << std::endl;
743 return cache[key][colorvec_ind];
751 QDPIO::cerr << __func__ <<
": t_source does not exist in cache = " <<
t_source << std::endl;
762 std::vector<int>
normDisp(
const std::vector<int>& orig)
766 std::vector<int> disp;
767 std::vector<int> empty;
768 std::vector<int> no_disp(1); no_disp[0] = 0;
772 if (orig.size() == 1)
802 push(xml_out,
"HadronNode");
803 write(xml_out,
"update_no", update_no);
804 write(xml_out,
"xml_file", xml_file);
807 XMLFileWriter xml(xml_file);
808 func(update_no, xml);
812 func(update_no, xml_out);
829 QDPIO::cout <<
name <<
": construct unsmeared hadron nodes via distillation" << std::endl;
832 multi1d<LatticeColorMatrix>
u;
833 XMLBufferWriter gauge_xml;
839 catch( std::bad_cast )
841 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
846 QDPIO::cerr <<
name <<
": std::map call failed: " << e << std::endl;
850 push(xml_out,
"UnsmearedHadronNode");
851 write(xml_out,
"update_no", update_no);
857 write(xml_out,
"Config_info", gauge_xml);
859 push(xml_out,
"Output_version");
860 write(xml_out,
"out_version", 1);
864 MesPlq(xml_out,
"Observables",
u);
868 const int Lt = Layout::lattSize()[decay_dir];
871 if (decay_dir !=
Nd-1)
873 QDPIO::cerr <<
name <<
": TimeSliceIO only supports decay_dir= " <<
Nd-1 <<
"\n";
887 QDPIO::cout <<
"Snarf the source from a std::map object disk file" << std::endl;
901 QDPIO::cout <<
"Get user data" << std::endl;
910 catch (std::bad_cast) {
911 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
915 QDPIO::cerr <<
name <<
": error extracting source_header: " << e << std::endl;
918 catch(
const char* e) {
919 QDPIO::cerr <<
name <<
": Caught some char* exception:" << std::endl;
920 QDPIO::cerr << e << std::endl;
921 QDPIO::cerr <<
"Rethrowing" << std::endl;
925 QDPIO::cout <<
"Source successfully read and parsed" << std::endl;
931 QDPIO::cerr <<
name <<
": number of available eigenvectors is too small\n";
934 QDPIO::cout <<
"Number of vecs available is large enough" << std::endl;
940 QDPIO::cout <<
"Initalize link smearing" << std::endl;
946 XMLReader linktop(xml_l);
955 QDPIO::cerr <<
name <<
": Caught Exception link smearing: " << e << std::endl;
959 QDPIO::cout <<
"Link smearing successfully initialized" << std::endl;
965 QDPIO::cout <<
"Parse momentum list" << std::endl;
978 MapObjectMemory<multi1d<int>,
int> uniq_mom;
982 QDPIO::cout <<
name <<
": mom= " << ins->mom << std::endl;
983 uniq_mom.insert(ins->mom, 1);
984 QDPIO::cout <<
" found mom" << std::endl;
985 mom_size = ins->mom.size();
986 QDPIO::cout <<
" mom_size= " << mom_size << std::endl;
992 std::vector<int> disp =
normDisp(ins->displacement);
998 george.insert(ins->mom, 1);
999 fred.insert(ins->gamma, george);
1001 if (disp_gamma_moms.exist(disp))
1003 if (disp_gamma_moms[disp].exist(ins->gamma))
1005 disp_gamma_moms[disp][ins->gamma].insert(ins->mom, 1);
1009 disp_gamma_moms[disp].insert(ins->gamma, george);
1014 disp_gamma_moms.insert(disp, fred);
1018 int num_mom = uniq_mom.size();
1019 QDPIO::cout <<
name <<
": num_mom= " << num_mom <<
" mom_size= " << mom_size << std::endl;
1020 moms.resize(num_mom,mom_size);
1022 for(
auto mom = uniq_mom.begin(); mom != uniq_mom.end(); ++mom)
1023 moms[
i++] = mom->first;
1027 QDPIO::cerr <<
name <<
": warning - you have an empty disp_gamma_mom_list" << std::endl;
1041 multi1d<LatticeColorMatrix> u_smr =
u;
1046 XMLReader linktop(xml_l);
1055 (*linkSmearing)(u_smr);
1059 QDPIO::cerr <<
name <<
": Caught Exception link smearing: " << e << std::endl;
1064 MesPlq(xml_out,
"Smeared_Observables", u_smr);
1075 XMLBufferWriter file_xml;
1077 push(file_xml,
"DBMetaData");
1079 write(file_xml,
"lattSize", QDP::Layout::lattSize());
1080 write(file_xml,
"decay_dir", decay_dir);
1082 write(file_xml,
"Config_info", gauge_xml);
1086 qdp_db.setMaxUserInfoLen(file_str.size());
1090 qdp_db.insertUserdata(file_str);
1097 QDPIO::cout <<
"Finished opening distillation file" << std::endl;
1109 QDPIO::cout <<
name <<
": initialize the prop cache" << std::endl;
1113 QDPIO::cout <<
name <<
": initialize the time sources" << std::endl;
1124 const int g5 = Ns*Ns-1;
1128 int t_sink = sink_source->t_sink;
1129 int t_source = sink_source->t_source;
1130 int sink_num_vecs = prop_cache.
getNumVecs(t_sink);
1133 QDPIO::cout <<
"\n\n--------------------------\nSink-Source pair: t_sink = " << t_sink <<
" t_source = " <<
t_source << std::endl;
1140 std::vector<bool> active_t_slices(Lt);
1145 for(
int t=0;
t < Lt; ++
t)
1147 active_t_slices[
t] =
false;
1151 for(
int dt=0;
dt < sink_source->Nt_forward; ++
dt)
1154 active_t_slices[
t] =
true;
1158 for(
int dt=0;
dt < sink_source->Nt_backward; ++
dt)
1161 active_t_slices[
t] =
true;
1169 for(
int colorvec_src=0; colorvec_src < srce_num_vecs; ++colorvec_src)
1171 QDPIO::cout <<
"SOURCE: colorvec_src = " << colorvec_src << std::endl;
1181 const LatticeColorVectorSpinMatrix& soln_srce = prop_cache.
getSoln(
t_source, colorvec_src);
1193 QDPIO::cout <<
"SOURCE: do insertions for colorvec_src= " << colorvec_src << std::endl;
1197 for(
auto dd = disp_gamma_moms.begin(); dd != disp_gamma_moms.end(); ++dd)
1199 for(
auto gg = dd->second.begin(); gg != dd->second.end(); ++gg)
1201 for(
auto mm = gg->second.begin(); mm != gg->second.end(); ++mm)
1207 auto disp = dd->first.deriv;
1208 auto gamma = gg->first.gamma;
1209 auto mom = mm->first;
1210 int mom_num = phases.
momToNum(mom);
1212 QDPIO::cout <<
"Insertion: disp= " << disp <<
" gamma= " << gamma <<
" mom= " << mom << std::endl;
1230 LatticeColorVectorSpinMatrix
tmp = phases[mom_num] *
1242 multi1d<KeyValUnsmearedMesonElementalOperator_t> buf(phases.
numSubsets());
1245 if (! active_t_slices[
t]) {
continue;}
1248 buf[
t].key.key().t_sink = t_sink;
1249 buf[
t].key.key().t_slice =
t;
1251 buf[
t].key.key().colorvec_src = colorvec_src;
1252 buf[
t].key.key().gamma = gamma;
1253 buf[
t].key.key().displacement = disp;
1254 buf[
t].key.key().mom = mom;
1256 buf[
t].val.data().op.resize(sink_num_vecs,Ns,Ns);
1261 for(
int colorvec_snk=0; colorvec_snk < sink_num_vecs; ++colorvec_snk)
1266 multi1d<SpinMatrixD> fred = sumMulti(localColorInnerProduct(prop_cache.
getSoln(t_sink, colorvec_snk),
tmp), phases.
getSet());
1270 if (! active_t_slices[
t]) {
continue;}
1273 SpinMatrixD gred = Gamma(g5) * fred[
t];
1275 for (
int spin_snk = 0; spin_snk < Ns; ++spin_snk)
1276 for (
int spin_src = 0; spin_src < Ns; ++spin_src)
1277 buf[
t].val.
data().op(colorvec_snk,spin_snk,spin_src) = peekSpin(gred, spin_snk, spin_src);
1284 if (! active_t_slices[
t]) {
continue;}
1289 qdp_db.insert(buf[
t].key, buf[
t].val);
1293 QDPIO::cout <<
" Time to build elemental: colorvec_src= " << colorvec_src
1294 <<
" gamma= " << gamma
1295 <<
" disp= " << disp
1297 <<
" time = " << snarss2.getTimeInSeconds() <<
" secs " <<std::endl;
1303 QDPIO::cout <<
"Time to do all insertions for colorvec_src= " << colorvec_src <<
" time = " << snarss1.getTimeInSeconds() <<
" secs " <<std::endl;
1307 QDPIO::cout <<
"SINK-SOURCE: time to compute all source solution vectors and insertions for t_sink= " << t_sink <<
" t_source= " <<
t_source <<
" time= " << swatch.getTimeInSeconds() <<
" secs" <<std::endl;
1312 QDPIO::cout <<
name <<
": caught exception around qprop: " << e << std::endl;
1323 QDPIO::cout <<
name <<
": total time = "
1324 << snoop.getTimeInSeconds()
1325 <<
" secs" << std::endl;
1327 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
const LatticeColorVectorSpinMatrix & getDispVector(bool use_derivP, const multi1d< int > &mom, const std::vector< int > &disp)
Accessor.
Class for counted reference semantics.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Handle< SystemSolver< LatticeFermion > > PP
qprop
void newTimeSource(const Params::Param_t::KeySolnProp_t &key_)
New t-slice.
MapObjectMemory< Params::Param_t::KeySolnProp_t, std::map< int, LatticeColorVectorSpinMatrix > > cache
Cache: {key -> {colorvec -> LCVSM}}.
SourcePropCache(const multi1d< LatticeColorMatrix > &u, const ChromaProp_t &prop, MODS_t &eigs, int num_tries)
MODS_t & eigen_source
Eigenvectors.
std::map< int, Params::Param_t::KeySolnProp_t > keys
t_source -> prop keys
int getNumVecs(int t_source)
Getters.
int num_tries
Put it here.
const LatticeColorVectorSpinMatrix & getSoln(int t_source, int colorvec_src)
The solution.
Serializable value harness.
Serializable key harness.
Fourier transform phase factor support.
int numSubsets() const
Number of subsets - length in decay direction.
int momToNum(const multi1d< int > &mom_in) const
Convert array of momenta to momenta id.
const Set & getSet() const
The set to be used in sumMulti.
Cache for displaced solution vectors.
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 FermToProp(const LatticeFermionF &a, LatticePropagatorF &b, int color_index, int spin_index)
Insert a LatticeFermion into a LatticePropagator.
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.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Class for counted reference semantics.
std::map< std::string, SinkPropContainer_t > prop
MODS_t & eigen_source
Eigenvectors.
Inline measurement that construct unsmeared hadron nodes using distillation.
Key for time-sliced color eigenvectors.
All link smearing constructors.
Factory for producing link smearing objects.
Named object function std::map.
static bool registered
Local registration flag.
multi1d< LatticeColorMatrix > P
QDP::MapObjectMemory< KeyTimeSliceColorVec_t, SubLatticeColorVectorF > SUB_MOD_t
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Propagator input.
bool registerAll()
Register all the factories.
std::vector< int > normDisp(const std::vector< int > &orig)
Normalize just one displacement array.
MapObjectMemory< KeyTwoQuarkDisp_t, MapTwoQuarkGammaMom_t > MapTwoQuarkDispGammaMom_t
Map holding expressions. Key is the two-quark, val is the weight.
MapObjectMemory< multi1d< int >, int > MapTwoQuarkMom_t
Map holding expressions. Key is the mom, val is some unique counter.
MapObjectMemory< KeyTwoQuarkGamma_t, MapTwoQuarkMom_t > MapTwoQuarkGammaMom_t
Map holding expressions. Key is the two-quark, val is the mom.
QDP::MapObjectDiskMultiple< KeyTimeSliceColorVec_t, TimeSliceIO< LatticeColorVectorF > > MODS_t
LatticeFermion doInversion(const SystemSolver< LatticeFermion > &PP, const LatticeColorVector &vec_srce, int spin_source, int num_tries)
Invert off of each source, and do all the checking.
QDP::MapObjectDisk< KeyTimeSliceColorVec_t, TimeSliceIO< LatticeColorVectorF > > MOD_t
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Propagator output.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
QDP::StandardOutputStream & operator<<(QDP::StandardOutputStream &s, const multi1d< int > &d)
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.
KeyTwoQuarkDisp_t(const std::vector< int > &d)
KeyTwoQuarkGamma_t(int g)
Unsmeared meson operator.
std::vector< int > displacement
Holds key and value as temporaries.
SerialDBData< ValUnsmearedMesonElementalOperator_t > val
SerialDBKey< KeyUnsmearedMesonElementalOperator_t > key
std::vector< std::string > colorvec_files
std::vector< int > displacement
std::vector< SinkSource_t > sink_source_pairs
std::vector< DispGammaMom_t > disp_gamma_mom_list
std::vector< KeySolnProp_t > prop_sources
Holds return info from SystemSolver call.
Convenience for building time-slice subsets.
Read an XML group as a std::string.