SST  7.2.0
StructuralSimulationToolkit
statoutputcsv.h
1 // Copyright 2009-2017 Sandia Corporation. Under the terms
2 // of Contract DE-NA0003525 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2017, Sandia Corporation
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef _H_SST_CORE_STATISTICS_OUTPUTCSV
13 #define _H_SST_CORE_STATISTICS_OUTPUTCSV
14 
15 #include "sst/core/sst_types.h"
16 
17 #include <sst/core/statapi/statoutput.h>
18 
19 #ifdef HAVE_LIBZ
20 #include <zlib.h>
21 #endif
22 
23 namespace SST {
24 namespace Statistics {
25 
26 /**
27  \class StatisticOutputCSV
28 
29  The class for statistics output to a comma separated file.
30 */
32 {
33 public:
34  /** Construct a StatOutputCSV
35  * @param outputParameters - Parameters used for this Statistic Output
36  */
37  StatisticOutputCSV(Params& outputParameters, bool compressed);
38 
39 protected:
40  /** Perform a check of provided parameters
41  * @return True if all required parameters and options are acceptable
42  */
43  bool checkOutputParameters() override;
44 
45  /** Print out usage for this Statistic Output */
46  void printUsage() override;
47 
48  /** Indicate to Statistic Output that simulation started.
49  * Statistic output may perform any startup code here as necessary.
50  */
51  void startOfSimulation() override;
52 
53  /** Indicate to Statistic Output that simulation ended.
54  * Statistic output may perform any shutdown code here as necessary.
55  */
56  void endOfSimulation() override;
57 
58  /** Implementation function for the start of output.
59  * This will be called by the Statistic Processing Engine to indicate that
60  * a Statistic is about to send data to the Statistic Output for processing.
61  * @param statistic - Pointer to the statistic object than the output can
62  * retrieve data from.
63  */
64  void implStartOutputEntries(StatisticBase* statistic) override;
65 
66  /** Implementation function for the end of output.
67  * This will be called by the Statistic Processing Engine to indicate that
68  * a Statistic is finished sendind data to the Statistic Output for processing.
69  * The Statisic Output can perform any output related functions here.
70  */
71  void implStopOutputEntries() override;
72 
73  /** Implementation functions for output.
74  * These will be called by the statistic to provide Statistic defined
75  * data to be output.
76  * @param fieldHandle - The handle to the registered statistic field.
77  * @param data - The data related to the registered field to be output.
78  */
79  void implOutputField(fieldHandle_t fieldHandle, int32_t data) override;
80  void implOutputField(fieldHandle_t fieldHandle, uint32_t data) override;
81  void implOutputField(fieldHandle_t fieldHandle, int64_t data) override;
82  void implOutputField(fieldHandle_t fieldHandle, uint64_t data) override;
83  void implOutputField(fieldHandle_t fieldHandle, float data) override;
84  void implOutputField(fieldHandle_t fieldHandle, double data) override;
85 
86 protected:
87  StatisticOutputCSV() {;} // For serialization
88 
89 private:
90  bool openFile();
91  void closeFile();
92  int print(const char* fmt, ...);
93 
94 private:
95 #ifdef HAVE_LIBZ
96  gzFile m_gzFile;
97 #endif
98  FILE* m_hFile;
99  std::vector<std::string> m_OutputBufferArray;
100  std::string m_Separator;
101  std::string m_FilePath;
102  std::string m_currentComponentName;
103  std::string m_currentStatisticName;
104  std::string m_currentStatisticSubId;
105  std::string m_currentStatisticType;
106  bool m_outputTopHeader;
107  bool m_outputSimTime;
108  bool m_outputRank;
109  bool m_useCompression;
110 
111 };
112 
113 } //namespace Statistics
114 } //namespace SST
115 
116 #endif
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputcsv.cc:174
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:47
Forms the base class for statistics gathering within SST.
Definition: statbase.h:61
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputcsv.cc:168
Definition: action.cc:17
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputcsv.cc:83
The class for statistics output to a comma separated file.
Definition: statoutputcsv.h:31
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputcsv.cc:189
bool checkOutputParameters() override
Perform a check of provided parameters.
Definition: statoutputcsv.cc:30
void printUsage() override
Print out usage for this Statistic Output.
Definition: statoutputcsv.cc:69
void implOutputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
Definition: statoutputcsv.cc:228
Parameter store.
Definition: params.h:45