SST  15.1.0
StructuralSimulationToolkit
timingOutput.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_TIMING_OUTPUT_H
13 #define SST_CORE_TIMING_OUTPUT_H
14 
15 #include "sst/core/output.h"
16 #include "sst/core/unitAlgebra.h"
17 #include "sst/core/util/filesystem.h"
18 
19 #include <cstdint>
20 #include <cstdio>
21 #include <map>
22 #include <string>
23 
24 namespace SST::Core {
25 
26 /**
27  * Outputs configuration data to a specified file path.
28  */
30 {
31 public:
32  /** Timing Parameters
33  */
34  enum Key {
35  LOCAL_MAX_RSS, // Max Resident Set Size (kB)
36  GLOBAL_MAX_RSS, // Approx. Global Max RSS Size (kB)
37  LOCAL_MAX_PF, // Max Local Page Faults
38  GLOBAL_PF, // Global Page Faults
39  GLOBAL_MAX_IO_IN, // Max Output Blocks
40  GLOBAL_MAX_IO_OUT, // Max Input Blocks
41  GLOBAL_MAX_SYNC_DATA_SIZE, // Max Sync data size
42  GLOBAL_SYNC_DATA_SIZE, // Global Sync data size
43  MAX_MEMPOOL_SIZE, // Max mempool usage (bytes)
44  GLOBAL_MEMPOOL_SIZE, // Global mempool usage (bytes)
45  MAX_BUILD_TIME, // Build time (wallclock seconds)
46  MAX_RUN_TIME, // Run loop time (wallclock seconds)
47  MAX_TOTAL_TIME, // Total time (wallclock seconds)
48  SIMULATED_TIME_UA, // Simulated time ( Algebra seconds string. eg. "10 us" )
49  GLOBAL_ACTIVE_ACTIVITIES, // Global active activities
50  GLOBAL_CURRENT_TV_DEPTH, // Current global TimeVortex depth
51  GLOBAL_MAX_TV_DEPTH, // Max TimeVortex depth
52  RANKS, // MPI ranks
53  THREADS, // Threads
54  };
55 
56  const std::map<Key, const char*> key2cstr = {
57  { LOCAL_MAX_RSS, "local_max_rss" },
58  { GLOBAL_MAX_RSS, "global_max_rss" },
59  { LOCAL_MAX_PF, "local_max_pf" },
60  { GLOBAL_PF, "global_pf" },
61  { GLOBAL_MAX_IO_IN, "global_max_io_in" },
62  { GLOBAL_MAX_IO_OUT, "global_max_io_out" },
63  { GLOBAL_MAX_SYNC_DATA_SIZE, "global_max_sync_data_size" },
64  { GLOBAL_SYNC_DATA_SIZE, "global_sync_data_size" },
65  { MAX_MEMPOOL_SIZE, "max_mempool_size" },
66  { GLOBAL_MEMPOOL_SIZE, "global_mempool_size" },
67  { MAX_BUILD_TIME, "max_build_time" },
68  { MAX_RUN_TIME, "max_run_time" },
69  { MAX_TOTAL_TIME, "max_total_time" },
70  { SIMULATED_TIME_UA, "simulated_time_ua" },
71  { GLOBAL_ACTIVE_ACTIVITIES, "global_active_activities" },
72  { GLOBAL_CURRENT_TV_DEPTH, "global_current_tv_depth" },
73  { GLOBAL_MAX_TV_DEPTH, "global_max_tv_depth" },
74  { RANKS, "ranks" },
75  { THREADS, "threads" },
76  };
77 
78  TimingOutput(const SST::Output& output, int print_verbosity);
79  virtual ~TimingOutput();
80  void setJSON(const std::string& path);
81  void generate();
82  void renderText();
83  void renderJSON();
84 
85  void set(Key key, uint64_t v);
86  void set(Key key, UnitAlgebra v);
87  void set(Key key, double v);
88 
89 private:
90  SST::Output output_;
91  int print_verbosity_;
92  bool jsonEnable_;
93 
94  std::map<Key, uint64_t> u64map_ = {};
95  std::map<Key, UnitAlgebra> uamap_ = {};
96  std::map<Key, double> dmap_ = {};
97  FILE* outputFile = nullptr;
98 };
99 
100 } // namespace SST::Core
101 
102 #endif // SST_CORE_TIMING_OUTPUT_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:57
Key
Timing Parameters.
Definition: timingOutput.h:34
Outputs configuration data to a specified file path.
Definition: timingOutput.h:29