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