Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_XMLPerfTestArchive.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_XMLPERFTESTARCHIVE_HPP
11 #define TEUCHOS_XMLPERFTESTARCHIVE_HPP
12 
15 
16 #include <Teuchos_ConfigDefs.hpp>
18 #include <Teuchos_XMLObject.hpp>
19 #include <sstream>
20 
21 //----------------------------------------------------------------------------
22 //-------- Identify Compiler Version -----------------------------------------
23 //----------------------------------------------------------------------------
24 
25 #if defined __ECC || defined __ICC || defined __INTEL_COMPILER
26  #define TEUCHOS_COMPILER_NAME "Intel C++"
27  #if defined __ICC
28  #define TEUCHOS_COMPILER_VERSION __ICC
29  #else
30  #if defined __INTEL_COMPILER
31  #define TEUCHOS_COMPILER_VERSION __INTEL_COMPILER
32  #else
33  #define TEUCHOS_COMPILER_VERSION __ECC
34  #endif
35  #endif
36  #define TEUCHOS_COMPILER_INTEL 1
37 #endif
38 
39 #if defined __IBMC__ || defined __IBMCPP__
40  #define TEUCHOS_COMPILER_NAME "IBM C++"
41  #if defined __IBMC__
42  #define TEUCHOS_COMPILER_VERSION __IBMC__
43  #else
44  #define TEUCHOS_COMPILER_VERSION __IBMCPP__
45  #endif
46  #define TEUCHOS_COMPILER_IBM 1
47 #endif
48 
49 #if defined __APPLE_CC__
50  /* Apple uses GNU as compiler */
51  #define TEUCHOS_COMPILER_APPLECC 1
52 #endif
53 
54 #if defined __clang__
55  #define TEUCHOS_COMPILER_NAME "Clang"
56  #define TEUCHOS_COMPILER_VERSION __clang_major__*100+__clang_minor__*10+__clang_patchlevel__
57  #define TEUCHOS_COMPILER_CLANG 1
58 #endif
59 
60 #if defined __GNUC__ && !defined TEUCHOS_COMPILER_NAME && !defined __clang__
61  #define TEUCHOS_COMPILER_NAME "Gnu GCC"
62  #define TEUCHOS_COMPILER_VERSION __GNUC__*100+__GNUC_MINOR__*10+__GNUC_PATCHLEVEL__
63  #define TEUCHOS_COMPILER_GCC 1
64 #endif
65 
66 #if defined __PGIC__ && !defined TEUCHOS_COMPILER_NAME
67  #define TEUCHOS_COMPILER_NAME "PGI C++"
68  #define TEUCHOS_COMPILER_VERSION __PGIC__*100+__PGIC_MINOR__*10+__PGIC_PATCHLEVEL__
69  #define TEUCHOS_COMPILER_PGI 1
70 #endif
71 
72 #if defined __NVCC__
73  #define TEUCHOS_DEVICE_COMPILER_NAME "NVIDIA NVCC"
74  #define TEUCHOS_DEVICE_COMPILER_VERSION __NVCC__
75 #endif
76 
77 #if !defined TEUCHOS_COMPILER_NAME
78  #define TEUCHOS_COMPILER_NAME "Unknown compiler"
79 #endif
80 
81 #if !defined TEUCHOS_COMPILER_VERSION
82  #define TEUCHOS_COMPILER_VERSION 0
83 #endif
84 
85 #if !defined TEUCHOS_DEVICE_COMPILER_NAME
86  #define TEUCHOS_DEVICE_COMPILER_NAME TEUCHOS_COMPILER_NAME
87 #endif
88 
89 #if !defined TEUCHOS_DEVICE_COMPILER_VERSION
90  #define TEUCHOS_DEVICE_COMPILER_VERSION TEUCHOS_COMPILER_VERSION
91 #endif
92 
93 namespace Teuchos {
100  double value;
101  double lower;
102  double upper;
103  double tolerance;
104  bool use_tolerance;
105 
106  ValueTolerance();
107  ValueTolerance(double val, double tol);
108  ValueTolerance(double val, double low, double up);
109 
110  ValueTolerance(std::string str);
111 
112  bool operator ==(ValueTolerance& rhs);
113 
114  std::string as_string();
115  void from_string(const std::string& valtol_str);
116 };
117 
118 
127 class XMLTestNode : public XMLObject {
128 public:
129  XMLTestNode();
130  XMLTestNode(const std::string &tag);
132  XMLTestNode(XMLObject obj);
133  void addDouble (const std::string& name, double val);
134  void addInt (const std::string& name, int val);
135  void addBool (const std::string& name, bool val);
136  void addValueTolerance(const std::string& name, ValueTolerance val);
137  void addString (const std::string& name, std::string val);
138 
139  template<class T>
140  void addAttribute (const std::string& name, T val) {
141  for (size_t i = 0; i < name.length (); i++) {
142  if (name[i] == ' ') {
143  return;
144  }
145  }
146  std::ostringstream strs;
147  strs << val;
148  XMLTestNode entry (name);
149  entry.addContent (strs.str ());
150  XMLObject::addChild (entry);
151  }
152 
153  bool hasChild(const std::string &name) const;
154 
155  void appendContentLine(const size_t& i, const std::string &str);
156 
157  XMLTestNode getChild(const std::string &name) const;
158 
159  XMLTestNode getChild(const int &i) const;
160 
161  const XMLObject* xml_object() const;
162 
163  bool hasSameElements(XMLTestNode const & lhs) const;
164 };
165 
183 
187 enum PerfTestResult {PerfTestFailed, PerfTestPassed,
188  PerfTestNewMachine, PerfTestNewConfiguration,
189  PerfTestNewTest, PerfTestNewTestConfiguration,
190  PerfTestUpdatedTest};
191 
239 PerfTest_CheckOrAdd_Test (XMLTestNode machine_config,
240  XMLTestNode new_test,
241  const std::string filename,
242  const std::string ext_hostname = std::string ());
243 
244 } // namespace Teuchos
245 
246 #endif
void addChild(const XMLObject &child)
Add a child node to the node.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
ValueTolerance is a struct to keep a tuple of value and a tolerance. The tolerance can be either expr...
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
PerfTestResult
ReturnValues for PerfTest_CheckOrAdd_Test.
Subclass of XMLObject used by the performance archive.
void addContent(const std::string &contentLine)
Add a line of character content.
The XMLObjectImplem class takes care of the low-level implementation details of XMLObject.
Definition of XMLInputSource derived class for reading XML from a file.
PerfTestResult PerfTest_CheckOrAdd_Test(XMLTestNode machine_config, XMLTestNode new_test, const std::string filename, const std::string ext_hostname)
Check whether a test is present and match an existing test in an archive.
XMLTestNode PerfTest_MachineConfig()
PerfTest_MachineConfig generates a basic machine configuration XMLTestNode.
An object representation of a subset of XML data.