CHROMA
inline_erase_quda_multigrid_space.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline task to erase an object from a named buffer
3  *
4  * Named object writing
5  */
6 
11 #include <quda.h>
12 
13 namespace Chroma {
14 namespace InlineEraseQUDAMULTIGRIDSpaceEnv {
15 namespace {
16 
17 AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
18  const std::string& path) {
19  return new InlineMeas(Params(xml_in, path));
20 }
21 
22 //! Local registration flag
23 bool registered = false;
24 
25 const std::string name = "ERASE_QUDA_MULTIGRID_SUBSPACE";
26 }
27 
28 //! Register all the factories
29 bool registerAll() {
30  bool success = true;
31  if (!registered) {
32  success &= TheInlineMeasurementFactory::Instance().registerObject(name,
33  createMeasurement);
34  registered = true;
35  }
36  return success;
37 }
38 
39 //! Object buffer
40 void write(XMLWriter& xml, const std::string& path,
41  const Params::NamedObject_t& input) {
42  push(xml, path);
43 
44  write(xml, "object_id", input.object_id);
45 
46  pop(xml);
47 }
48 
49 //! Object buffer
50 void read(XMLReader& xml, const std::string& path,
51  Params::NamedObject_t& input) {
52  XMLReader inputtop(xml, path);
53 
54  read(inputtop, "object_id", input.object_id);
55 }
56 
57 // Param stuff
59  frequency = 0;
60 }
61 
62 Params::Params(XMLReader& xml_in, const std::string& path) {
63  try {
64  XMLReader paramtop(xml_in, path);
65 
66  if (paramtop.count("Frequency") == 1)
67  read(paramtop, "Frequency", frequency);
68  else
69  frequency = 1;
70 
71  // Ids
72  read(paramtop, "NamedObject", named_obj);
73  } catch (const std::string& e) {
74  QDPIO::cerr << __func__ << ": caught Exception reading XML: " << e
75  << std::endl;
76  QDP_abort(1);
77  }
78 }
79 
80 void Params::writeXML(XMLWriter& xml_out, const std::string& path) {
81  push(xml_out, path);
82 
83  // Ids
84  write(xml_out, "NamedObject", named_obj);
85 
86  pop(xml_out);
87 }
88 
89 void InlineMeas::operator()(unsigned long update_no, XMLWriter& xml_out) {
90  START_CODE();
91 
92  push(xml_out, "erase_quda_multigrid_subspace");
93  write(xml_out, "update_no", update_no);
94 
95  QDPIO::cout << name << ": object erase" << std::endl;
96 
97  // Erase the object
98  QDPIO::cout << "Attempt to erase object name = "
99  << params.named_obj.object_id << std::endl;
100  write(xml_out, "object_id", params.named_obj.object_id);
103 
104  } else {
105  QDPIO::cout << "QUDA MG Subspace: " << params.named_obj.object_id
106  << " is not in the map. Cannot delete" << std::endl;
107  }
108  QDPIO::cout << name << ": ran successfully" << std::endl;
109 
110  pop(xml_out); // erase_named_obj
111 
112  END_CODE();
113 }
114 
115 }
116 
117 }
118 
Inline measurement factory.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the writing.
static T & Instance()
Definition: singleton.h:432
Inline task to erase a named mg space.
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Object buffer.
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Object buffer.
void delete_subspace(const std::string SubspaceID)
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::InlineEraseQUDAMULTIGRIDSpaceEnv::Params::NamedObject_t named_obj
void writeXML(XMLWriter &xml_out, const std::string &path)