Struct ocl::ProQue

source ·
pub struct ProQue { /* private fields */ }
Expand description

An all-in-one chimera of the Program, Queue, Context and (optionally) SpatialDims types.

Handy when you only need a single context, program, and queue for your project or when using a unique context and program on each device.

All ProQue functionality is also provided separately by the Context, Queue, Program, and SpatialDims types.

§Creation

There are two ways to create a ProQue:

  1. [Recommended] Use ProQue::builder or ProQueBuilder::new().
  2. Call ::new and pass pre-created components.

§Destruction

Now handled automatically. Freely use, store, clone, discard, share among threads… put some on your toast… whatever.

Implementations§

source§

impl ProQue

source

pub fn builder<'b>() -> ProQueBuilder<'b>

Returns a new ProQueBuilder.

This is the recommended way to create a new ProQue.

Calling ProQueBuilder::build() will return a new ProQue.

source

pub fn new<D: Into<SpatialDims>>( context: Context, queue: Queue, program: Program, dims: Option<D> ) -> ProQue

Creates a new ProQue from individual parts.

Use ::builder instead unless you know what you’re doing. Creating from components associated with different devices or contexts will cause errors later on.

source

pub fn kernel_builder<S>(&self, name: S) -> KernelBuilder<'_>
where S: Into<String>,

Returns a new KernelBuilder with the name, program, default queue, and global work size pre-configured.

Use ::arg to specify arguments and ::build to build the kernel.

§Example
let kernel = pro_que.kernel_builder("add")
   .arg(&buffer)
   .arg(&10.0f32)
   .build()?;

See KernelBuilder documentation for more

source

pub fn create_buffer<T: OclPrm>(&self) -> OclResult<Buffer<T>>

Returns a new buffer.

The default dimensions and queue from this ProQue will be used.

The buffer will be filled with zeros upon creation, blocking the current thread until completion.

Use Buffer::builder() (or BufferBuilder::new()) for access to the full range of buffer creation options.

§Errors

This ProQue must have been pre-configured with default dimensions. If not, set them with ::set_dims, or just create a buffer using Buffer::builder() instead.

source

pub fn buffer_builder<T: OclPrm>(&self) -> BufferBuilder<'_, T>

Returns a new BufferBuilder with the default queue and length pre-configured.

Use .fill_val(Default::default()) to fill buffer with zeros.

Use .build() to create the buffer.

§Panics

This ProQue must have been pre-configured with default dimensions. If not, set them with ::set_dims, or just create a buffer using Buffer::builder() instead.

source

pub fn set_dims<S: Into<SpatialDims>>(&mut self, dims: S)

Sets the default dimensions used when creating buffers and kernels.

source

pub fn max_wg_size(&self) -> OclResult<usize>

Returns the maximum workgroup size supported by the device associated with this ProQue.

[UNSTABLE]: Evaluate usefulness.

source

pub fn queue(&self) -> &Queue

Returns a reference to the queue associated with this ProQue.

source

pub fn context(&self) -> &Context

Returns the contained context.

source

pub fn program(&self) -> &Program

Returns the current program build.

source

pub fn dims(&self) -> &SpatialDims

Returns the current dims or panics.

[UNSTABLE]: Evaluate which ‘dims’ method to keep. Leaning towards this version at the moment.

source

pub fn dims_result(&self) -> OclResult<&SpatialDims>

Returns the current dims or an error.

[UNSTABLE]: Evaluate which ‘dims’ method to keep. Leaning towards the above, panicking version at the moment.

Methods from Deref<Target = Queue>§

source

pub fn flush(&self) -> OclResult<()>

Issues all previously queued OpenCL commands to the device.

source

pub fn finish(&self) -> OclResult<()>

Blocks until all commands in this queue have completed before returning.

source

pub fn enqueue_marker<Ewl>(&self, ewait: Option<Ewl>) -> OclResult<Event>
where Ewl: ClWaitListPtr,

Enqueues a marker command which waits for either a list of events to complete, or all previously enqueued commands to complete.

source

pub fn as_core(&self) -> &CommandQueueCore

Returns a reference to the core pointer wrapper, usable by functions in the core module.

source

pub fn context(&self) -> Context

Returns a copy of the Context associated with this queue.

source

pub fn device(&self) -> Device

Returns the OpenCL device associated with this queue.

source

pub fn device_version(&self) -> OpenclVersion

Returns the cached device version.

source

pub fn info( &self, info_kind: CommandQueueInfo ) -> OclCoreResult<CommandQueueInfoResult>

Returns info about this queue.

Methods from Deref<Target = CommandQueueCore>§

source

pub fn as_ptr(&self) -> *mut c_void

Returns a pointer, do not store it.

source

pub fn device(&self) -> Result<DeviceId, Error>

Returns the DeviceId associated with this command queue.

source

pub fn context(&self) -> Result<Context, Error>

Returns the Context associated with this command queue.

source

pub fn context_ptr(&self) -> Result<*mut c_void, Error>

Returns the cl_context associated with this command queue.

Trait Implementations§

source§

impl Clone for ProQue

source§

fn clone(&self) -> ProQue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ProQue

source§

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

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

impl Deref for ProQue

§

type Target = Queue

The resulting type after dereferencing.
source§

fn deref(&self) -> &Queue

Dereferences the value.
source§

impl MemLen for ProQue

source§

fn to_len(&self) -> usize

Returns the exact number of elements of a volume of memory (equivalent to Vec::len()).
source§

fn to_len_padded(&self, incr: usize) -> usize

Returns the length of a volume of memory padded to the next multiple of incr.
source§

fn to_lens(&self) -> [usize; 3]

Returns the exact lengths of each dimension of a volume of memory.
source§

impl WorkDims for ProQue

source§

fn dim_count(&self) -> u32

Returns the number of dimensions defined.
source§

fn to_work_size(&self) -> Option<[usize; 3]>

Returns an array representing the amount of work to be done by a kernel. Read more
source§

fn to_work_offset(&self) -> Option<[usize; 3]>

Returns an array representing the offset of a work item or memory location. Read more

Auto Trait Implementations§

§

impl Freeze for ProQue

§

impl RefUnwindSafe for ProQue

§

impl Send for ProQue

§

impl Sync for ProQue

§

impl Unpin for ProQue

§

impl UnwindSafe for ProQue

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.