|
| 1 | + |
| 2 | +//@HEADER |
| 3 | +// *************************************************** |
| 4 | +// |
| 5 | +// HPCG: High Performance Conjugate Gradient Benchmark |
| 6 | +// |
| 7 | +// Contact: |
| 8 | +// Michael A. Heroux ( [email protected]) |
| 9 | +// Jack Dongarra ([email protected]) |
| 10 | +// Piotr Luszczek ([email protected]) |
| 11 | +// |
| 12 | +// *************************************************** |
| 13 | +//@HEADER |
| 14 | + |
| 15 | +/*! |
| 16 | + @file Output_File.hpp |
| 17 | +
|
| 18 | + HPCG output file classes |
| 19 | + */ |
| 20 | + |
| 21 | +#ifndef OUTPUTFILE_HPP |
| 22 | +#define OUTPUTFILE_HPP |
| 23 | + |
| 24 | +#include <list> |
| 25 | +#include <string> |
| 26 | + |
| 27 | +//! The OutputFile class for the uniform collecting and reporting of performance data for HPCG |
| 28 | + |
| 29 | +/*! |
| 30 | +
|
| 31 | + The OutputFile class facilitates easy collecting and reporting of |
| 32 | + key-value-formatted data that can be then registered with the HPCG results |
| 33 | + collection website. The keys may have hierarchy key1::key2::key3=val with |
| 34 | + double colon :: as a seperator. A sample output may look like this (note how |
| 35 | + "major" and "micro" keys repeat with different ancestor keys): |
| 36 | +
|
| 37 | +\code |
| 38 | +
|
| 39 | +version=3.2.1alpha |
| 40 | +version::major=3 |
| 41 | +version::minor=2 |
| 42 | +version::micro=1 |
| 43 | +version::release=alpha |
| 44 | +axis=xyz |
| 45 | +axis::major=x |
| 46 | +axis::minor=y |
| 47 | +
|
| 48 | +\endcode |
| 49 | +
|
| 50 | +*/ |
| 51 | +class OutputFile { |
| 52 | +protected: |
| 53 | + std::list<OutputFile *> descendants; //!< descendant elements |
| 54 | + std::string name; //!< name of the benchmark |
| 55 | + std::string version; //!< version of the benchmark |
| 56 | + std::string key; //!< the key under which the element is stored |
| 57 | + std::string value; //!< the value of the stored element |
| 58 | + std::string eol = "\n"; //!< end-of-line character sequence in the output file |
| 59 | + std::string keySeparator = "::"; //!< character sequence to seperate keys in the output file |
| 60 | + |
| 61 | + //! Recursively generate output string from descendent list, and their descendendents and so on |
| 62 | + std::string generateRecursive(std::string prefix); |
| 63 | + |
| 64 | +public: |
| 65 | + static OutputFile * allocKeyVal(const std::string & key, const std::string & value); |
| 66 | + |
| 67 | + //! Constructor: accepts name and version as strings that are used to create a file name for printing results. |
| 68 | + /*! |
| 69 | + This constructor accepts and name and version number for the benchmark that |
| 70 | + are used to form a file name information for results that are generated by |
| 71 | + the generate() method. |
| 72 | + \param name (in) string containing name of the benchmark |
| 73 | + \param version (in) string containing the version of the benchmark |
| 74 | + */ |
| 75 | + OutputFile(const std::string & name, const std::string & version); |
| 76 | + |
| 77 | + //! Default constructor: no-arguments accepted, should be used for descendant nodes |
| 78 | + /*! |
| 79 | + This no-argument constructor can be used for leaf nodes to provide |
| 80 | + key1::key2::key3=val output. |
| 81 | + */ |
| 82 | + OutputFile(void); |
| 83 | + |
| 84 | + //! Create and add a descendant element with value of type "string" |
| 85 | + /*! |
| 86 | + Create and add a descendant element identified by "key" and associated with |
| 87 | + "value". The element is added at the end of a list of previously added |
| 88 | + elements. |
| 89 | +
|
| 90 | + @param[in] key The key that identifies the added element and under which the element is stored |
| 91 | + @param[in] value The value stored by the element |
| 92 | + */ |
| 93 | + void add(const std::string & key, const std::string & value); |
| 94 | + |
| 95 | + //! Create and add a descendant element with value of type "double" |
| 96 | + /*! |
| 97 | + Create and add a descendant element identified by "key" and associated with |
| 98 | + "value". The element is added at the end of a list of previously added |
| 99 | + elements. |
| 100 | +
|
| 101 | + @param[in] key The key that identifies the added element and under which the element is stored |
| 102 | + @param[in] value The value stored by the element |
| 103 | + */ |
| 104 | + void add(const std::string & key, double value); |
| 105 | + |
| 106 | + //! Create and add a descendant element with value of type "int" |
| 107 | + /*! |
| 108 | + Create and add a descendant element identified by "key" and associated with |
| 109 | + "value". The element is added at the end of a list of previously added |
| 110 | + elements. |
| 111 | +
|
| 112 | + @param[in] key The key that identifies the added element and under which the element is stored |
| 113 | + @param[in] value The value stored by the element |
| 114 | + */ |
| 115 | + void add(const std::string & key, int value); |
| 116 | + |
| 117 | +#ifndef HPCG_NO_LONG_LONG |
| 118 | + //! Create and add a descendant element with value of type "long long" |
| 119 | + /*! |
| 120 | + Create and add a descendant element identified by "key" and associated with |
| 121 | + "value". The element is added at the end of a list of previously added |
| 122 | + elements. |
| 123 | +
|
| 124 | + @param[in] key The key that identifies the added element and under which the element is stored |
| 125 | + @param[in] value The value stored by the element |
| 126 | + */ |
| 127 | + void add(const std::string & key, long long value); |
| 128 | +#endif |
| 129 | + |
| 130 | + //! Create and add a descendant element with value of type "size_t" |
| 131 | + /*! |
| 132 | + Create and add a descendant element identified by "key" and associated with |
| 133 | + "value". The element is added at the end of a list of previously added |
| 134 | + elements. |
| 135 | +
|
| 136 | + @param[in] key The key that identifies the added element and under which the element is stored |
| 137 | + @param[in] value The value stored by the element |
| 138 | + */ |
| 139 | + void add(const std::string & key, size_t value); |
| 140 | + |
| 141 | + //! Key-Value setter method |
| 142 | + /*! |
| 143 | + Set the key and the value of this element. |
| 144 | +
|
| 145 | + @param[in] key The key that identifies this element and under which the element is stored |
| 146 | + @param[in] value The value stored by the element |
| 147 | + */ |
| 148 | + void setKeyValue(const std::string & key, const std::string & value); |
| 149 | + |
| 150 | + //! Get the element in the list with the given key or return NULL if not found |
| 151 | + OutputFile * get(const std::string & key); |
| 152 | + |
| 153 | + //! Generate output string with results based on the stored key-value hierarchy |
| 154 | + std::string generate(void); |
| 155 | +}; |
| 156 | + |
| 157 | +#endif // OUTPUTFILE_HPP |
0 commit comments