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