SST  14.1.0
StructuralSimulationToolkit
statoutputcsv.h
1 // Copyright 2009-2024 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-2024, 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  void serialize_order(SST::Core::Serialization::serializer& ser) override;
48  ImplementSerializable(SST::Statistics::StatisticOutputCSV)
49 protected:
50  /** Perform a check of provided parameters
51  * @return True if all required parameters and options are acceptable
52  */
53  bool checkOutputParameters() override;
54 
55  /** Print out usage for this Statistic Output */
56  void printUsage() override;
57 
58  /** Indicate to Statistic Output that simulation started.
59  * Statistic output may perform any startup code here as necessary.
60  */
61  void startOfSimulation() override;
62 
63  /** Indicate to Statistic Output that simulation ended.
64  * Statistic output may perform any shutdown code here as necessary.
65  */
66  void endOfSimulation() override;
67 
68  /** Implementation function for the start of output.
69  * This will be called by the Statistic Processing Engine to indicate that
70  * a Statistic is about to send data to the Statistic Output for processing.
71  * @param statistic - Pointer to the statistic object than the output can
72  * retrieve data from.
73  */
74  void implStartOutputEntries(StatisticBase* statistic) override;
75 
76  /** Implementation function for the end of output.
77  * This will be called by the Statistic Processing Engine to indicate that
78  * a Statistic is finished sending data to the Statistic Output for processing.
79  * The Statistic Output can perform any output related functions here.
80  */
81  void implStopOutputEntries() override;
82 
83  /** Implementation functions for output.
84  * These will be called by the statistic to provide Statistic defined
85  * data to be output.
86  * @param fieldHandle - The handle to the registered statistic field.
87  * @param data - The data related to the registered field to be output.
88  */
89  void outputField(fieldHandle_t fieldHandle, int32_t data) override;
90  void outputField(fieldHandle_t fieldHandle, uint32_t data) override;
91  void outputField(fieldHandle_t fieldHandle, int64_t data) override;
92  void outputField(fieldHandle_t fieldHandle, uint64_t data) override;
93  void outputField(fieldHandle_t fieldHandle, float data) override;
94  void outputField(fieldHandle_t fieldHandle, double data) override;
95 
96  /** True if this StatOutput can handle StatisticGroups */
97  virtual bool acceptsGroups() const override { return true; }
98 
99 protected:
100  StatisticOutputCSV() { ; } // For serialization
101 
102 private:
103  bool openFile();
104  void closeFile();
105  int print(const char* fmt, ...);
106 
107 private:
108 #ifdef HAVE_LIBZ
109  gzFile m_gzFile;
110 #endif
111  FILE* m_hFile;
112  std::vector<std::string> m_OutputBufferArray;
113  std::string m_Separator;
114  std::string m_FilePath;
115  std::string m_currentComponentName;
116  std::string m_currentStatisticName;
117  std::string m_currentStatisticSubId;
118  std::string m_currentStatisticType;
119  bool m_outputTopHeader;
120  bool m_outputSimTime;
121  bool m_outputRank;
122  bool m_useCompression;
123 };
124 
125 } // namespace Statistics
126 } // namespace SST
127 
128 #endif // SST_CORE_STATAPI_STATOUTPUTCSV_H
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputcsv.cc:169
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:50
Forms the base class for statistics gathering within SST.
Definition: statbase.h:45
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputcsv.cc:162
Definition: action.cc:18
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputcsv.cc:78
The class for statistics output to a comma separated file.
Definition: statoutputcsv.h:30
virtual bool checkOutputParameters()=0
Have the Statistic Output check its parameters.
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputcsv.cc:185
virtual bool acceptsGroups() const override
True if this StatOutput can handle StatisticGroups.
Definition: statoutputcsv.h:97
Definition: statoutput.h:162
ImplementSerializable(SST::Statistics::StatisticOutputCSV) protected void printUsage() override
Perform a check of provided parameters.
Definition: statoutputcsv.cc:63
Parameter store.
Definition: params.h:55
void outputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
Definition: statoutputcsv.cc:223
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.