SST  12.0.0
StructuralSimulationToolkit
sst_types.h
1 // Copyright 2009-2022 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-2022, 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 
18 namespace SST {
19 
20 typedef uint64_t ComponentId_t;
21 typedef uint64_t StatisticId_t;
22 typedef uint32_t LinkId_t;
23 typedef uint32_t HandlerId_t;
24 typedef uint64_t Cycle_t;
25 typedef uint64_t SimTime_t;
26 typedef double Time_t;
27 
28 static constexpr StatisticId_t STATALL_ID = std::numeric_limits<StatisticId_t>::max();
29 
30 #define MAX_SIMTIME_T 0xFFFFFFFFFFFFFFFFl
31 
32 /* Subcomponent IDs are in the high-16 bits of the Component ID */
33 #define UNSET_COMPONENT_ID 0xFFFFFFFFFFFFFFFFULL
34 #define UNSET_STATISTIC_ID 0xFFFFFFFFFFFFFFFFULL
35 #define COMPONENT_ID_BITS 32
36 #define COMPONENT_ID_MASK(x) ((x)&0xFFFFFFFFULL)
37 #define SUBCOMPONENT_ID_BITS 16
38 #define SUBCOMPONENT_ID_MASK(x) ((x) >> COMPONENT_ID_BITS)
39 #define SUBCOMPONENT_ID_CREATE(compId, sCompId) ((((uint64_t)sCompId) << COMPONENT_ID_BITS) | compId)
40 #define CONFIG_COMPONENT_ID_BITS (COMPONENT_ID_BITS + SUBCOMPONENT_ID_BITS)
41 #define CONFIG_COMPONENT_ID_MASK(x) ((x)&0xFFFFFFFFFFFFULL)
42 #define STATISTIC_ID_CREATE(compId, statId) ((((uint64_t)statId) << CONFIG_COMPONENT_ID_BITS) | compId)
43 #define COMPDEFINED_SUBCOMPONENT_ID_MASK(x) ((x) >> 63)
44 #define COMPDEFINED_SUBCOMPONENT_ID_CREATE(compId, sCompId) \
45  ((((uint64_t)sCompId) << COMPONENT_ID_BITS) | compId | 0x8000000000000000ULL)
46 
47 typedef double watts;
48 typedef double joules;
49 typedef double farads;
50 typedef double volts;
51 
52 #ifndef LIKELY
53 #define LIKELY(x) __builtin_expect((int)(x), 1)
54 #define UNLIKELY(x) __builtin_expect((int)(x), 0)
55 #endif
56 
57 } // namespace SST
58 
59 #endif // SST_CORE_SST_TYPES_H