Top | ![]() |
![]() |
![]() |
![]() |
GoclProgram * | gocl_program_new () |
GoclProgram * | gocl_program_new_from_file_sync () |
GoclContext * | gocl_program_get_context () |
GoclKernel * | gocl_program_get_kernel () |
gboolean | gocl_program_build_sync () |
void | gocl_program_build () |
gboolean | gocl_program_build_finish () |
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.
Alternative;y, gocl_program_new_from_file_sync()
can be used for simple cases
when source code is in a single file.
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.
GoclProgram * gocl_program_new (GoclContext *context
,const gchar **sources
,guint num_sources
);
Creates and returns a new GoclProgram. Upon error, NULL
is returned.
context |
The GoclContext |
|
sources |
Array of source code null-terminated strings. |
[array length=num_sources][type utf8] |
num_sources |
The number of elements in |
GoclProgram * gocl_program_new_from_file_sync (GoclContext *context
,const gchar *filename
);
Creates and returns a new GoclProgram. This is a convenient constructor for
cases when there is only one file containing the source code. Upon error,
NULL
is returned.
GoclContext *
gocl_program_get_context (GoclProgram *self
);
Obtain the GoclContext the program belongs to.
GoclKernel * gocl_program_get_kernel (GoclProgram *self
,const gchar *kernel_name
);
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.
gboolean gocl_program_build_sync (GoclProgram *self
,const gchar *options
);
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.
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
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 |
[allow-none] |
callback |
Callback to be called upon completion, or |
[allow-none] |
user_data |
Arbitrary data to pass in |
[allow-none] |
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 |
[out][allow-none] |
“context”
property“context” GoclContext *
The OpenCL context.
Flags: Read / Write / Construct Only