Trait rust_cuda::lend::LendToCudaAsync
source · pub trait LendToCudaAsync: RustToCudaAsync {
// Required methods
fn lend_to_cuda_async<'stream, O, E: From<CudaError>, F: FnOnce(Async<'_, 'stream, HostAndDeviceConstRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>(
&self,
stream: Stream<'stream>,
inner: F,
) -> Result<O, E>
where Self: Sync;
fn lend_to_cuda_mut_async<'a, 'stream, O, E: From<CudaError>, F: for<'b> FnOnce(Async<'b, 'stream, HostAndDeviceMutRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>, T: 'a>(
this: BoxRefMut<'a, T, Self>,
stream: Stream<'stream>,
inner: F,
) -> Result<(Async<'a, 'stream, BoxRefMut<'a, T, Self>, CompletionFnMut<'a, Self>>, O), E>
where Self: Sync + SafeMutableAliasing;
fn move_to_cuda_async<'stream, O, E: From<CudaError>, F: for<'a> FnOnce(Async<'a, 'stream, HostAndDeviceOwned<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>(
self,
stream: Stream<'stream>,
inner: F,
) -> Result<O, E>
where Self: Send + RustToCuda<CudaRepresentation: StackOnly, CudaAllocation: EmptyCudaAlloc>;
}
host
only.Required Methods§
sourcefn lend_to_cuda_async<'stream, O, E: From<CudaError>, F: FnOnce(Async<'_, 'stream, HostAndDeviceConstRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>(
&self,
stream: Stream<'stream>,
inner: F,
) -> Result<O, E>where
Self: Sync,
fn lend_to_cuda_async<'stream, O, E: From<CudaError>, F: FnOnce(Async<'_, 'stream, HostAndDeviceConstRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>(
&self,
stream: Stream<'stream>,
inner: F,
) -> Result<O, E>where
Self: Sync,
Lends an immutable copy of &self
to CUDA:
- code in the CUDA kernel can only access
&self
through theDeviceConstRef
inside the closure - after the closure,
&self
will not have changed, i.e. interior mutability is not handled by this method
Since the HostAndDeviceConstRef
is wrapped in an Async
with
NoCompletion
, this Async
can be safely dropped or forgotten
without changing any behaviour. Therefore, this Async
does not
need to be returned from the inner
closure.
§Errors
Returns a CudaError
iff an error occurs inside CUDA
sourcefn lend_to_cuda_mut_async<'a, 'stream, O, E: From<CudaError>, F: for<'b> FnOnce(Async<'b, 'stream, HostAndDeviceMutRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>, T: 'a>(
this: BoxRefMut<'a, T, Self>,
stream: Stream<'stream>,
inner: F,
) -> Result<(Async<'a, 'stream, BoxRefMut<'a, T, Self>, CompletionFnMut<'a, Self>>, O), E>where
Self: Sync + SafeMutableAliasing,
fn lend_to_cuda_mut_async<'a, 'stream, O, E: From<CudaError>, F: for<'b> FnOnce(Async<'b, 'stream, HostAndDeviceMutRef<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>, T: 'a>(
this: BoxRefMut<'a, T, Self>,
stream: Stream<'stream>,
inner: F,
) -> Result<(Async<'a, 'stream, BoxRefMut<'a, T, Self>, CompletionFnMut<'a, Self>>, O), E>where
Self: Sync + SafeMutableAliasing,
Lends a mutable borrow of &mut self
to CUDA iff Self
is
SafeMutableAliasing
:
- code in the CUDA kernel can only access
&mut self
through theDeviceMutRef
inside the closure - after the closure,
&mut self
will reflect the changes from the kernel execution
§Errors
Returns a rustacuda::errors::CudaError
iff an error occurs inside CUDA
sourcefn move_to_cuda_async<'stream, O, E: From<CudaError>, F: for<'a> FnOnce(Async<'a, 'stream, HostAndDeviceOwned<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>(
self,
stream: Stream<'stream>,
inner: F,
) -> Result<O, E>
fn move_to_cuda_async<'stream, O, E: From<CudaError>, F: for<'a> FnOnce(Async<'a, 'stream, HostAndDeviceOwned<'_, DeviceAccessible<<Self as RustToCuda>::CudaRepresentation>>, NoCompletion>) -> Result<O, E>>( self, stream: Stream<'stream>, inner: F, ) -> Result<O, E>
Moves self
to CUDA iff self
is StackOnly
.
Since the HostAndDeviceOwned
is wrapped in an Async
with
NoCompletion
, this Async
can be safely dropped or forgotten
without changing any behaviour. Therefore, this Async
does not
need to be returned from the inner
closure.
§Errors
Returns a CudaError
iff an error occurs inside CUDA