23 namespace InlineQIOReadNamedObjEnv
27 namespace QIOReadObjectEnv
36 virtual void operator()(QDP_serialparallel_t serpar) = 0;
50 TheQIOReadObjectFactory;
57 class QIOReadLatProp :
public QIOReadObject
63 QIOReadLatProp(
const Params&
p) :
params(
p) {}
67 LatticePropagator
obj;
68 XMLReader file_xml, record_xml;
70 QDPFileReader to(file_xml,
params.file.file_name,serpar);
82 QIOReadObject* qioReadLatProp(
const Params&
p)
84 return new QIOReadLatProp(
p);
90 class QIOReadLatPropF :
public QIOReadObject
96 QIOReadLatPropF(
const Params&
p) :
params(
p) {}
100 LatticePropagatorF
obj;
101 XMLReader file_xml, record_xml;
103 QDPFileReader to(file_xml,
params.file.file_name,serpar);
115 QIOReadObject* qioReadLatPropF(
const Params&
p)
117 return new QIOReadLatPropF(
p);
123 class QIOReadLatPropD :
public QIOReadObject
129 QIOReadLatPropD(
const Params&
p) :
params(
p) {}
132 void operator()(QDP_serialparallel_t serpar) {
133 LatticePropagatorD
obj;
134 XMLReader file_xml, record_xml;
136 QDPFileReader to(file_xml,
params.file.file_name,serpar);
148 QIOReadObject* qioReadLatPropD(
const Params&
p)
150 return new QIOReadLatPropD(
p);
156 class QIOReadStagLatProp :
public QIOReadObject
162 QIOReadStagLatProp(
const Params&
p) :
params(
p) {}
165 void operator()(QDP_serialparallel_t serpar) {
166 LatticeStaggeredPropagator
obj;
167 XMLReader file_xml, record_xml;
169 QDPFileReader to(file_xml,
params.file.file_name,serpar);
181 QIOReadObject* qioReadStagLatProp(
const Params&
p)
183 return new QIOReadStagLatProp(
p);
189 class QIOReadStagLatPropF :
public QIOReadObject
195 QIOReadStagLatPropF(
const Params&
p) :
params(
p) {}
198 void operator()(QDP_serialparallel_t serpar) {
199 LatticeStaggeredPropagatorF
obj;
200 XMLReader file_xml, record_xml;
202 QDPFileReader to(file_xml,
params.file.file_name,serpar);
214 QIOReadObject* qioReadStagLatPropF(
const Params&
p)
216 return new QIOReadStagLatPropF(
p);
221 class QIOReadStagLatPropD :
public QIOReadObject
227 QIOReadStagLatPropD(
const Params&
p) :
params(
p) {}
230 void operator()(QDP_serialparallel_t serpar) {
231 LatticeStaggeredPropagatorD
obj;
232 XMLReader file_xml, record_xml;
234 QDPFileReader to(file_xml,
params.file.file_name,serpar);
246 QIOReadObject* qioReadStagLatPropD(
const Params&
p)
248 return new QIOReadStagLatPropD(
p);
255 class QIOReadSubsetVectorsLCV :
public QIOReadObject
259 Handle< MapObject<int,EVPair<LatticeColorVector> > >
obj;
262 QIOReadSubsetVectorsLCV(
const Params& params_) :
params(params_)
270 XMLBufferWriter file_xml;
272 push(file_xml,
"MODMetaData");
274 write(file_xml,
"lattSize", QDP::Layout::lattSize());
278 file_str = file_xml.str();
282 std::istringstream xml_nam(
params.named_obj_xml.xml);
283 XMLReader namtop(xml_nam);
284 GroupXML_t colorvec_obj =
readXMLGroup(namtop,
"MapObject",
"MapObjType");
293 catch (std::bad_cast)
295 QDPIO::cerr <<
"QIOReadSubsetVectorsLCV: caught dynamic cast error" << std::endl;
300 QDPIO::cerr <<
"QIOReadSubsetVectorsLCV: error creating prop: " << e << std::endl;
309 void operator()(QDP_serialparallel_t serpar) {
311 XMLReader file_xml, record_xml, largest_record_xml;
314 QDPFileReader to(file_xml,
params.file.file_name,serpar);
319 XMLReader vec_xml(file_xml,
"/AllVectors");
321 read(vec_xml,
"n_vec", N);
322 read(vec_xml,
"decay_dir", decay_dir);
325 QDPIO::cerr<<
"Caught Exception while reading XML: " << e << std::endl;
330 const int Lt = QDP::Layout::lattSize()[decay_dir];
334 std::istringstream xml_nam(
params.named_obj_xml.xml);
335 XMLReader param_xml_top(xml_nam);
336 XMLReader param_xml(param_xml_top,
"MapObject");
337 if(param_xml.count(
"num_vecs") > 0)
338 read(param_xml,
"num_vecs", num_vecs);
343 QDPIO::cerr<<
"Error: number of vectors to read, num_vecs= " << num_vecs <<
", is greater than number in file, N= " << N << std::endl;
348 QDPIO::cout <<
"About to read " << num_vecs <<
" out of " << N <<
" evectors from QIO..."<<std::endl;
349 for(
int n=0;
n < num_vecs;
n++)
351 XMLReader record_xml_dummy;
352 EVPair<LatticeColorVector> read_pair;
354 read(to, record_xml_dummy, read_pair.eigenVector);
356 read_pair.eigenValue.weights.resize(Lt);
357 read(record_xml_dummy,
"/VectorInfo/weights", read_pair.eigenValue.weights);
358 QDPIO::cout <<
"Inserting Pair " <<
n <<
" into Map" << std::endl;
359 obj->insert(
n, read_pair);
365 XMLBufferWriter
dummy;
369 record_xml.open(
dummy);
380 QIOReadObject* qioReadSubsetVectorsLCV(
const Params&
p)
382 return new QIOReadSubsetVectorsLCV(
p);
395 class QIOReadLatFerm :
public QIOReadObject
401 QIOReadLatFerm(
const Params&
p) :
params(
p) {}
404 void operator()(QDP_serialparallel_t serpar) {
406 XMLReader file_xml, record_xml;
408 QDPFileReader to(file_xml,
params.file.file_name,serpar);
420 QIOReadObject* qioReadLatFerm(
const Params&
p)
422 return new QIOReadLatFerm(
p);
432 QDP_serialparallel_t serpar)
435 XMLReader file_xml, record_xml;
437 QDPFileReader to(file_xml,
params.file.file_name,serpar);
451 QDP_serialparallel_t serpar)
454 XMLReader file_xml, record_xml;
456 QDPFileReader to(file_xml,
params.file.file_name,serpar);
469 class QIOReadArrayLatColMat :
public QIOReadObject
475 QIOReadArrayLatColMat(
const Params&
p) :
params(
p) {}
478 void operator()(QDP_serialparallel_t serpar) {
479 multi1d<LatticeColorMatrix>
obj;
480 XMLReader file_xml, record_xml;
484 QDPFileReader to(file_xml,
params.file.file_name,serpar);
496 QIOReadObject* qioReadArrayLatColMat(
const Params&
p)
498 return new QIOReadArrayLatColMat(
p);
504 class QIOReadArrayLatColMatF :
public QIOReadObject
510 QIOReadArrayLatColMatF(
const Params&
p) :
params(
p) {}
513 void operator()(QDP_serialparallel_t serpar) {
514 multi1d<LatticeColorMatrixF>
obj;
515 XMLReader file_xml, record_xml;
519 QDPFileReader to(file_xml,
params.file.file_name,serpar);
525 for(
int i=0;
i <
Nd;
i++) {
534 QIOReadObject* qioReadArrayLatColMatF(
const Params&
p)
536 return new QIOReadArrayLatColMatF(
p);
542 class QIOReadArrayLatColMatD :
public QIOReadObject
548 QIOReadArrayLatColMatD(
const Params&
p) :
params(
p) {}
551 void operator()(QDP_serialparallel_t serpar) {
552 multi1d<LatticeColorMatrixD>
obj;
553 XMLReader file_xml, record_xml;
557 QDPFileReader to(file_xml,
params.file.file_name,serpar);
563 for(
int i=0;
i <
Nd;
i++) {
574 QIOReadObject* qioReadArrayLatColMatD(
const Params&
p)
576 return new QIOReadArrayLatColMatD(
p);
582 class QIOReadQQDiquarkContract :
public QIOReadObject
588 QIOReadQQDiquarkContract(
const Params&
p) :
params(
p) {}
591 void operator()(QDP_serialparallel_t serpar) {
593 XMLReader file_xml, record_xml;
594 const int sz_qq = Ns*Ns*Ns*Ns*Nc*Nc;
595 multi1d<LatticeComplex> obj_1d(sz_qq);
597 QDPFileReader to(file_xml,
params.file.file_name,serpar);
598 read(to,record_xml,obj_1d);
615 multi1d<int> ranks(6);
616 for(ranks[0]=0; ranks[0] < sz[0]; ++ranks[0])
617 for(ranks[1]=0; ranks[1] < sz[1]; ++ranks[1])
618 for(ranks[2]=0; ranks[2] < sz[2]; ++ranks[2])
619 for(ranks[3]=0; ranks[3] < sz[3]; ++ranks[3])
620 for(ranks[4]=0; ranks[4] < sz[4]; ++ranks[4])
621 for(ranks[5]=0; ranks[5] < sz[5]; ++ranks[5])
626 QDPIO::cerr << __func__ <<
": size mismatch for multi1Nd object" << std::endl;
630 obj.comp[ranks] = obj_1d[cnt++];
636 QIOReadObject* qioReadQQDiquarkContract(
const Params&
p)
638 return new QIOReadQQDiquarkContract(
p);
643 class QIOReadEigenInfoLatticeFermion :
public QIOReadObject
649 QIOReadEigenInfoLatticeFermion(
const Params&
p) :
params(
p) {}
652 void operator()(QDP_serialparallel_t serpar) {
653 multi1d<Real64> evalsD;
660 multi1d<Real64> largestD(1);
663 LatticeFermion evecD;
666 XMLReader file_xml, record_xml, largest_record_xml;
669 QDPFileReader to(file_xml,
params.file.file_name,serpar);
675 read(to, largest_record_xml, largestD);
680 read(largest_record_xml,
"/NumElem/n_vec", size);
683 QDPIO::cerr<<
"Caught Exception while reading XML: " << e << std::endl;
694 read(to, record_xml, evalsD);
696 QDPIO::cout <<
"Read " << evalsD.size() <<
"Evals " << std::endl;
697 for(
int i=0;
i < evalsD.size();
i++) {
698 QDPIO::cout <<
"Eval["<<
i<<
"] = " << Real(evalsD[
i]) << std::endl;
705 for (
int i=0;
i<evalsD.size();
i++)
714 for (
int i=0;
i<evalsD.size();
i++)
716 XMLReader record_xml_dummy;
717 read(to, record_xml_dummy, evecD);
718 LatticeFermion evecR;
734 QIOReadObject* qioReadEigenInfoLatticeFermion(
const Params&
p)
736 return new QIOReadEigenInfoLatticeFermion(
p);
742 class QIOReadRitzPairsLatticeFermion :
public QIOReadObject
748 QIOReadRitzPairsLatticeFermion(
const Params&
p) :
params(
p) {}
751 void operator()(QDP_serialparallel_t serpar) {
756 QDPFileReader to(file_xml,
params.file.file_name,serpar);
763 LinAlg::RitzPairs<LatticeFermion>&
obj =
766 XMLReader record_xml;
770 read(file_xml,
"/RitzPairs/Nmax", Nmax);
771 read(file_xml,
"/RitzPairs/Neig",
obj.Neig);
773 obj.evec.resize(Nmax);
774 obj.eval.resize(Nmax);
778 QDPIO::cerr << __func__ <<
": error, found Neig > Nmax" << std::endl;
783 for(
int i=0;
i <
obj.Neig; ++
i)
785 XMLReader record_xml;
786 read(to, record_xml,
obj.evec.vec[
i]);
788 read(record_xml,
"/Eigenstd::vector/eigenValue",
obj.eval.vec[
i]);
797 QIOReadObject* qioReadRitzPairsLatticeFermion(
const Params&
p)
799 return new QIOReadRitzPairsLatticeFermion(
p);
819 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticePropagator"),
821 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticePropagatorF"),
823 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticePropagatorD"),
826 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticeStaggeredPropagator"),
828 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticeStaggeredPropagatorF"),
829 qioReadStagLatPropF);
830 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticeStaggeredPropagatorD"),
831 qioReadStagLatPropD);
833 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"SubsetVectorsLatticeColorVector"),
834 qioReadSubsetVectorsLCV);
836 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"LatticeFermion"),
844 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"Multi1dLatticeColorMatrix"),
845 qioReadArrayLatColMat);
847 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"Multi1dLatticeColorMatrixF"),
848 qioReadArrayLatColMatF);
850 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"Multi1dLatticeColorMatrixD"),
851 qioReadArrayLatColMatD);
853 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"QQDiquarkContract"),
854 qioReadQQDiquarkContract);
856 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"EigenInfoLatticeFermion"),
857 qioReadEigenInfoLatticeFermion);
859 success &= TheQIOReadObjectFactory::Instance().registerObject(
std::string(
"RitzPairsLatticeFermion"),
860 qioReadRitzPairsLatticeFermion);
875 return new InlineMeas(Params(xml_in, path));
910 XMLReader inputtop(xml, path);
919 XMLReader inputtop(xml, path);
922 if( inputtop.count(
"parallel_io") == 1 ) {
926 input.
parallel_io = Layout::isIOGridDefined() && ( Layout::numIONodeGrid() > 1 );
938 XMLReader paramtop(xml_in, path);
940 if (paramtop.count(
"Frequency") == 1)
956 QDPIO::cerr << __func__ <<
": caught Exception reading XML: " << e << std::endl;
968 push(xml_out,
"qio_read_named_obj");
969 write(xml_out,
"update_no", update_no);
971 QDPIO::cout <<
name <<
": object reader" << std::endl;
986 QDP_serialparallel_t serpar;
988 QDPIO::cout <<
"Attempting Parallel IO read" << std::endl;
989 serpar = QDPIO_PARALLEL;
992 serpar = QDPIO_SERIAL;
998 (*qioReadObject)(serpar);
1002 QDPIO::cout <<
"Object successfully read: time= "
1003 << swatch.getTimeInSeconds()
1004 <<
" secs" << std::endl;
1006 catch( std::bad_cast )
1008 QDPIO::cerr <<
name <<
": caught dynamic cast error"
1014 QDPIO::cerr <<
name <<
": std::map call failed: " << e
1019 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
Class for counted reference semantics.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
virtual void operator()(QDP_serialparallel_t serpar)=0
Read the object.
Construct a diquark object.
Hold eigenvalues and eigenvectors.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
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.
Handle< MapObject< int, EVPair< LatticeColorVector > > > obj
Inline task to read an object from a named buffer.
Key for propagator colorstd::vector sources.
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Object buffer.
bool registerAll()
Register all the factories.
bool registerAll()
aggregate everything
multi1d< Hadron2PtContraction_t > operator()(const multi1d< LatticeColorMatrix > &u)
Asqtad Staggered-Dirac operator.
push(xml_out,"Condensates")
Holds of vectors and weights.