pub struct CompressedDeviceBuffer { /* private fields */ }Expand description
Host-side descriptor for a compressed device allocation.
Tracks the logical size, the physically reserved (granularity-aligned) size, and an observed compression ratio that the application can update as it learns how compressible its data is. The descriptor never owns a GPU pointer here — that is filled in by the device-gated path — but it provides the bandwidth and footprint accounting that callers use to decide whether compression is worthwhile.
The compression ratio is defined as physical / effective: a ratio of
2.0 means the data occupies half its physical footprint over the memory
bus, doubling effective bandwidth for that region.
Implementations§
Source§impl CompressedDeviceBuffer
impl CompressedDeviceBuffer
Sourcepub fn new(plan: CompressionPlan) -> Self
pub fn new(plan: CompressionPlan) -> Self
Creates a descriptor for a freshly planned compressed buffer.
The compression ratio starts at 1.0 (no measured compression yet).
Sourcepub fn alloc(
requested_bytes: usize,
support: CompressionSupport,
) -> CudaResult<Self>
pub fn alloc( requested_bytes: usize, support: CompressionSupport, ) -> CudaResult<Self>
Builds a descriptor directly from a request, applying capability gating and granularity alignment in one step.
§Errors
Forwards errors from CompressionPlan::new.
Sourcepub fn plan(&self) -> CompressionPlan
pub fn plan(&self) -> CompressionPlan
Returns the underlying allocation plan.
Sourcepub fn compression_type(&self) -> CompressionType
pub fn compression_type(&self) -> CompressionType
Returns the compression type recorded for this buffer.
Sourcepub fn logical_bytes(&self) -> usize
pub fn logical_bytes(&self) -> usize
The logical (requested) size in bytes.
Sourcepub fn physical_bytes(&self) -> usize
pub fn physical_bytes(&self) -> usize
The physical (granularity-aligned) footprint in bytes.
Sourcepub fn set_ratio(&mut self, ratio: f64)
pub fn set_ratio(&mut self, ratio: f64)
Records an observed compression ratio (physical / effective).
Values below 1.0 are clamped to 1.0 (data cannot expand under
lossless compression as far as bus traffic is concerned). Non-finite
inputs are ignored.
Sourcepub fn effective_bus_bytes(&self) -> usize
pub fn effective_bus_bytes(&self) -> usize
The effective number of bytes that traverse the memory bus given the recorded compression ratio.
Equal to physical_bytes / ratio, rounded down. With a ratio of 1.0
this equals the physical footprint.
Sourcepub fn effective_bandwidth_gbps(&self, dram_gbps: f64) -> f64
pub fn effective_bandwidth_gbps(&self, dram_gbps: f64) -> f64
Estimates the effective bandwidth seen by a transfer of this buffer’s
physical footprint, given a raw dram_gbps DRAM bandwidth.
Because compression reduces bus traffic by ratio, the effective
bandwidth observed for compressible data is dram_gbps * ratio.
Non-positive bandwidth returns 0.0.
Sourcepub fn bytes_saved(&self) -> usize
pub fn bytes_saved(&self) -> usize
The number of physical bytes saved on the bus relative to an
uncompressed transfer (physical - effective).
Trait Implementations§
Source§impl Clone for CompressedDeviceBuffer
impl Clone for CompressedDeviceBuffer
Source§fn clone(&self) -> CompressedDeviceBuffer
fn clone(&self) -> CompressedDeviceBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CompressedDeviceBuffer
Source§impl Debug for CompressedDeviceBuffer
impl Debug for CompressedDeviceBuffer
Source§impl Display for CompressedDeviceBuffer
impl Display for CompressedDeviceBuffer
Source§impl PartialEq for CompressedDeviceBuffer
impl PartialEq for CompressedDeviceBuffer
Source§fn eq(&self, other: &CompressedDeviceBuffer) -> bool
fn eq(&self, other: &CompressedDeviceBuffer) -> bool
self and other values to be equal, and is used by ==.