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 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TEUCHOS_XMLPERFTESTARCHIVE_HPP
43 #define TEUCHOS_XMLPERFTESTARCHIVE_HPP
44 
47 
48 #include <Teuchos_ConfigDefs.hpp>
50 #include <Teuchos_XMLObject.hpp>
51 #include <sstream>
52 
53 //----------------------------------------------------------------------------
54 //-------- Identify Compiler Version -----------------------------------------
55 //----------------------------------------------------------------------------
56 
57 #if defined __ECC || defined __ICC || defined __INTEL_COMPILER
58  #define TEUCHOS_COMPILER_NAME "Intel C++"
59  #if defined __ICC
60  #define TEUCHOS_COMPILER_VERSION __ICC
61  #else
62  #if defined __INTEL_COMPILER
63  #define TEUCHOS_COMPILER_VERSION __INTEL_COMPILER
64  #else
65  #define TEUCHOS_COMPILER_VERSION __ECC
66  #endif
67  #endif
68  #define TEUCHOS_COMPILER_INTEL 1
69 #endif
70 
71 #if defined __IBMC__ || defined __IBMCPP__
72  #define TEUCHOS_COMPILER_NAME "IBM C++"
73  #if defined __IBMC__
74  #define TEUCHOS_COMPILER_VERSION __IBMC__
75  #else
76  #define TEUCHOS_COMPILER_VERSION __IBMCPP__
77  #endif
78  #define TEUCHOS_COMPILER_IBM 1
79 #endif
80 
81 #if defined __APPLE_CC__
82  /* Apple uses GNU as compiler */
83  #define TEUCHOS_COMPILER_APPLECC 1
84 #endif
85 
86 #if defined __clang__
87  #define TEUCHOS_COMPILER_NAME "Clang"
88  #define TEUCHOS_COMPILER_VERSION __clang_major__*100+__clang_minor__*10+__clang_patchlevel__
89  #define TEUCHOS_COMPILER_CLANG 1
90 #endif
91 
92 #if defined __GNUC__ && !defined TEUCHOS_COMPILER_NAME && !defined __clang__
93  #define TEUCHOS_COMPILER_NAME "Gnu GCC"
94  #define TEUCHOS_COMPILER_VERSION __GNUC__*100+__GNUC_MINOR__*10+__GNUC_PATCHLEVEL__
95  #define TEUCHOS_COMPILER_GCC 1
96 #endif
97 
98 #if defined __PGIC__ && !defined TEUCHOS_COMPILER_NAME
99  #define TEUCHOS_COMPILER_NAME "PGI C++"
100  #define TEUCHOS_COMPILER_VERSION __PGIC__*100+__PGIC_MINOR__*10+__PGIC_PATCHLEVEL__
101  #define TEUCHOS_COMPILER_PGI 1
102 #endif
103 
104 #if defined __NVCC__
105  #define TEUCHOS_DEVICE_COMPILER_NAME "NVIDIA NVCC"
106  #define TEUCHOS_DEVICE_COMPILER_VERSION __NVCC__
107 #endif
108 
109 #if !defined TEUCHOS_COMPILER_NAME
110  #define TEUCHOS_COMPILER_NAME "Unknown compiler"
111 #endif
112 
113 #if !defined TEUCHOS_COMPILER_VERSION
114  #define TEUCHOS_COMPILER_VERSION 0
115 #endif
116 
117 #if !defined TEUCHOS_DEVICE_COMPILER_NAME
118  #define TEUCHOS_DEVICE_COMPILER_NAME TEUCHOS_COMPILER_NAME
119 #endif
120 
121 #if !defined TEUCHOS_DEVICE_COMPILER_VERSION
122  #define TEUCHOS_DEVICE_COMPILER_VERSION TEUCHOS_COMPILER_VERSION
123 #endif
124 
125 namespace Teuchos {
132  double value;
133  double lower;
134  double upper;
135  double tolerance;
136  bool use_tolerance;
137 
138  ValueTolerance();
139  ValueTolerance(double val, double tol);
140  ValueTolerance(double val, double low, double up);
141 
142  ValueTolerance(std::string str);
143 
144  bool operator ==(ValueTolerance& rhs);
145 
146  std::string as_string();
147  void from_string(const std::string& valtol_str);
148 };
149 
150 
159 class XMLTestNode : public XMLObject {
160 public:
161  XMLTestNode();
162  XMLTestNode(const std::string &tag);
164  XMLTestNode(XMLObject obj);
165  void addDouble (const std::string& name, double val);
166  void addInt (const std::string& name, int val);
167  void addBool (const std::string& name, bool val);
168  void addValueTolerance(const std::string& name, ValueTolerance val);
169  void addString (const std::string& name, std::string val);
170 
171  template<class T>
172  void addAttribute (const std::string& name, T val) {
173  for (size_t i = 0; i < name.length (); i++) {
174  if (name[i] == ' ') {
175  return;
176  }
177  }
178  std::ostringstream strs;
179  strs << val;
180  XMLTestNode entry (name);
181  entry.addContent (strs.str ());
182  XMLObject::addChild (entry);
183  }
184 
185  bool hasChild(const std::string &name) const;
186 
187  void appendContentLine(const size_t& i, const std::string &str);
188 
189  XMLTestNode getChild(const std::string &name) const;
190 
191  XMLTestNode getChild(const int &i) const;
192 
193  const XMLObject* xml_object() const;
194 
195  bool hasSameElements(XMLTestNode const & lhs) const;
196 };
197 
215 
219 enum PerfTestResult {PerfTestFailed, PerfTestPassed,
220  PerfTestNewMachine, PerfTestNewConfiguration,
221  PerfTestNewTest, PerfTestNewTestConfiguration,
222  PerfTestUpdatedTest};
223 
271 PerfTest_CheckOrAdd_Test (XMLTestNode machine_config,
272  XMLTestNode new_test,
273  const std::string filename,
274  const std::string ext_hostname = std::string ());
275 
276 } // namespace Teuchos
277 
278 #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.