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§
Sourcefn copy_to_host_sync(&self, alignment: Alignment) -> VortexResult<ByteBuffer>
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.
Sourcefn copy_to_host(
&self,
alignment: Alignment,
) -> VortexResult<BoxFuture<'static, VortexResult<ByteBuffer>>>
fn copy_to_host( &self, alignment: Alignment, ) -> VortexResult<BoxFuture<'static, VortexResult<ByteBuffer>>>
Sourcefn slice(&self, range: Range<usize>) -> Arc<dyn DeviceBuffer>
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.
Sourcefn aligned(
self: Arc<Self>,
alignment: Alignment,
) -> VortexResult<Arc<dyn DeviceBuffer>>
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).