nvbit_model/
lib.rs

1pub mod dim;
2pub use dim::*;
3
4use serde::{Deserialize, Serialize};
5
6/// A CUDA device.
7#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
8pub struct Device(pub u64);
9
10/// A CUDA context.
11#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
12pub struct Context(pub u64);
13
14/// A CUDA function.
15#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
16pub struct Function(pub u64);
17
18/// A CUDA stream.
19#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
20pub struct Stream(pub u64);
21
22/// CUDA function attribute.
23#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
24pub enum FunctionAttribute {
25    MaxThreadsPerBlock,
26    SharedSizeBytes,
27    ConstSizeBytes,
28    LocalSizeBytes,
29    NumRegs,
30    PTXVersion,
31    BinaryVersion,
32    CacheModeCA,
33    MaxDynamicSharedSizeBytes,
34    PreferredSharedMemoryCarveout,
35    Max,
36}
37
38/// NVBIT Register modifiers.
39#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
40pub enum RegisterModifier {
41    None = 0,
42    X1 = 1,
43    X4 = 2,
44    X8 = 3,
45    X16 = 4,
46    U32 = 5,
47    U64 = 6,
48}
49
50/// An instruction operand.
51#[derive(Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
52pub enum OperandKind {
53    ImmutableUint64 {
54        value: u64,
55    },
56    ImmutableDouble {
57        value: f64,
58    },
59    Register {
60        num: i32,
61        prop: String,
62    },
63    Predicate {
64        num: i32,
65    },
66    // URegister {},
67    // UPredicate {},
68    CBank {
69        id: i32,
70        has_imm_offset: bool,
71        imm_offset: i32,
72        has_reg_offset: bool,
73        reg_offset: i32,
74    },
75    MemRef {
76        has_ra: bool,
77        ra_num: i32,
78        ra_mod: RegisterModifier,
79        has_ur: bool,
80        ur_num: i32,
81        ur_mod: RegisterModifier,
82        has_imm: bool,
83        imm: i32,
84    },
85    Generic {
86        array: String,
87    },
88}
89
90/// Identifier of GPU memory space.
91#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
92pub enum MemorySpace {
93    None = 0,
94    Local = 1,
95    Generic = 2,
96    Global = 3,
97    Shared = 4,
98    Constant = 5,
99    GlobalToShared = 6,
100    Surface = 7,
101    Texture = 8,
102}
103
104/// An instruction operand predicate.
105#[derive(
106    Debug, Default, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize,
107)]
108pub struct Predicate {
109    /// predicate number
110    pub num: std::ffi::c_int,
111    /// whether predicate is negated (i.e. @!P0).
112    pub is_neg: bool,
113    /// whether predicate is uniform predicate (e.g., @UP0).
114    pub is_uniform: bool,
115}
116
117/// Insertion point where the instrumentation for an instruction should be inserted
118#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
119pub enum InsertionPoint {
120    Before,
121    After,
122}
123
124/// All possible CUDA error kinds
125#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
126pub enum CudaErrorKind {
127    Success,
128    InvalidValue,
129    OutOfMemory,
130    NotInitialized,
131    Deinitialized,
132    ProfilerDisabled,
133    ProfilerNotInitialized,
134    ProfilerAlreadyStarted,
135    ProfilerAlreadyStopped,
136    NoDevice,
137    InvalidDevice,
138    InvalidImage,
139    InvalidContext,
140    ContextAlreadyCurrent,
141    MapFailed,
142    UnmapFailed,
143    ArrayIsMapped,
144    AlreadyMapped,
145    NoBinaryForGpu,
146    AlreadyAcquired,
147    NotMapped,
148    NotMappedAsArray,
149    NotMappedAsPointer,
150    EccUncorrectable,
151    UnsupportedLimit,
152    ContextAlreadyInUse,
153    PeerAccessUnsupported,
154    InvalidPtx,
155    InvalidGraphicsContext,
156    NvlinkUncorrectable,
157    InvalidSouce,
158    FileNotFound,
159    SharedObjectSymbolNotFound,
160    SharedObjectInitFailed,
161    OperatingSystemError,
162    InvalidHandle,
163    NotFound,
164    NotReady,
165    IllegalAddress,
166    LaunchOutOfResources,
167    LaunchTimeout,
168    LaunchIncompatibleTexturing,
169    PeerAccessAlreadyEnabled,
170    PeerAccessNotEnabled,
171    PrimaryContextActive,
172    ContextIsDestroyed,
173    AssertError,
174    TooManyPeers,
175    HostMemoryAlreadyRegistered,
176    HostMemoryNotRegistered,
177    HardwareStackError,
178    IllegalInstruction,
179    MisalignedAddress,
180    InvalidAddressSpace,
181    InvalidProgramCounter,
182    LaunchFailed,
183    NotPermitted,
184    NotSupported,
185    Unknown,
186}