GoclProgram

GoclProgram — Object that represents an OpenCL program

Stability Level

Unstable, unless otherwise indicated

Synopsis

struct              GoclProgram;
struct              GoclProgramClass;
void                gocl_program_build                  (GoclProgram *self,
                                                         const gchar *options,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            gocl_program_build_finish           (GoclProgram *self,
                                                         GAsyncResult *result,
                                                         GError **error);
gboolean            gocl_program_build_sync             (GoclProgram *self,
                                                         const gchar *options,
                                                         GError **error);
GoclContext *       gocl_program_get_context            (GoclProgram *self);
GoclKernel *        gocl_program_get_kernel             (GoclProgram *self,
                                                         const gchar *kernel_name,
                                                         GError **error);
cl_program          gocl_program_get_program            (GoclProgram *self);
GoclProgram *       gocl_program_new                    (GoclContext *context,
                                                         const gchar **sources,
                                                         guint num_sources,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GoclProgram

Properties

  "context"                  GoclContext*          : Read / Write / Construct Only

Description

A GoclProgram allows to transform OpenCL source code into kernel objects that can run on OpenCL runtimes.

A GoclProgram is created with gocl_program_new(), provinding a null-terminated array of strings, each one representing OpenCL source code. Currently, creating a program from pre-compiled, binary code is not supported, but will be in the future.

Once a program is created, it needs to be built before kernels can be created from it. To build a program asynchronously, gocl_program_build() and gocl_program_build_finish() methods are provided. For building synchronously, gocl_program_build_sync() is used.

Once a program is successfully built, kernels can be obtained from it using gocl_program_get_kernel() method.

Details

struct GoclProgram

struct GoclProgram;


struct GoclProgramClass

struct GoclProgramClass {
  GObjectClass parent_class;
};

The class for GoclProgram objects.

GObjectClass parent_class;

The parent class

gocl_program_build ()

void                gocl_program_build                  (GoclProgram *self,
                                                         const gchar *options,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Builds the program using the build options specified in options. This method is non-blocking. If callback is provided, it will be called when the operation completes, and gocl_program_build_finish() can be used within the callback to retrieve the result of the operation.

A GCancellable object can be passed in cancellable to allow cancelling the operation.

self :

The GoclProgram

options :

A string specifying OpenCL program build options

cancellable :

A GCancellable object, or NULL. [allow-none]

callback :

Callback to be called upon completion, or NULL. [allow-none]

user_data :

Arbitrary data to pass in callback, or NULL. [allow-none]

gocl_program_build_finish ()

gboolean            gocl_program_build_finish           (GoclProgram *self,
                                                         GAsyncResult *result,
                                                         GError **error);

Retrieves the result of a gocl_program_build() asynchronous operation. On error, FALSE is returned and error is filled accordingly.

self :

The GoclProgram

result :

The GAsyncResult object from callback's arguments

error :

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

Returns :

TRUE on success, or FALSE on error

gocl_program_build_sync ()

gboolean            gocl_program_build_sync             (GoclProgram *self,
                                                         const gchar *options,
                                                         GError **error);

Builds the program using the build options specified in options. This method is blocking. For an asynchronous version, gocl_program_build() is provided. On error, FALSE is returned and error is filled accordingly.

A detailed description of the build options is available at Kronos documentation website: http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clBuildProgram.html

self :

The GoclProgram

options :

A string specifying OpenCL program build options

error :

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

Returns :

TRUE on success or FALSE on error

gocl_program_get_context ()

GoclContext *       gocl_program_get_context            (GoclProgram *self);

Obtain the GoclContext the program belongs to.

self :

The GoclProgram

Returns :

A GoclContext. The returned object is owned by the program, do not free. [transfer none]

gocl_program_get_kernel ()

GoclKernel *        gocl_program_get_kernel             (GoclProgram *self,
                                                         const gchar *kernel_name,
                                                         GError **error);

Creates and retrieves a new GoclKernel object from a kernel function in the source code, specified by kernel_name string. Upon success, a new GoclKernel is returned, otherwise NULL is returned and error is filled accordingly.

self :

The GoclProgram

kernel_name :

A string representing the name of a kernel function

error :

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

Returns :

A newly created GoclKernel object. [transfer full]

gocl_program_get_program ()

cl_program          gocl_program_get_program            (GoclProgram *self);

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

self :

The GoclProgram

Returns :

The internal cl_program. [transfer none][type guint64]

gocl_program_new ()

GoclProgram *       gocl_program_new                    (GoclContext *context,
                                                         const gchar **sources,
                                                         guint num_sources,
                                                         GError **error);

Creates and returns a new GoclProgram. Upon error, NULL is returned and error is filled accordingly.

context :

The GoclContext

sources :

Array of source code null-terminated strings. [array length=num_sources][type utf8]

num_sources :

The number of elements in sources

error :

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

Returns :

A newly created GoclProgram. [transfer full]

Property Details

The "context" property

  "context"                  GoclContext*          : Read / Write / Construct Only

The OpenCL context.