1use crate::DeviceId;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct DeviceMemoryResourceUsage {
8 pub allocation_limit_bytes: u64,
9 pub current_bytes: u64,
10 pub peak_bytes: u64,
11 pub total_bytes: u64,
12 pub current_aligned_bytes: u64,
13 pub peak_aligned_bytes: u64,
14 pub total_allocations: u64,
15 pub current_allocations: u64,
16 pub peak_allocations: u64,
17 pub failed_allocation_count: u64,
18 pub largest_failed_allocation_bytes: u64,
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub struct DeviceMemoryPoolUsage {
24 pub reserved_current_bytes: u64,
25 pub reserved_high_bytes: u64,
26 pub used_current_bytes: u64,
27 pub used_high_bytes: u64,
28}
29
30impl From<cudf_sys::cudf_memory_resource_usage_t> for DeviceMemoryResourceUsage {
31 fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
32 Self {
33 allocation_limit_bytes: value.allocation_limit_bytes,
34 current_bytes: value.current_bytes,
35 peak_bytes: value.peak_bytes,
36 total_bytes: value.total_bytes,
37 current_aligned_bytes: value.current_aligned_bytes,
38 peak_aligned_bytes: value.peak_aligned_bytes,
39 total_allocations: value.total_allocations,
40 current_allocations: value.current_allocations,
41 peak_allocations: value.peak_allocations,
42 failed_allocation_count: value.failed_allocation_count,
43 largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
44 }
45 }
46}
47
48impl From<cudf_sys::cudf_memory_pool_usage_t> for DeviceMemoryPoolUsage {
49 fn from(value: cudf_sys::cudf_memory_pool_usage_t) -> Self {
50 Self {
51 reserved_current_bytes: value.reserved_current_bytes,
52 reserved_high_bytes: value.reserved_high_bytes,
53 used_current_bytes: value.used_current_bytes,
54 used_high_bytes: value.used_high_bytes,
55 }
56 }
57}
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq)]
66pub struct ReservationUsage {
67 pub reservation_id: u64,
69 pub attached: bool,
71 pub direct_total_allocations: u64,
73 pub routed_total_allocations: u64,
76 pub allocation_limit_bytes: u64,
78 pub current_bytes: u64,
80 pub peak_bytes: u64,
82 pub total_bytes: u64,
84 pub current_aligned_bytes: u64,
86 pub peak_aligned_bytes: u64,
88 pub total_allocations: u64,
90 pub current_allocations: u64,
92 pub peak_allocations: u64,
94 pub failed_allocation_count: u64,
96 pub largest_failed_allocation_bytes: u64,
98}
99
100#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
106pub struct QueryMemoryDomainIdentity {
107 pub device: DeviceId,
108 pub domain_id: u64,
109 pub generation: u64,
110}
111
112#[derive(Debug, Clone, Copy, PartialEq, Eq)]
114pub struct QueryMemoryDomainUsage {
115 pub domain_id: u64,
117 pub active: bool,
119 pub active_members: u64,
121 pub ceiling_bytes: u64,
123 pub allocation_limit_bytes: u64,
125 pub current_bytes: u64,
127 pub peak_bytes: u64,
129 pub total_bytes: u64,
131 pub current_aligned_bytes: u64,
133 pub peak_aligned_bytes: u64,
135 pub total_allocations: u64,
137 pub current_allocations: u64,
139 pub peak_allocations: u64,
141 pub failed_allocation_count: u64,
143 pub largest_failed_allocation_bytes: u64,
145}
146
147impl From<cudf_sys::cudf_memory_resource_usage_t> for ReservationUsage {
148 fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
149 Self {
150 reservation_id: value.reserved[0],
151 attached: value.reserved[1] != 0,
152 direct_total_allocations: value.reserved[2],
153 routed_total_allocations: value.reserved[3],
154 allocation_limit_bytes: value.allocation_limit_bytes,
155 current_bytes: value.current_bytes,
156 peak_bytes: value.peak_bytes,
157 total_bytes: value.total_bytes,
158 current_aligned_bytes: value.current_aligned_bytes,
159 peak_aligned_bytes: value.peak_aligned_bytes,
160 total_allocations: value.total_allocations,
161 current_allocations: value.current_allocations,
162 peak_allocations: value.peak_allocations,
163 failed_allocation_count: value.failed_allocation_count,
164 largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
165 }
166 }
167}
168
169impl From<cudf_sys::cudf_memory_resource_usage_t> for QueryMemoryDomainUsage {
170 fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
171 Self {
172 domain_id: value.reserved[0],
173 active: value.reserved[1] != 0,
174 active_members: value.reserved[2],
175 ceiling_bytes: value.reserved[3],
176 allocation_limit_bytes: value.allocation_limit_bytes,
177 current_bytes: value.current_bytes,
178 peak_bytes: value.peak_bytes,
179 total_bytes: value.total_bytes,
180 current_aligned_bytes: value.current_aligned_bytes,
181 peak_aligned_bytes: value.peak_aligned_bytes,
182 total_allocations: value.total_allocations,
183 current_allocations: value.current_allocations,
184 peak_allocations: value.peak_allocations,
185 failed_allocation_count: value.failed_allocation_count,
186 largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
187 }
188 }
189}
190
191impl From<ReservationUsage> for DeviceMemoryResourceUsage {
192 fn from(value: ReservationUsage) -> Self {
193 Self {
194 allocation_limit_bytes: value.allocation_limit_bytes,
195 current_bytes: value.current_bytes,
196 peak_bytes: value.peak_bytes,
197 total_bytes: value.total_bytes,
198 current_aligned_bytes: value.current_aligned_bytes,
199 peak_aligned_bytes: value.peak_aligned_bytes,
200 total_allocations: value.total_allocations,
201 current_allocations: value.current_allocations,
202 peak_allocations: value.peak_allocations,
203 failed_allocation_count: value.failed_allocation_count,
204 largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
205 }
206 }
207}
208
209#[derive(Debug, Clone, Copy, PartialEq, Eq)]
211pub struct QueryMemoryDomainAllocation {
212 pub device_pointer: usize,
214 pub bytes: u64,
216 pub aligned_bytes: u64,
218 pub alignment: u64,
220}
221
222impl From<cudf_sys::cudf_query_memory_domain_allocation_t> for QueryMemoryDomainAllocation {
223 fn from(value: cudf_sys::cudf_query_memory_domain_allocation_t) -> Self {
224 Self {
225 device_pointer: value.device_pointer as usize,
226 bytes: value.bytes as u64,
227 aligned_bytes: value.aligned_bytes as u64,
228 alignment: value.alignment as u64,
229 }
230 }
231}