SST  15.1.0
StructuralSimulationToolkit
sst_types.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_SST_TYPES_H
13 #define SST_CORE_SST_TYPES_H
14 
15 #include <cstdint>
16 #include <iosfwd>
17 #include <limits>
18 #include <ostream>
19 #include <utility>
20 
21 namespace SST {
22 
23 using ComponentId_t = uint64_t;
24 using StatisticId_t = uint64_t;
25 using LinkId_t = uint32_t;
26 using HandlerId_t = uint64_t;
27 using Cycle_t = uint64_t;
28 using SimTime_t = uint64_t;
29 using Time_t = double;
30 /* PorModuleId_t is a <port name,index> pair*/
31 using PortModuleId_t = std::pair<std::string, size_t>;
32 
33 #define PRI_SIMTIME PRIu64
34 
35 static constexpr StatisticId_t STATALL_ID = std::numeric_limits<StatisticId_t>::max();
36 
37 #define MAX_SIMTIME_T 0xFFFFFFFFFFFFFFFFl
38 
39 /* Subcomponent IDs are in the high-16 bits of the Component ID */
40 #define UNSET_COMPONENT_ID 0xFFFFFFFFFFFFFFFFULL
41 #define UNSET_STATISTIC_ID 0xFFFFFFFFFFFFFFFFULL
42 #define COMPONENT_ID_BITS 32
43 #define COMPONENT_ID_MASK(x) ((x) & 0xFFFFFFFFULL)
44 #define SUBCOMPONENT_ID_BITS 16
45 #define SUBCOMPONENT_ID_MASK(x) ((x) >> COMPONENT_ID_BITS)
46 #define SUBCOMPONENT_ID_CREATE(compId, sCompId) ((((uint64_t)sCompId) << COMPONENT_ID_BITS) | compId)
47 #define CONFIG_COMPONENT_ID_BITS (COMPONENT_ID_BITS + SUBCOMPONENT_ID_BITS)
48 #define CONFIG_COMPONENT_ID_MASK(x) ((x) & 0xFFFFFFFFFFFFULL)
49 #define STATISTIC_ID_CREATE(compId, statId) ((((uint64_t)statId) << CONFIG_COMPONENT_ID_BITS) | compId)
50 #define COMPDEFINED_SUBCOMPONENT_ID_MASK(x) ((x) >> 63)
51 #define COMPDEFINED_SUBCOMPONENT_ID_CREATE(compId, sCompId) \
52  ((((uint64_t)sCompId) << COMPONENT_ID_BITS) | compId | 0x8000000000000000ULL)
53 
54 using watts = double;
55 using joules = double;
56 using farads = double;
57 using volts = double;
58 
59 #ifndef LIKELY
60 #define LIKELY(x) __builtin_expect((int)(x), 1)
61 #define UNLIKELY(x) __builtin_expect((int)(x), 0)
62 #endif
63 
64 enum class SimulationRunMode {
65  UNKNOWN, /*!< Unknown mode - Invalid for running */
66  INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */
67  RUN, /*!< Run-only. Useful when restoring from a checkpoint (not currently supported) */
68  BOTH /*!< Default. Both initialize and Run the simulation */
69 };
70 
71 // Overload the << operator for SimulationRunMode
72 std::ostream& operator<<(std::ostream& os, const SimulationRunMode& mode);
73 
74 /**
75  Struct used as a base class for all AttachPoint metadata passed to
76  registration functions. Needed so that dynamic cast can be used
77  since different tools may pass different metadata through the
78  AttachPoints.
79  */
81 {
83  virtual ~AttachPointMetaData() {}
84 };
85 
86 } // namespace SST
87 
88 #endif // SST_CORE_SST_TYPES_H
Definition: action.cc:18
Struct used as a base class for all AttachPoint metadata passed to registration functions.
Definition: sst_types.h:80