Skip to main content

DeviceBuffer

Trait DeviceBuffer 

Source
pub trait DeviceBuffer:
    'static
    + Send
    + Sync
    + Debug
    + DynEq
    + DynHash {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn len(&self) -> usize;
    fn alignment(&self) -> Alignment;
    fn copy_to_host_sync(
        &self,
        alignment: Alignment,
    ) -> VortexResult<ByteBuffer>;
    fn copy_to_host(
        &self,
        alignment: Alignment,
    ) -> VortexResult<BoxFuture<'static, VortexResult<ByteBuffer>>>;
    fn slice(&self, range: Range<usize>) -> Arc<dyn DeviceBuffer> ;
    fn aligned(
        self: Arc<Self>,
        alignment: Alignment,
    ) -> VortexResult<Arc<dyn DeviceBuffer>>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A buffer that is stored on the GPU.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns a reference as Any to enable downcasting.

Source

fn len(&self) -> usize

Returns the length of the buffer in bytes.

Source

fn alignment(&self) -> Alignment

Returns the alignment of the buffer.

Source

fn copy_to_host_sync(&self, alignment: Alignment) -> VortexResult<ByteBuffer>

Attempts to copy the device buffer to a host ByteBuffer.

§Errors

This operation may fail, depending on the device implementation and the underlying hardware.

Source

fn copy_to_host( &self, alignment: Alignment, ) -> VortexResult<BoxFuture<'static, VortexResult<ByteBuffer>>>

Copies the device buffer to a host buffer asynchronously.

Schedules an async copy and returns a future that completes when the copy is finished.

§Arguments
  • alignment - The memory alignment to use for the host buffer.
§Errors

Returns an error if the async copy operation fails.

Source

fn slice(&self, range: Range<usize>) -> Arc<dyn DeviceBuffer>

Create a new buffer that references a subrange of this buffer at the given slice indices.

Note that slice indices are in byte units.

Source

fn aligned( self: Arc<Self>, alignment: Alignment, ) -> VortexResult<Arc<dyn DeviceBuffer>>

Return a buffer with the given alignment. Where possible, this will be zero-copy.

§Errors

Returns an error if the buffer cannot be aligned (e.g., allocation or copy failure).

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the buffer is empty.

Trait Implementations§

Source§

impl Hash for dyn DeviceBuffer

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for dyn DeviceBuffer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for dyn DeviceBuffer

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§