use crate::DeviceId;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DeviceMemoryResourceUsage {
pub allocation_limit_bytes: u64,
pub current_bytes: u64,
pub peak_bytes: u64,
pub total_bytes: u64,
pub current_aligned_bytes: u64,
pub peak_aligned_bytes: u64,
pub total_allocations: u64,
pub current_allocations: u64,
pub peak_allocations: u64,
pub failed_allocation_count: u64,
pub largest_failed_allocation_bytes: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DeviceMemoryPoolUsage {
pub reserved_current_bytes: u64,
pub reserved_high_bytes: u64,
pub used_current_bytes: u64,
pub used_high_bytes: u64,
}
impl From<cudf_sys::cudf_memory_resource_usage_t> for DeviceMemoryResourceUsage {
fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
Self {
allocation_limit_bytes: value.allocation_limit_bytes,
current_bytes: value.current_bytes,
peak_bytes: value.peak_bytes,
total_bytes: value.total_bytes,
current_aligned_bytes: value.current_aligned_bytes,
peak_aligned_bytes: value.peak_aligned_bytes,
total_allocations: value.total_allocations,
current_allocations: value.current_allocations,
peak_allocations: value.peak_allocations,
failed_allocation_count: value.failed_allocation_count,
largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
}
}
}
impl From<cudf_sys::cudf_memory_pool_usage_t> for DeviceMemoryPoolUsage {
fn from(value: cudf_sys::cudf_memory_pool_usage_t) -> Self {
Self {
reserved_current_bytes: value.reserved_current_bytes,
reserved_high_bytes: value.reserved_high_bytes,
used_current_bytes: value.used_current_bytes,
used_high_bytes: value.used_high_bytes,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ReservationUsage {
pub reservation_id: u64,
pub attached: bool,
pub direct_total_allocations: u64,
pub routed_total_allocations: u64,
pub allocation_limit_bytes: u64,
pub current_bytes: u64,
pub peak_bytes: u64,
pub total_bytes: u64,
pub current_aligned_bytes: u64,
pub peak_aligned_bytes: u64,
pub total_allocations: u64,
pub current_allocations: u64,
pub peak_allocations: u64,
pub failed_allocation_count: u64,
pub largest_failed_allocation_bytes: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct QueryMemoryDomainIdentity {
pub device: DeviceId,
pub domain_id: u64,
pub generation: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct QueryMemoryDomainUsage {
pub domain_id: u64,
pub active: bool,
pub active_members: u64,
pub ceiling_bytes: u64,
pub allocation_limit_bytes: u64,
pub current_bytes: u64,
pub peak_bytes: u64,
pub total_bytes: u64,
pub current_aligned_bytes: u64,
pub peak_aligned_bytes: u64,
pub total_allocations: u64,
pub current_allocations: u64,
pub peak_allocations: u64,
pub failed_allocation_count: u64,
pub largest_failed_allocation_bytes: u64,
}
impl From<cudf_sys::cudf_memory_resource_usage_t> for ReservationUsage {
fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
Self {
reservation_id: value.reserved[0],
attached: value.reserved[1] != 0,
direct_total_allocations: value.reserved[2],
routed_total_allocations: value.reserved[3],
allocation_limit_bytes: value.allocation_limit_bytes,
current_bytes: value.current_bytes,
peak_bytes: value.peak_bytes,
total_bytes: value.total_bytes,
current_aligned_bytes: value.current_aligned_bytes,
peak_aligned_bytes: value.peak_aligned_bytes,
total_allocations: value.total_allocations,
current_allocations: value.current_allocations,
peak_allocations: value.peak_allocations,
failed_allocation_count: value.failed_allocation_count,
largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
}
}
}
impl From<cudf_sys::cudf_memory_resource_usage_t> for QueryMemoryDomainUsage {
fn from(value: cudf_sys::cudf_memory_resource_usage_t) -> Self {
Self {
domain_id: value.reserved[0],
active: value.reserved[1] != 0,
active_members: value.reserved[2],
ceiling_bytes: value.reserved[3],
allocation_limit_bytes: value.allocation_limit_bytes,
current_bytes: value.current_bytes,
peak_bytes: value.peak_bytes,
total_bytes: value.total_bytes,
current_aligned_bytes: value.current_aligned_bytes,
peak_aligned_bytes: value.peak_aligned_bytes,
total_allocations: value.total_allocations,
current_allocations: value.current_allocations,
peak_allocations: value.peak_allocations,
failed_allocation_count: value.failed_allocation_count,
largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
}
}
}
impl From<ReservationUsage> for DeviceMemoryResourceUsage {
fn from(value: ReservationUsage) -> Self {
Self {
allocation_limit_bytes: value.allocation_limit_bytes,
current_bytes: value.current_bytes,
peak_bytes: value.peak_bytes,
total_bytes: value.total_bytes,
current_aligned_bytes: value.current_aligned_bytes,
peak_aligned_bytes: value.peak_aligned_bytes,
total_allocations: value.total_allocations,
current_allocations: value.current_allocations,
peak_allocations: value.peak_allocations,
failed_allocation_count: value.failed_allocation_count,
largest_failed_allocation_bytes: value.largest_failed_allocation_bytes,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct QueryMemoryDomainAllocation {
pub device_pointer: usize,
pub bytes: u64,
pub aligned_bytes: u64,
pub alignment: u64,
}
impl From<cudf_sys::cudf_query_memory_domain_allocation_t> for QueryMemoryDomainAllocation {
fn from(value: cudf_sys::cudf_query_memory_domain_allocation_t) -> Self {
Self {
device_pointer: value.device_pointer as usize,
bytes: value.bytes as u64,
aligned_bytes: value.aligned_bytes as u64,
alignment: value.alignment as u64,
}
}
}