Struct ocl::Kernel [] [src]

pub struct Kernel { /* fields omitted */ }

A kernel which represents a 'procedure'.

Corresponds to code which must have already been compiled into a program.

Set arguments using ::set_arg or any of the ::set_arg... methods.

Kernel includes features that a raw OpenCL kernel does not, including:

  1. Type-checked arguments (not just size-checked)
  2. Named arguments (with a &'static str name)
  3. Prevention of a potential (difficult to debug) segfault if a buffer or image used by a kernel is dropped prematurely.
  4. Stored defaults for the:
    • Queue
    • Global Work Offset
    • Global Work Size
    • Local Work Size

Clone and Send

A Kernel may not be cloned but may be sent between threads. This ensures that no two threads create a race condition by attempting to set an argument and enqueue a kernel at the same time. Use the KernelBuilder to create multiple identical kernels (KernelBuilder is clonable and re-usable).

Methods

impl Kernel
[src]

[src]

Returns a new KernelBuilder.

[src]

Returns the argument index of a named argument if it exists.

[src]

Sets an argument by index without checks of any kind.

Setting buffer or image (cl_mem) arguments this way may cause segfaults or errors if the buffer goes out of scope at any point before this kernel is dropped.

This also bypasses the check to determine if the type of the value you pass here matches the type defined in your kernel.

[src]

Sets a Buffer, Image, scalar, or vector argument by index or by name.

Example

This example is not tested
// Create a kernel with arguments corresponding to those in the kernel.
// Just for fun, one argument will be 'named':
let kern = ocl_pq.kernel_builder("multiply_by_scalar")
    .arg(&0)
    .arg(None::<&Buffer<f32>>)
    .arg_named("result", None::<&Buffer<f32>>)
    .build()?;

// Set our named argument. The Option<_> wrapper is, well... optional:
kern.set_arg("result", &result_buffer)?;
// We can also set arguments (named or not) by index. Just for
// demonstration, we'll set one using an option:
kern.set_arg(0, &COEFF)?;
kern.set_arg(1, Some(&source_buffer))?;
kern.set_arg(2, &result_buffer)?;

[src]

Deprecated since 0.18.0

: Use ::set_arg instead.

Modifies the kernel argument named: name.

[src]

Deprecated since 0.18.0

: Use ::set_arg instead.

Modifies the kernel argument named: name.

[src]

Deprecated since 0.18.0

: Use ::set_arg_sampler_named instead.

Sets the value of a named sampler argument.

[src]

Deprecated since 0.18.0

: Use ::set_arg instead.

Modifies the kernel argument named: name.

[src]

Deprecated since 0.18.0

: Use ::set_arg instead.

Modifies the kernel argument named: name.

[src]

Sets the value of a named sampler argument.

[src]

Returns a command builder which is used to chain parameters of an 'enqueue' command together.

[src]

Enqueues this kernel on the default queue using the default work sizes and offsets.

Shorthand for .cmd().enq()

Safety

All kernel code must be considered untrusted. Therefore the act of calling this function contains implied unsafety even though the API itself is safe.

[src]

Changes the default queue.

Returns a ref for chaining i.e.:

kernel.set_default_queue(queue).enqueue(....);

Even when used as above, the queue is changed permanently, not just for the one call. Changing the queue is cheap so feel free to change as often as needed.

If you want to change the queue for only a single call, use: ::cmd.queue(...)...enq()...

The new queue must be associated with a device associated with the kernel's program.

[src]

Deprecated since 0.18.0

: Use ::global_work_offset instead.

Returns the default global work offset.

[src]

Deprecated since 0.18.0

: Use ::global_work_size instead.

Returns the default global work size.

[src]

Deprecated since 0.18.0

: Use ::local_work_size instead.

Returns the default local work size.

[src]

Sets the default global work offset.

[src]

Sets the default global work size.

[src]

Sets the default local work size.

[src]

Returns the default queue for this kernel if one has been set.

[src]

Returns the default global work offset.

[src]

Returns the default global work size.

[src]

Returns the default local work size.

[src]

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

[src]

Returns information about this kernel.

[src]

Returns work group information for this kernel.

[src]

Returns argument information for this kernel.

[src]

Returns the name of this kernel.

[src]

Returns the number of arguments this kernel has.

Methods from Deref<Target = KernelCore>

[src]

Returns a pointer, do not store it.

[src]

Returns the program associated with this kernel.

[src]

Trait Implementations

impl Debug for Kernel
[src]

[src]

Formats the value using the given formatter. Read more

impl Display for Kernel
[src]

[src]

Formats the value using the given formatter. Read more

impl Deref for Kernel
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Clone for Kernel
[src]

[src]

Creates a new, identical kernel.

1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Kernel

impl !Sync for Kernel