Struct blaze_rs::buffer::BufMut

source ·
#[repr(transparent)]
pub struct BufMut<'a, T, C: Context = Global> { /* private fields */ }
Available on crate feature cl1_1 only.
Expand description

A mutable slice of a Buffer

Implementations§

source§

impl<'a, T, C: Context> BufMut<'a, T, C>

source

pub fn new<R: IntoRange>(parent: &'a mut Buffer<T, C>, range: R) -> Result<Self>where C: Clone,

source

pub unsafe fn from_raw<R: IntoRange>( parent: &RawBuffer, range: R, ctx: C ) -> Result<Self>

Methods from Deref<Target = Buffer<T, C>>§

source

pub fn len(&self) -> Result<usize>

Number of elements inside the buffer

source

pub fn context(&self) -> &C

Returns a reference to the Buffer’s underlying Context.

source

pub fn slice<R: IntoRange>(&self, range: R) -> Result<Buf<'_, T, C>>where C: Clone,

Creates a shared slice of this buffer.

source

pub fn slice_mut<R: IntoRange>(&mut self, range: R) -> Result<BufMut<'_, T, C>>where C: Clone,

Creates a mutable slice of this buffer.

source

pub fn chunks_exact(&self, offset: usize, len: usize) -> ChunksExact<'_, T, C> where C: Clone,

Returns an iterator over chunks of size len of the buffer, starting at offset.

source

pub fn chunks_exact_mut( &mut self, offset: usize, len: usize ) -> ChunksExactMut<'_, T, C> where C: Clone,

Returns an iterator over mutable chunks of size len of the buffer, starting at offset.

This is usefull for situations where you want to write to the same buffer in parallel, in regions that don’t overlap.

source

pub fn as_uninit(&self) -> &Buffer<MaybeUninit<T>, C>

Converts &Buffer<T,C> to &Buffer<MaybeUninit<T>,C>

source

pub fn as_mut_uninit(&mut self) -> &mut Buffer<MaybeUninit<T>, C>

Converts &mut Buffer<T,C> to &mut Buffer<MaybeUninit<T>,C>

source

pub fn try_clone(&self, wait: WaitList<'_>) -> Result<Self>where T: Clone, C: Clone,

source

pub async fn try_clone_async<'a>(&self, wait: WaitList<'a>) -> Result<Self>where T: Clone, C: Clone,

Available on crate feature futures only.
source

pub fn eq_buffer(&self, other: &Buffer<T, C>) -> bool

Checks if the buffer pointer is the same in both buffers.

source

pub fn write_init<'scope, 'env, O: Into<Option<usize>>>( &'env mut self, scope: &'scope Scope<'scope, 'env, C>, offset: O, src: &'env [T], wait: WaitList<'_> ) -> Result<WriteEvent<'scope, MaybeUninit<T>, C>>

Convenience method for writing to an unitialized buffer. See write.

source

pub fn write_init_blocking( &mut self, offset: impl Into<Option<usize>>, src: &[T], wait: WaitList<'_> ) -> Result<()>

Convenience method for writing to an unitialized buffer. See write_blocking.

source

pub fn copy_from_init<'scope, 'env, Dst: Into<Option<usize>>, Src: Into<Option<usize>>, Size: Into<Option<usize>>>( &'env mut self, scope: &'scope Scope<'scope, 'env, C>, dst_offset: Dst, src: &'env Buffer<T, C>, src_offset: Src, size: Size, wait: WaitList<'_> ) -> Result<CopyEvent<'scope, MaybeUninit<T>, C>>

Convenience method for copying to an unitialized buffer. See copy_from.

source

pub fn copy_from_init_blocking( &mut self, dst_offset: impl Into<Option<usize>>, src: &Buffer<T, C>, src_offset: impl Into<Option<usize>>, size: impl Into<Option<usize>>, wait: WaitList<'_> ) -> Result<()>where T: Copy + Send + Sync,

Convenience method for copying to an unitialized buffer. See copy_from_blocking.

source

pub fn fill_init<'scope, 'env, R: IntoRange>( &'env mut self, scope: &'scope Scope<'scope, 'env, C>, v: T, range: R, wait: WaitList<'_> ) -> Result<FillEvent<'scope, MaybeUninit<T>, C>>

Available on crate feature cl1_2 only.

Convenience method for filling an unitialized buffer. See fill.

source

pub fn fill_init_blocking( &mut self, v: T, range: impl IntoRange, wait: WaitList<'_> ) -> Result<()>

Available on crate feature cl1_2 only.

Convenience method for filling an unitialized buffer. See fill_blocking.

source

pub fn get_blocking(&self, idx: usize, wait: WaitList<'_>) -> Result<T>

Reads the contents of the buffer at the specified index, blocking the current thread until the operation has completed.

source

pub fn get<'scope, 'env>( &'env self, scope: &'scope Scope<'scope, 'env, C>, idx: usize, wait: WaitList<'_> ) -> Result<GetEvent<'scope, T, C>>where T: 'static + Send,

Reads the contents of the buffer at the specified index, blocking the current thread until the operation has completed.

source

pub fn read<'scope, 'env, R: IntoRange>( &'env self, scope: &'scope Scope<'scope, 'env, C>, range: R, wait: WaitList<'_> ) -> Result<ReadEvent<'scope, T, C>>

Reads the contents of the buffer.

source

pub fn read_blocking<R: IntoRange>( &self, range: R, wait: WaitList<'_> ) -> Result<Vec<T>>

Reads the contents of the buffer, blocking the current thread until the operation has completed.

source

pub fn read_into<'scope, 'env, O: Into<Option<usize>>>( &'env self, s: &'scope Scope<'scope, 'env, C>, offset: O, dst: &'env mut [T], wait: WaitList<'_> ) -> Result<ReadIntoEvent<'scope, T, C>>

Reads the contents of the buffer into dst.

source

pub fn read_into_blocking( &self, offset: impl Into<Option<usize>>, dst: &mut [T], wait: WaitList<'_> ) -> Result<()>

Reads the contents of the buffer into dst, blocking the current thread until the operation has completed.

source

pub fn write<'scope, 'env, O: Into<Option<usize>>>( &'env mut self, scope: &'scope Scope<'scope, 'env, C>, offset: O, src: &'env [T], wait: WaitList<'_> ) -> Result<WriteEvent<'scope, T, C>>

Writes the contents of src into the buffer

source

pub fn write_blocking( &mut self, offset: impl Into<Option<usize>>, src: &[T], wait: WaitList<'_> ) -> Result<()>

Writes the contents of src into the buffer, blocking the current thread until the operation has completed.

source

pub fn copy_to<'scope, 'env, Src: Into<Option<usize>>, Dst: Into<Option<usize>>, Size: Into<Option<usize>>>( &'env self, scope: &'scope Scope<'scope, 'env, C>, src_offset: Src, dst: &'env mut Self, dst_offset: Dst, size: Size, wait: WaitList<'_> ) -> Result<CopyEvent<'scope, T, C>>

Copies the contents from self to dst

source

pub fn copy_to_blocking( &self, src_offset: impl Into<Option<usize>>, dst: &mut Self, dst_offset: impl Into<Option<usize>>, size: impl Into<Option<usize>>, wait: WaitList<'_> ) -> Result<()>

Copies the contents from self to dst, blocking the current thread until the operation has completed.

source

pub fn copy_from<'scope, 'env, Dst: Into<Option<usize>>, Src: Into<Option<usize>>, Size: Into<Option<usize>>>( &'env mut self, s: &'scope Scope<'scope, 'env, C>, dst_offset: Dst, src: &'env Self, src_offset: Src, size: Size, wait: WaitList<'_> ) -> Result<CopyEvent<'scope, T, C>>

Copies the contents from src to self

source

pub fn copy_from_blocking( &mut self, dst_offset: impl Into<Option<usize>>, src: &Self, src_offset: impl Into<Option<usize>>, size: impl Into<Option<usize>>, wait: WaitList<'_> ) -> Result<()>

Copies the contents from src to self, blocking the current thread until the operation has completed.

source

pub fn fill<'scope, 'env, R: IntoRange>( &'env mut self, scope: &'scope Scope<'scope, 'env, C>, v: T, range: R, wait: WaitList<'_> ) -> Result<FillEvent<'scope, T, C>>

Available on crate feature cl1_2 only.

Fills a region of the buffer with v

source

pub fn fill_blocking<R: IntoRange>( &mut self, v: T, range: R, wait: WaitList<'_> ) -> Result<()>

Available on crate feature cl1_2 only.

Fills a region of the buffer with v, blocking the current thread until the operation has completed.

source

pub fn map<'scope, 'env, R: IntoRange>( &'env self, s: &'scope Scope<'scope, 'env, C>, range: R, wait: WaitList<'_> ) -> Result<BufferMapEvent<'scope, 'env, T, C>>

source

pub fn map_blocking<'a, R: IntoRange>( &'a self, range: R, wait: WaitList<'_> ) -> Result<MapGuard<'a, T, C>>

source

pub fn map_mut<'scope, 'env, R: IntoRange>( &'env mut self, s: &'scope Scope<'scope, 'env, C>, range: R, wait: WaitList<'_> ) -> Result<BufferMapMutEvent<'scope, 'env, T, C>>

source

pub fn map_mut_blocking<'a, R: IntoRange>( &'a mut self, range: R, wait: WaitList<'_> ) -> Result<MapMutGuard<'a, T, C>>

Methods from Deref<Target = RawBuffer>§

source

pub unsafe fn create_sub_buffer( &self, flags: MemAccess, region: BufferRange ) -> Result<RawBuffer>

Creates a new buffer object (referred to as a sub-buffer object) from an existing buffer object.

source

pub unsafe fn read_to_ptr( &self, range: BufferRange, dst: *mut c_void, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn read_rect_to_ptr( &self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, dst: *mut c_void, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn write_from_ptr( &mut self, range: BufferRange, src: *const c_void, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn write_rect_from_ptr( &mut self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, src: *const c_void, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn copy_from( &mut self, dst_offset: usize, src: &RawBuffer, src_offset: usize, size: usize, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn fill_raw<T: Copy>( &mut self, v: T, range: BufferRange, wait: WaitList<'_> ) -> Result<RawEvent>

Available on crate feature cl1_2 only.
source

pub unsafe fn map_read( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*const c_void, RawEvent)>

source

pub unsafe fn map_write( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>

source

pub unsafe fn map_read_write( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>

source

pub unsafe fn read_to_ptr_in( &self, range: BufferRange, dst: *mut c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

Reads the contents of this

source

pub unsafe fn read_rect_to_ptr_in( &self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, dst: *mut c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn write_from_ptr_in( &mut self, range: BufferRange, src: *const c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn write_rect_from_ptr_in( &mut self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, src: *const c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn copy_from_in( &mut self, dst_offset: usize, src: &RawBuffer, src_offset: usize, size: usize, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn copy_from_rect_raw_in( &mut self, dst_origin: [usize; 3], src_origin: [usize; 3], region: [usize; 3], dst_row_pitch: Option<usize>, dst_slice_pitch: Option<usize>, src_row_pitch: Option<usize>, src_slice_pitch: Option<usize>, src: &RawBuffer, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

source

pub unsafe fn fill_raw_in<T>( &mut self, v: T, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>

Available on crate feature cl1_2 only.
source

pub unsafe fn map_read_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*const c_void, RawEvent)>

source

pub unsafe fn map_write_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>

source

pub unsafe fn map_read_write_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>

Methods from Deref<Target = RawMemObject>§

source

pub unsafe fn retain(&self) -> Result<()>

source

pub fn id(&self) -> cl_mem

source

pub fn id_ref(&self) -> &cl_mem

source

pub fn id_ref_mut(&mut self) -> &mut cl_mem

source

pub fn ty(&self) -> Result<MemObjectType>

Returns the memory obejct’s type

source

pub fn associated_memobject(&self) -> Result<Option<RawMemObject>>

Return memory object from which memobj is created.

source

pub fn flags(&self) -> Result<MemFlags>

Return the flags argument value specified when memobj is created.

source

pub fn size(&self) -> Result<usize>

Return actual size of the data store associated with memobj in bytes.

source

pub fn host_ptr(&self) -> Result<Option<NonNull<c_void>>>

If memobj is created with a host_ptr specified, return the host_ptr argument value specified when memobj is created.

source

pub fn map_count(&self) -> Result<u32>

Map count. The map count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for debugging.

source

pub fn reference_count(&self) -> Result<u32>

Return memobj reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.

source

pub fn context(&self) -> Result<RawContext>

Return context specified when memory object is created.

source

pub fn offset(&self) -> Result<usize>

Return offset if memobj is a sub-buffer object created using create_sub_buffer. Returns 0 if memobj is not a subbuffer object.

source

pub fn uses_svm_pointer(&self) -> Result<bool>

Available on crate feature cl2 only.

Return true if memobj is a buffer object that was created with CL_MEM_USE_HOST_PTR or is a sub-buffer object of a buffer object that was created with CL_MEM_USE_HOST_PTR and the host_ptr specified when the buffer object was created is a SVM pointer; otherwise returns false.

source

pub fn on_destruct(&self, f: impl 'static + FnOnce() + Send) -> Result<()>

Adds a callback to be executed when the memory object is destructed by OpenCL.

source

pub fn on_destruct_boxed(&self, f: Box<dyn FnOnce() + Send>) -> Result<()>

source

pub unsafe fn on_destruct_raw( &self, f: unsafe extern "C" fn(memobj: cl_mem, user_data: *mut c_void), user_data: *mut c_void ) -> Result<()>

Trait Implementations§

source§

impl<T: Debug, C: Context> Debug for BufMut<'_, T, C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T, C: Context> Deref for BufMut<'a, T, C>

§

type Target = Buffer<T, C>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, T, C: Context> DerefMut for BufMut<'a, T, C>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T: PartialEq, C: Context> PartialEq<BufMut<'_, T, C>> for BufMut<'_, T, C>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq, C: Context> Eq for BufMut<'_, T, C>

Auto Trait Implementations§

§

impl<'a, T, C> RefUnwindSafe for BufMut<'a, T, C>where C: RefUnwindSafe, T: RefUnwindSafe,

§

impl<'a, T, C> Send for BufMut<'a, T, C>where C: Send, T: Send,

§

impl<'a, T, C> Sync for BufMut<'a, T, C>where C: Sync, T: Sync,

§

impl<'a, T, C> Unpin for BufMut<'a, T, C>where C: Unpin, T: Unpin,

§

impl<'a, T, C = Global> !UnwindSafe for BufMut<'a, T, C>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsMem for Twhere T: Deref<Target = impl AsMem + 'static>,

source§

impl<T> AsMutMem for Twhere T: DerefMut<Target = impl AsMutMem + 'static>,

source§

fn as_mut_mem(&mut self) -> &mut RawMemObject

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.