pub struct TaskScope(/* private fields */);Implementations§
Source§impl TaskScope
impl TaskScope
Sourcepub fn alloc<T>(&self, capacity: usize) -> Buffer<T, Self>
pub fn alloc<T>(&self, capacity: usize) -> Buffer<T, Self>
Allocates a buffer in this scope on the device.
This call is not blocking. Upon successful completion, it will return a buffer with a memory that is guaranteed to be available in the scope of the task but without any absolute guarantee relative to the host or any other task.
Other tasks may try to allocate memory concurrently. In order to guarantee enough memory for all expected work, the user must ensure some limit on task calls by e.g. using a semaphore.
Sourcepub fn try_alloc<T>(
&self,
capacity: usize,
) -> Result<Buffer<T, Self>, TryReserveError>
pub fn try_alloc<T>( &self, capacity: usize, ) -> Result<Buffer<T, Self>, TryReserveError>
Tries to allocate a buffer in this scope on the device.
Sourcepub unsafe fn launch_host_fn(
&self,
host_fn: unsafe extern "C" fn(*mut c_void),
data: *mut c_void,
) -> Result<(), CudaError>
pub unsafe fn launch_host_fn( &self, host_fn: unsafe extern "C" fn(*mut c_void), data: *mut c_void, ) -> Result<(), CudaError>
Launches a host function in this task.
§Safety
The function essentially executes an extern call in C. The safety assumption of an extern.
The user must ensure the pointer is valid and that the data remains valid as this call will
be asynchronous.
Sourcepub unsafe fn launch_kernel(
&self,
kernel: KernelPtr,
grid_dim: impl Into<Dim3>,
block_dim: impl Into<Dim3>,
args: &[*mut c_void],
shared_mem: usize,
) -> Result<(), CudaError>
pub unsafe fn launch_kernel( &self, kernel: KernelPtr, grid_dim: impl Into<Dim3>, block_dim: impl Into<Dim3>, args: &[*mut c_void], shared_mem: usize, ) -> Result<(), CudaError>
Launches a kernel in this task.
§Safety
The caller must ensure that:
- The kernel ptr is valid.
- The arguments are passed correctly across the FFI interface.
- The data lives whitin the scope of the current task.
Sourcepub fn sleep(&self, time: Duration)
pub fn sleep(&self, time: Duration)
Sends the CUDA task to sleep for at least the given duration.
This function will not block the calling host thread. The function does a small allocation so the sleep time might be slightly longer than the given duration for very short times.
Sourcepub unsafe fn copy<T: DeviceCopy>(
&self,
dst: &mut Slice<T, Self>,
src: &Slice<T, Self>,
) -> Result<(), CopyError>
pub unsafe fn copy<T: DeviceCopy>( &self, dst: &mut Slice<T, Self>, src: &Slice<T, Self>, ) -> Result<(), CopyError>
Copies data between slices using CudaMemCpyAsync
§Safety
The caller must ensure that the data is valid and that the data remains valid as this call
Sourcepub async fn synchronize(&self) -> Result<(), CudaError>
pub async fn synchronize(&self) -> Result<(), CudaError>
Waits for all work enqueued so far in this task to finish.
This function can be useful in case there is work to be enqueued but for some reason this work cannot be done using Self::launch_host_fn.
Sourcepub fn into_device<T: IntoDevice>(
&self,
data: T,
) -> Result<T::Output, CopyError>
pub fn into_device<T: IntoDevice>( &self, data: T, ) -> Result<T::Output, CopyError>
Copies data from the host to the device.
pub fn to_device<T: ToDevice>(&self, data: &T) -> Result<T::Output, CopyError>
Sourcepub fn synchronize_blocking(&self) -> Result<(), CudaError>
pub fn synchronize_blocking(&self) -> Result<(), CudaError>
Waits for all work enqueued so far in this task to finish.
This function can be useful in case there is work to be enqueued but for some reason this work cannot be done using Self::launch_host_fn.
Sourcepub unsafe fn handle(&self) -> CudaStreamHandle
pub unsafe fn handle(&self) -> CudaStreamHandle
§Safety
pub fn owner(&self) -> TaskPool
Sourcepub fn spawn<F, Fut>(&self, f: F) -> SpawnHandle<Fut::Output>
pub fn spawn<F, Fut>(&self, f: F) -> SpawnHandle<Fut::Output>
Spawns a new task from the current task pool.
The task starting point will have a “happens before” relationship with the current task when the spawn is called. The handle can be used to wait for the child task to finish.
Sourcepub async fn run_in_place<F, Fut>(&self, f: F) -> Result<Fut::Output, CudaError>
pub async fn run_in_place<F, Fut>(&self, f: F) -> Result<Fut::Output, CudaError>
Runs a task in place in a new stream.
Awaiting this task will peform the device calls and synchronize the end of this task to the parent, but does not do host synchronization.
Trait Implementations§
Source§impl Allocator for TaskScope
impl Allocator for TaskScope
Source§unsafe fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
unsafe fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
ptr. Read morefn by_ref(&self) -> &Selfwhere
Self: Sized,
Source§impl Backend for TaskScope
impl Backend for TaskScope
Source§impl DeviceMemory for TaskScope
impl DeviceMemory for TaskScope
Source§impl DeviceSumKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl DeviceSumKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
fn partial_sum_kernel() -> KernelPtr
fn block_sum_kernel() -> KernelPtr
Source§impl DeviceSumKernel<KoalaBear> for TaskScope
impl DeviceSumKernel<KoalaBear> for TaskScope
fn partial_sum_kernel() -> KernelPtr
fn block_sum_kernel() -> KernelPtr
Source§impl DeviceTransposeKernel<[KoalaBear; 8]> for TaskScope
impl DeviceTransposeKernel<[KoalaBear; 8]> for TaskScope
fn transpose_kernel() -> KernelPtr
Source§impl DeviceTransposeKernel<[u32; 8]> for TaskScope
impl DeviceTransposeKernel<[u32; 8]> for TaskScope
fn transpose_kernel() -> KernelPtr
Source§impl DeviceTransposeKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl DeviceTransposeKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
fn transpose_kernel() -> KernelPtr
Source§impl DeviceTransposeKernel<KoalaBear> for TaskScope
impl DeviceTransposeKernel<KoalaBear> for TaskScope
fn transpose_kernel() -> KernelPtr
Source§impl DeviceTransposeKernel<u32> for TaskScope
impl DeviceTransposeKernel<u32> for TaskScope
fn transpose_kernel() -> KernelPtr
Source§impl DotKernel<BinomialExtensionField<KoalaBear, 4>, BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl DotKernel<BinomialExtensionField<KoalaBear, 4>, BinomialExtensionField<KoalaBear, 4>> for TaskScope
Source§impl FoldKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl FoldKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
fn fold_kernel() -> KernelPtr
Source§impl FoldKernel<KoalaBear> for TaskScope
impl FoldKernel<KoalaBear> for TaskScope
fn fold_kernel() -> KernelPtr
Source§impl IntoFuture for TaskScope
impl IntoFuture for TaskScope
Source§type IntoFuture = StreamCallbackFuture<TaskScope>
type IntoFuture = StreamCallbackFuture<TaskScope>
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Source§impl<F: Field> MleBaseBackend<F> for TaskScope
impl<F: Field> MleBaseBackend<F> for TaskScope
Source§fn uninit_mle(
&self,
num_polynomials: usize,
num_non_zero_entries: usize,
) -> Tensor<F, Self>
fn uninit_mle( &self, num_polynomials: usize, num_non_zero_entries: usize, ) -> Tensor<F, Self>
Source§fn num_polynomials(guts: &Tensor<F, Self>) -> usize
fn num_polynomials(guts: &Tensor<F, Self>) -> usize
Source§fn num_variables(guts: &Tensor<F, Self>) -> u32
fn num_variables(guts: &Tensor<F, Self>) -> u32
Source§fn num_non_zero_entries(guts: &Tensor<F, Self>) -> usize
fn num_non_zero_entries(guts: &Tensor<F, Self>) -> usize
Source§impl MleFixLastVariableKernel<BinomialExtensionField<KoalaBear, 4>, BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl MleFixLastVariableKernel<BinomialExtensionField<KoalaBear, 4>, BinomialExtensionField<KoalaBear, 4>> for TaskScope
Source§impl PartialGeqKernel<KoalaBear> for TaskScope
impl PartialGeqKernel<KoalaBear> for TaskScope
fn partial_geq_kernel() -> KernelPtr
Source§impl PartialLagrangeKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
impl PartialLagrangeKernel<BinomialExtensionField<KoalaBear, 4>> for TaskScope
Source§impl PartialLagrangeKernel<KoalaBear> for TaskScope
impl PartialLagrangeKernel<KoalaBear> for TaskScope
Source§impl ScanKernel<KoalaBear> for TaskScope
impl ScanKernel<KoalaBear> for TaskScope
Auto Trait Implementations§
impl Freeze for TaskScope
impl !RefUnwindSafe for TaskScope
impl Send for TaskScope
impl Sync for TaskScope
impl Unpin for TaskScope
impl UnsafeUnpin for TaskScope
impl !UnwindSafe for TaskScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, Src, A> CanCopyFrom<T, Src> for A
impl<T, Src, A> CanCopyFrom<T, Src> for A
Source§impl<T, Src, A> CanCopyFromRef<T, Src> for A
impl<T, Src, A> CanCopyFromRef<T, Src> for A
Source§impl<T, Dst, A> CanCopyInto<T, Dst> for A
impl<T, Dst, A> CanCopyInto<T, Dst> for A
type Output = <Dst as CanCopyFrom<T, A>>::Output
fn copy_to_dst( dst: &Dst, value: T, ) -> Result<<A as CanCopyInto<T, Dst>>::Output, CopyError>
Source§impl<T, Dst, Src> CanCopyIntoRef<T, Dst> for Src
impl<T, Dst, Src> CanCopyIntoRef<T, Dst> for Src
type Output = <Dst as CanCopyFromRef<T, Src>>::Output
fn copy_to_dst( dst: &Dst, value: &T, ) -> Result<<Src as CanCopyIntoRef<T, Dst>>::Output, CopyError>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<Challenger, A> FromChallenger<Challenger, A> for Challengerwhere
Challenger: Clone,
impl<Challenger, A> FromChallenger<Challenger, A> for Challengerwhere
Challenger: Clone,
fn from_challenger(challenger: &Challenger, _backend: &A) -> Challenger
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.