Struct blaze_rs::buffer::Buf

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

An immutable slice of a Buffer

Implementations§

source§

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

source

pub fn new<R: IntoRange>(parent: &'a 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 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 as_uninit(&self) -> &Buffer<MaybeUninit<T>, C>

Converts &Buffer<T,C> to &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 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 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 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>>

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 Buf<'_, 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 Buf<'a, T, C>

§

type Target = Buffer<T, C>

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<T: PartialEq, C: Context> PartialEq<Buf<'_, T, C>> for Buf<'_, 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 Buf<'_, T, C>

Auto Trait Implementations§

§

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

§

impl<'a, T, C> Send for Buf<'a, T, C>where C: Send + Sync, T: Send + Sync,

§

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

§

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

§

impl<'a, T, C> UnwindSafe for Buf<'a, T, C>where C: UnwindSafe + RefUnwindSafe, T: UnwindSafe + RefUnwindSafe,

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> 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.