SST  10.0.0
StructuralSimulationToolkit
statoutputtxt.h
1 // Copyright 2009-2020 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-2020, 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_OUTPUTTXT
13 #define _H_SST_CORE_STATISTICS_OUTPUTTXT
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 StatisticOutputTxt
28 
29  The class for statistics output to a text file.
30 */
32 {
33 public:
37  "sst",
38  "statoutputtxt",
39  SST_ELI_ELEMENT_VERSION(1,0,0),
40  "Output directly to console screen"
41  )
42 
43  /** Construct a StatOutputTxt
44  * @param outputParameters - Parameters used for this Statistic Output
45  */
46  StatisticOutputTxt(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  StatisticOutputTxt() {;} // 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::string m_outputBuffer;
109  std::string m_FilePath;
110  bool m_outputTopHeader;
111  bool m_outputInlineHeader;
112  bool m_outputSimTime;
113  bool m_outputRank;
114  bool m_useCompression;
115 
116 };
117 
118 } //namespace Statistics
119 } //namespace SST
120 
121 #endif
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputtxt.cc:84
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputtxt.cc:151
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:64
bool checkOutputParameters() override
Perform a check of provided parameters.
Definition: statoutputtxt.cc:32
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputtxt.cc:145
The class for statistics output to a text file.
Definition: statoutputtxt.h:31
void outputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
Definition: statoutputtxt.cc:193
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputtxt.cc:187
Definition: statoutput.h:144
void printUsage() override
Print out usage for this Statistic Output.
Definition: statoutputtxt.cc:70
Parameter store.
Definition: params.h:44
SST_ELI_REGISTER_DERIVED(StatisticOutput, StatisticOutputTxt,"sst","statoutputtxt", SST_ELI_ELEMENT_VERSION(1, 0, 0),"Output directly to console screen") StatisticOutputTxt(Params &outputParameters)
Construct a StatOutputTxt.