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