GoclKernel

GoclKernel — Object that represents an OpenCL kernel

Stability Level

Unstable, unless otherwise indicated

Synopsis

struct              GoclKernel;
struct              GoclKernelClass;
cl_kernel           gocl_kernel_get_kernel              (GoclKernel *self);
GoclEvent *         gocl_kernel_run_in_device           (GoclKernel *self,
                                                         GoclDevice *device,
                                                         gsize global_work_size,
                                                         gsize local_work_size,
                                                         GList *event_wait_list);
gboolean            gocl_kernel_run_in_device_sync      (GoclKernel *self,
                                                         GoclDevice *device,
                                                         gsize global_work_size,
                                                         gsize local_work_size,
                                                         GList *event_wait_list,
                                                         GError **error);
gboolean            gocl_kernel_set_argument            (GoclKernel *self,
                                                         guint index,
                                                         gsize size,
                                                         const gpointer *buffer,
                                                         GError **error);
gboolean            gocl_kernel_set_argument_buffer     (GoclKernel *self,
                                                         guint index,
                                                         GoclBuffer *buffer,
                                                         GError **error);
gboolean            gocl_kernel_set_argument_int32      (GoclKernel *self,
                                                         guint index,
                                                         gsize num_elements,
                                                         gint32 *buffer,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GoclKernel

Implemented Interfaces

GoclKernel implements GInitable.

Properties

  "name"                     gchar*                : Read / Write / Construct Only
  "program"                  GoclProgram*          : Read / Write / Construct Only

Description

A GoclKernel object represents a special type of functions in OpenCL programs, that allows for host code to set its arguments and invoke the function.

A GoclKernel is not created directly. Instead, it is obtained from a GoclProgram by calling gocl_program_get_kernel() method.

Before a kernel object can be executed, all its arguments must be set. Several methods are provided for this purpose, and depending on the type of the argument to set, one or other is used. gocl_kernel_set_argument(), gocl_kernel_set_argument_int32() and gocl_kernel_set_argument_buffer() are examples of such methods. More will be added soon.

Once all arguments are set, the kernel is ready to be executed on a device. For this, the gocl_kernel_run_in_device() is used for non-blocking execution, and gocl_kernel_run_in_device_sync() for a blocking version. Notice that these methods will use the device's default command queue. In the future, methods will be provided to run the kernel on arbitrary command queues as well.

Details

struct GoclKernel

struct GoclKernel;


struct GoclKernelClass

struct GoclKernelClass {
  GObjectClass parent_class;
};

The class for GoclKernel objects.

GObjectClass parent_class;

The parent class

gocl_kernel_get_kernel ()

cl_kernel           gocl_kernel_get_kernel              (GoclKernel *self);

Retrieves the internal OpenCL cl_kernel object. This is not normally called by applications. It is rather a low-level, internal API.

self :

The GoclKernel

Returns :

The internal cl_kernel object. [transfer none][type guint64]

gocl_kernel_run_in_device ()

GoclEvent *         gocl_kernel_run_in_device           (GoclKernel *self,
                                                         GoclDevice *device,
                                                         gsize global_work_size,
                                                         gsize local_work_size,
                                                         GList *event_wait_list);

Runs the kernel on the specified device, asynchronously. A GoclEvent is returned, and can be used to get notified when the execution finishes, or as wait event input to other operations on the device.

If event_wait_list is provided, the kernel execution will start only when all the events in the list have triggered.

self :

The GoclKernel

device :

A GoclDevice to run the kernel on

global_work_size :

The global work group size

local_work_size :

The local work group size

event_wait_list :

List of GoclEvent events to wait for, or NULL. [element-type Gocl.Event][allow-none]

Returns :

A GoclEvent to get notified when execution finishes. [transfer none]

gocl_kernel_run_in_device_sync ()

gboolean            gocl_kernel_run_in_device_sync      (GoclKernel *self,
                                                         GoclDevice *device,
                                                         gsize global_work_size,
                                                         gsize local_work_size,
                                                         GList *event_wait_list,
                                                         GError **error);

Runs the kernel on the specified device, blocking the program until the kernel execution finishes. For non-blocking version, gocl_kernel_run_in_device() is provided.

If event_wait_list is provided, the kernel execution will start only when all the events in the list have triggered.

self :

The GoclKernel

device :

A GoclDevice to run the kernel on

global_work_size :

The global work group size

local_work_size :

The local work group size

event_wait_list :

List of GoclEvent events to wait for, or NULL. [element-type Gocl.Event][allow-none]

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

gocl_kernel_set_argument ()

gboolean            gocl_kernel_set_argument            (GoclKernel *self,
                                                         guint index,
                                                         gsize size,
                                                         const gpointer *buffer,
                                                         GError **error);

Sets the value of the kernel argument at index, as an arbitrary block of memory.

self :

The GoclKernel

index :

The index of this argument in the kernel function

size :

The size of buffer, in bytes

buffer :

A pointer to an arbitrary block of memory

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

gocl_kernel_set_argument_buffer ()

gboolean            gocl_kernel_set_argument_buffer     (GoclKernel *self,
                                                         guint index,
                                                         GoclBuffer *buffer,
                                                         GError **error);

Sets the value of the kernel argument at index, as a buffer object.

self :

The GoclKernel

index :

The index of this argument in the kernel function

buffer :

A GoclBuffer

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

gocl_kernel_set_argument_int32 ()

gboolean            gocl_kernel_set_argument_int32      (GoclKernel *self,
                                                         guint index,
                                                         gsize num_elements,
                                                         gint32 *buffer,
                                                         GError **error);

Sets the value of the kernel argument at index, as an array of int32.

self :

The GoclKernel

index :

The index of this argument in the kernel function

num_elements :

The number of int32 elements in buffer

buffer :

Array of int32 values. [array length=num_elements][element-type guint32]

error :

A pointer to a GError, or NULL. [out][allow-none]

Returns :

TRUE on success, FALSE on error

Property Details

The "name" property

  "name"                     gchar*                : Read / Write / Construct Only

The name of the kernel function.

Default value: NULL


The "program" property

  "program"                  GoclProgram*          : Read / Write / Construct Only

The program owning this kernel.