Trait ComputeMemory

Source
pub trait ComputeMemory<F> {
    type FSlice<'a>: Copy + SizedSlice + Sync;
    type FSliceMut<'a>: SizedSlice;

    const ALIGNMENT: usize;
Show 13 methods // Required methods fn narrow<'a>(data: &'a Self::FSlice<'_>) -> Self::FSlice<'a>; fn narrow_mut<'a, 'b: 'a>(data: Self::FSliceMut<'b>) -> Self::FSliceMut<'a>; fn to_owned_mut<'a>( data: &'a mut Self::FSliceMut<'_>, ) -> Self::FSliceMut<'a>; fn as_const<'a>(data: &'a Self::FSliceMut<'_>) -> Self::FSlice<'a>; fn slice( data: Self::FSlice<'_>, range: impl RangeBounds<usize>, ) -> Self::FSlice<'_>; fn slice_mut<'a>( data: &'a mut Self::FSliceMut<'_>, range: impl RangeBounds<usize>, ) -> Self::FSliceMut<'a>; fn split_at_mut( data: Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'_>, Self::FSliceMut<'_>); fn slice_chunks_mut<'a>( data: Self::FSliceMut<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSliceMut<'a>>; // Provided methods fn split_at( data: Self::FSlice<'_>, mid: usize, ) -> (Self::FSlice<'_>, Self::FSlice<'_>) { ... } fn split_at_mut_borrowed<'a>( data: &'a mut Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>) { ... } fn slice_chunks<'a>( data: Self::FSlice<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSlice<'a>> { ... } fn split_half<'a>( data: Self::FSlice<'a>, ) -> (Self::FSlice<'a>, Self::FSlice<'a>) { ... } fn split_half_mut<'a>( data: Self::FSliceMut<'a>, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>) { ... }
}
Expand description

Interface for manipulating handles to memory in a compute device.

Required Associated Constants§

Source

const ALIGNMENT: usize

The required alignment of indices for the split methods. This must be a power of two.

Required Associated Types§

Source

type FSlice<'a>: Copy + SizedSlice + Sync

An opaque handle to an immutable slice of elements stored in a compute memory.

Source

type FSliceMut<'a>: SizedSlice

An opaque handle to a mutable slice of elements stored in a compute memory.

Required Methods§

Source

fn narrow<'a>(data: &'a Self::FSlice<'_>) -> Self::FSlice<'a>

Borrows an immutable memory slice, narrowing the lifetime.

Source

fn narrow_mut<'a, 'b: 'a>(data: Self::FSliceMut<'b>) -> Self::FSliceMut<'a>

Borrows a mutable memory slice, narrowing the lifetime.

Source

fn to_owned_mut<'a>(data: &'a mut Self::FSliceMut<'_>) -> Self::FSliceMut<'a>

Source

fn as_const<'a>(data: &'a Self::FSliceMut<'_>) -> Self::FSlice<'a>

Borrows a mutable memory slice as immutable.

This allows the immutable reference to be copied.

Source

fn slice( data: Self::FSlice<'_>, range: impl RangeBounds<usize>, ) -> Self::FSlice<'_>

Borrows a subslice of an immutable memory slice.

§Preconditions
Source

fn slice_mut<'a>( data: &'a mut Self::FSliceMut<'_>, range: impl RangeBounds<usize>, ) -> Self::FSliceMut<'a>

Borrows a subslice of a mutable memory slice.

§Preconditions
Source

fn split_at_mut( data: Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'_>, Self::FSliceMut<'_>)

Splits a mutable slice into two disjoint subslices.

§Preconditions
Source

fn slice_chunks_mut<'a>( data: Self::FSliceMut<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSliceMut<'a>>

Splits a mutable slice into equal chunks.

§Preconditions
  • the length of the slice must be a multiple of chunk_len
  • chunk_len must be a multiple of Self::ALIGNMENT

Provided Methods§

Source

fn split_at( data: Self::FSlice<'_>, mid: usize, ) -> (Self::FSlice<'_>, Self::FSlice<'_>)

Splits an immutable slice into two disjoint subslices.

§Preconditions
Source

fn split_at_mut_borrowed<'a>( data: &'a mut Self::FSliceMut<'_>, mid: usize, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>)

Source

fn slice_chunks<'a>( data: Self::FSlice<'a>, chunk_len: usize, ) -> impl Iterator<Item = Self::FSlice<'a>>

Splits slice into equal chunks.

§Preconditions
  • the length of the slice must be a multiple of chunk_len
  • chunk_len must be a multiple of Self::ALIGNMENT
Source

fn split_half<'a>( data: Self::FSlice<'a>, ) -> (Self::FSlice<'a>, Self::FSlice<'a>)

Splits an immutable slice of power-two length into two equal halves.

Unlike all other splitting methods, this method does not require input or output slices to be a multiple of Self::ALIGNMENT.

Source

fn split_half_mut<'a>( data: Self::FSliceMut<'a>, ) -> (Self::FSliceMut<'a>, Self::FSliceMut<'a>)

Splits a mutable slice of power-two length into two equal halves.

Unlike all other splitting methods, this method does not require input or output slices to be a multiple of Self::ALIGNMENT.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F: 'static + Sync> ComputeMemory<F> for CpuMemory

Source§

const ALIGNMENT: usize = 1usize

Source§

type FSlice<'a> = &'a [F]

Source§

type FSliceMut<'a> = &'a mut [F]