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