CHROMA
inline_qio_write_erase_obj.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline task to write and delete an object from a named buffer
3  *
4  * Named object writing
5  */
6 
10 
11 namespace Chroma
12 {
13  namespace InlineQIOWriteEraseNamedObjEnv
14  {
15  namespace
16  {
17  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
18  const std::string& path)
19  {
20  return new InlineMeas(InlineQIOWriteNamedObjEnv::Params(xml_in, path));
21  }
22 
23  //! Local registration flag
24  bool registered = false;
25 
26  const std::string name = "QIO_WRITE_ERASE_NAMED_OBJECT";
27  }
28 
29  //! Register all the factories
30  bool registerAll()
31  {
32  bool success = true;
33  if (! registered)
34  {
35  // Inline measurement
36  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
37 
38  registered = true;
39  }
40  return success;
41  }
42 
43 
44  // Func
45  void
46  InlineMeas::operator()(unsigned long update_no,
47  XMLWriter& xml_out)
48  {
49  START_CODE();
50 
51  push(xml_out, "qio_write_erase_named_obj");
52  write(xml_out, "update_no", update_no);
53 
54  QDPIO::cout << name << ": object writer" << std::endl;
55  StopWatch swatch;
56 
57  // Write and erase the object
58  // ONLY SciDAC output format is supported in this task
59  // Other tasks could support other disk formats
60  QDPIO::cout << "Attempt to write then delete an object name = " << params.named_obj.object_id << std::endl;
61  write(xml_out, "object_id", params.named_obj.object_id);
62  try
63  {
64  swatch.reset();
65 
66  // Use the qio writer
68 
69  // Write the object
70  qio_write(update_no, xml_out);
71 
72  // Now erase the object
74 
75  QDPIO::cout << "Object erased" << std::endl;
76  }
77  catch( std::bad_cast )
78  {
79  QDPIO::cerr << name << ": cast error"
80  << std::endl;
81  QDP_abort(1);
82  }
83  catch (const std::string& e)
84  {
85  QDPIO::cerr << name << ": error message: " << e
86  << std::endl;
87  QDP_abort(1);
88  }
89 
90  QDPIO::cout << name << ": ran successfully" << std::endl;
91 
92  pop(xml_out); // qio_write_erase_named_obj
93 
94  END_CODE();
95  }
96 
97  }
98 
99 }
Inline measurement factory.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
static T & Instance()
Definition: singleton.h:432
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Inline task to write and delete an object from a named buffer.
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.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
struct Chroma::InlineQIOWriteNamedObjEnv::Params::NamedObject_t named_obj