pub struct DeviceBox<'a> { /* private fields */ }
Expand description
An owned device-allocated buffer
Implementations§
Source§impl<'a> DeviceBox<'a>
impl<'a> DeviceBox<'a>
Sourcepub fn alloc(handle: &Rc<Handle<'a>>, size: u64) -> CudaResult<Self>
pub fn alloc(handle: &Rc<Handle<'a>>, size: u64) -> CudaResult<Self>
Allocate an uninitialized buffer of size size
on the device
Sourcepub fn new(handle: &Rc<Handle<'a>>, input: &[u8]) -> CudaResult<Self>
pub fn new(handle: &Rc<Handle<'a>>, input: &[u8]) -> CudaResult<Self>
Allocate a new initialized buffer on the device matching the size and content of input
.
Sourcepub fn new_stream<'b>(
handle: &Rc<Handle<'a>>,
input: &'b [u8],
stream: &'b mut Stream<'a>,
) -> CudaResult<Self>
pub fn new_stream<'b>( handle: &Rc<Handle<'a>>, input: &'b [u8], stream: &'b mut Stream<'a>, ) -> CudaResult<Self>
Allocates a new uninitialized buffer on the device, then asynchronously fills it with input
.
input
must not be dropped or mutated until stream.sync
is called.
Does not allocate the memory asynchronously.
Sourcepub fn new_stream_buf(
handle: &Rc<Handle<'a>>,
input: Vec<u8>,
stream: &mut Stream<'a>,
) -> CudaResult<Self>
pub fn new_stream_buf( handle: &Rc<Handle<'a>>, input: Vec<u8>, stream: &mut Stream<'a>, ) -> CudaResult<Self>
Allocates a new uninitialized buffer on the device, then synchronously fills it with input
.
input
will be dropped when the stream is synced or dropped.
Does not allocate the memory asynchronously.
Sourcepub fn new_ffi<T>(handle: &Rc<Handle<'a>>, input: &[T]) -> CudaResult<Self>
pub fn new_ffi<T>(handle: &Rc<Handle<'a>>, input: &[T]) -> CudaResult<Self>
Allocates a new initialized buffer on the device matching the size and content of input
.
Note that memory is directly copied, so [T
] must be Sized
should not contain any pointers, references, unsized types, or other non-FFI safe types.
Sourcepub fn new_ffi_stream<'b, T>(
handle: &Rc<Handle<'a>>,
input: &'b [T],
stream: &'b mut Stream<'a>,
) -> CudaResult<Self>
pub fn new_ffi_stream<'b, T>( handle: &Rc<Handle<'a>>, input: &'b [T], stream: &'b mut Stream<'a>, ) -> CudaResult<Self>
Allocates a new uninitialized buffer on the device, then synchronously fills it with input
.
Note that memory is directly copied, so [T
] must be Sized
should not contain any pointers, references, unsized types, or other non-FFI safe types.
input
must not be dropped or mutated until stream.sync
is called.
Does not allocate the memory asynchronously.
Sourcepub fn new_ffi_stream_buf<'b, T>(
handle: &Rc<Handle<'a>>,
input: Vec<T>,
stream: &'b mut Stream<'a>,
) -> CudaResult<Self>
pub fn new_ffi_stream_buf<'b, T>( handle: &Rc<Handle<'a>>, input: Vec<T>, stream: &'b mut Stream<'a>, ) -> CudaResult<Self>
Allocates a new uninitialized buffer on the device, then synchronously fills it with input
.
Note that memory is directly copied, so [T
] must be Sized
should not contain any pointers, references, unsized types, or other non-FFI safe types.
input
will be dropped when the stream is synced or dropped.
Does not allocate the memory asynchronously.
Methods from Deref<Target = DevicePtr<'a>>§
pub fn as_raw(&self) -> u64
Sourcepub fn copy_to<'b>(&self, target: &DevicePtr<'b>) -> CudaResult<()>
pub fn copy_to<'b>(&self, target: &DevicePtr<'b>) -> CudaResult<()>
Synchronously copies data from self
to target
. Panics if length is not equal.
Sourcepub fn copy_to_stream<'b, 'c: 'b + 'a>(
&self,
target: &DevicePtr<'b>,
stream: &mut Stream<'c>,
) -> CudaResult<()>where
'a: 'b,
pub fn copy_to_stream<'b, 'c: 'b + 'a>(
&self,
target: &DevicePtr<'b>,
stream: &mut Stream<'c>,
) -> CudaResult<()>where
'a: 'b,
Asynchronously copies data from self
to target
. Panics if length is not equal.
Sourcepub fn copy_from<'b>(&self, source: &DevicePtr<'b>) -> CudaResult<()>
pub fn copy_from<'b>(&self, source: &DevicePtr<'b>) -> CudaResult<()>
Synchronously copies data from source
to self
. Panics if length is not equal.
Sourcepub fn copy_from_stream<'b: 'a, 'c: 'a + 'b>(
&self,
source: &DevicePtr<'b>,
stream: &mut Stream<'c>,
) -> CudaResult<()>
pub fn copy_from_stream<'b: 'a, 'c: 'a + 'b>( &self, source: &DevicePtr<'b>, stream: &mut Stream<'c>, ) -> CudaResult<()>
Asynchronously copies data from source
to self
. Panics if length is not equal.
Sourcepub fn subslice(&self, from: u64, to: u64) -> Self
pub fn subslice(&self, from: u64, to: u64) -> Self
Gets a subslice of this slice from [from:to]
Sourcepub fn load(&self) -> CudaResult<Vec<u8>>
pub fn load(&self) -> CudaResult<Vec<u8>>
Synchronously loads the data from this slice into a local buffer
Sourcepub unsafe fn load_stream(&self, stream: &mut Stream<'a>) -> CudaResult<Vec<u8>>
pub unsafe fn load_stream(&self, stream: &mut Stream<'a>) -> CudaResult<Vec<u8>>
Asynchronously loads the data from this slice into a local buffer.
The contents of the buffer are undefined until stream.sync
is called.
The output must not be dropped until the stream is synced.
Sourcepub fn store(&self, data: &[u8]) -> CudaResult<()>
pub fn store(&self, data: &[u8]) -> CudaResult<()>
Synchronously stores host data from data
to self
.
Sourcepub fn store_stream<'b>(
&self,
data: &'b [u8],
stream: &'b mut Stream<'a>,
) -> CudaResult<()>
pub fn store_stream<'b>( &self, data: &'b [u8], stream: &'b mut Stream<'a>, ) -> CudaResult<()>
Asynchronously stores host data from data
to self
.
The data
must not be dropped or mutated until stream.sync
is called.
Sourcepub fn store_stream_buf(
&self,
data: Vec<u8>,
stream: &mut Stream<'a>,
) -> CudaResult<()>
pub fn store_stream_buf( &self, data: Vec<u8>, stream: &mut Stream<'a>, ) -> CudaResult<()>
Asynchronously stores host data from data
to self
.
data
will be dropped once the Stream
is synced or dropped.
Sourcepub fn memset_d8(&self, data: u8) -> CudaResult<()>
pub fn memset_d8(&self, data: u8) -> CudaResult<()>
Synchronously set the contents of self
to data
repeated to fill length
Sourcepub fn memset_d8_stream(
&self,
data: u8,
stream: &mut Stream<'a>,
) -> CudaResult<()>
pub fn memset_d8_stream( &self, data: u8, stream: &mut Stream<'a>, ) -> CudaResult<()>
Asynchronously set the contents of self
to data
repeated to fill length
Sourcepub fn memset_d16(&self, data: u16) -> CudaResult<()>
pub fn memset_d16(&self, data: u16) -> CudaResult<()>
Synchronously set the contents of self
to data
repeated to fill length.
Panics if Self::len
is not a multiple of 2.
Sourcepub fn memset_d16_stream(
&self,
data: u16,
stream: &mut Stream<'a>,
) -> CudaResult<()>
pub fn memset_d16_stream( &self, data: u16, stream: &mut Stream<'a>, ) -> CudaResult<()>
Asynchronously set the contents of self
to data
repeated to fill length.
Panics if Self::len
is not a multiple of 2.
Sourcepub fn memset_d32(&self, data: u32) -> CudaResult<()>
pub fn memset_d32(&self, data: u32) -> CudaResult<()>
Synchronously set the contents of self
to data
repeated to fill length.
Panics if Self::len
is not a multiple of 4.
Sourcepub fn memset_d32_stream(
&self,
data: u32,
stream: &mut Stream<'a>,
) -> CudaResult<()>
pub fn memset_d32_stream( &self, data: u32, stream: &mut Stream<'a>, ) -> CudaResult<()>
Asynchronously set the contents of self
to data
repeated to fill length.
Panics if Self::len
is not a multiple of 4.