cf4ocl (C Framework for OpenCL)
v2.1.0
Object-oriented framework for developing and benchmarking OpenCL projects in C/C++
|
The program wrapper module provides functionality for simple handling of OpenCL program objects. More...
Macros | |
#define | ccl_program_get_build_info(prg, dev, param_name, err) |
Get a CCLWrapperInfo program build information object. More... | |
#define | ccl_program_get_build_info(prg, dev, param_name, err) |
Get a CCLWrapperInfo program build information object. More... | |
#define | ccl_program_get_build_info_array(prg, dev, param_name, param_type, err) |
Macro which returns an array program build information value. More... | |
#define | ccl_program_get_build_info_array(prg, dev, param_name, param_type, err) |
Macro which returns an array program build information value. More... | |
#define | ccl_program_get_build_info_scalar(prg, dev, param_name, param_type, err) |
Macro which returns a scalar program build information value. More... | |
#define | ccl_program_get_build_info_scalar(prg, dev, param_name, param_type, err) |
Macro which returns a scalar program build information value. More... | |
#define | ccl_program_get_info(prg, param_name, err) |
Get a CCLWrapperInfo program information object. More... | |
#define | ccl_program_get_info(prg, param_name, err) |
Get a CCLWrapperInfo program information object. More... | |
#define | ccl_program_get_info_array(prg, param_name, param_type, err) |
Macro which returns an array program information value. More... | |
#define | ccl_program_get_info_array(prg, param_name, param_type, err) |
Macro which returns an array program information value. More... | |
#define | ccl_program_get_info_scalar(prg, param_name, param_type, err) |
Macro which returns a scalar program information value. More... | |
#define | ccl_program_get_info_scalar(prg, param_name, param_type, err) |
Macro which returns a scalar program information value. More... | |
#define | ccl_program_ref(prg) ccl_wrapper_ref((CCLWrapper*) prg) |
Increase the reference count of the program object. More... | |
#define | ccl_program_ref(prg) ccl_wrapper_ref((CCLWrapper*) prg) |
Increase the reference count of the program object. More... | |
#define | ccl_program_unref(prg) ccl_program_destroy(prg) |
Alias to ccl_program_destroy(). More... | |
#define | ccl_program_unref(prg) ccl_program_destroy(prg) |
Alias to ccl_program_destroy(). More... | |
#define | ccl_program_unwrap(prg) ((cl_program) ccl_wrapper_unwrap((CCLWrapper*) prg)) |
Get the OpenCL program object. More... | |
#define | ccl_program_unwrap(prg) ((cl_program) ccl_wrapper_unwrap((CCLWrapper*) prg)) |
Get the OpenCL program object. More... | |
Typedefs | |
typedef void(* | ccl_program_callback )(cl_program program, void *user_data) |
Prototype of callback functions for program build, compile and link. More... | |
typedef void(* | ccl_program_callback )(cl_program program, void *user_data) |
Prototype of callback functions for program build, compile and link. More... | |
typedef struct ccl_program | CCLProgram |
Program wrapper class. | |
typedef struct ccl_program_binary | CCLProgramBinary |
Class which represents a binary object associated with a program and a device. More... | |
typedef struct ccl_program_binary | CCLProgramBinary |
Class which represents a binary object associated with a program and a device. More... | |
Functions | |
cl_bool | ccl_program_build (CCLProgram *prg, const char *options, CCLErr **err) |
Utility function which builds (compiles and links) a program executable from the program source or binary. More... | |
cl_bool | ccl_program_build_full (CCLProgram *prg, cl_uint num_devices, CCLDevice *const *devs, const char *options, ccl_program_callback pfn_notify, void *user_data, CCLErr **err) |
Builds (compiles and links) a program executable from the program source or binary. More... | |
cl_bool | ccl_program_compile (CCLProgram *prg, cl_uint num_devices, CCLDevice *const *devs, const char *options, cl_uint num_input_headers, CCLProgram **prg_input_headers, const char **header_include_names, ccl_program_callback pfn_notify, void *user_data, CCLErr **err) |
Compile a program's source code. More... | |
void | ccl_program_destroy (CCLProgram *prg) |
Decrements the reference count of the program wrapper object. More... | |
CCLEvent * | ccl_program_enqueue_kernel (CCLProgram *prg, const char *kernel_name, CCLQueue *cq, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, CCLEventWaitList *evt_wait_lst, CCLErr **err,...) |
Enqueues a program kernel function for execution on a device. More... | |
CCLEvent * | ccl_program_enqueue_kernel_v (CCLProgram *prg, const char *kernel_name, CCLQueue *cq, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, CCLEventWaitList *evt_wait_lst, void **args, CCLErr **err) |
Enqueues a program kernel function for execution on a device. More... | |
CCLDevice *const * | ccl_program_get_all_devices (CCLProgram *prg, CCLErr **err) |
Get all device wrappers in program. More... | |
CCLProgramBinary * | ccl_program_get_binary (CCLProgram *prg, CCLDevice *dev, CCLErr **err) |
Get the program binary object for the specified device. More... | |
const char * | ccl_program_get_build_log (CCLProgram *prg, CCLErr **err) |
Get a general build log of most recent build, compile or link, for all devices. More... | |
CCLDevice * | ccl_program_get_device (CCLProgram *prg, cl_uint index, CCLErr **err) |
Get CCLDevice wrapper at given index. More... | |
const char * | ccl_program_get_device_build_log (CCLProgram *prg, CCLDevice *dev, CCLErr **err) |
Get build log for most recent build, compile or link for the specified device. More... | |
CCLKernel * | ccl_program_get_kernel (CCLProgram *prg, const char *kernel_name, CCLErr **err) |
Get the kernel wrapper object for the given program kernel function. More... | |
cl_uint | ccl_program_get_num_devices (CCLProgram *prg, CCLErr **err) |
Return number of devices in program. More... | |
cl_uint | ccl_program_get_opencl_version (CCLProgram *prg, CCLErr **err) |
Get the OpenCL version of the platform associated with this program. More... | |
CCLProgram * | ccl_program_link (CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char *options, cl_uint num_input_programs, CCLProgram **input_prgs, ccl_program_callback pfn_notify, void *user_data, CCLErr **err) |
Link a set of compiled programs and create an executable program wrapper. More... | |
CCLProgram * | ccl_program_new_from_binaries (CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, CCLProgramBinary **bins, cl_int *binary_status, CCLErr **err) |
Create a new program wrapper object from a list of binary code strings executable on the given device list, one binary string per device. More... | |
CCLProgram * | ccl_program_new_from_binary (CCLContext *ctx, CCLDevice *dev, CCLProgramBinary *binary, cl_int *binary_status, CCLErr **err) |
Create a new program wrapper object from binary code executable on a specific device. More... | |
CCLProgram * | ccl_program_new_from_binary_file (CCLContext *ctx, CCLDevice *dev, const char *filename, cl_int *binary_status, CCLErr **err) |
Create a new program wrapper object from a file containing binary code executable on a specific device. More... | |
CCLProgram * | ccl_program_new_from_binary_files (CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char **filenames, cl_int *binary_status, CCLErr **err) |
Create a new program wrapper object from files containing binary code executable on the given device list, one file per device. More... | |
CCLProgram * | ccl_program_new_from_built_in_kernels (CCLContext *ctx, cl_uint num_devices, CCLDevice *const *devs, const char *kernel_names, CCLErr **err) |
Create a new program wrapper object from device built-in kernels. More... | |
CCLProgram * | ccl_program_new_from_source (CCLContext *ctx, const char *string, CCLErr **err) |
Create a new program wrapper object from a null-terminated source string. More... | |
CCLProgram * | ccl_program_new_from_source_file (CCLContext *ctx, const char *filename, CCLErr **err) |
Create a new program wrapper object from a source file. More... | |
CCLProgram * | ccl_program_new_from_source_files (CCLContext *ctx, cl_uint count, const char **filenames, CCLErr **err) |
Create a new program wrapper object from several source files. More... | |
CCLProgram * | ccl_program_new_from_sources (CCLContext *ctx, cl_uint count, const char **strings, const size_t *lengths, CCLErr **err) |
Create a new program wrapper object from several source code strings. More... | |
CCLProgram * | ccl_program_new_wrap (cl_program program) |
Get the program wrapper for the given OpenCL program. More... | |
cl_bool | ccl_program_save_all_binaries (CCLProgram *prg, const char *file_prefix, const char *file_suffix, char ***filenames, CCLErr **err) |
Save the program binaries for all associated devices to files, one file per device. More... | |
cl_bool | ccl_program_save_binary (CCLProgram *prg, CCLDevice *dev, const char *filename, CCLErr **err) |
Save the program binary code for a specified device to a file. More... | |
The program wrapper module provides functionality for simple handling of OpenCL program objects.
OpenCL program objects can be created from source code, from binary data or from built-in kernels using the clCreateProgramWithSource(), clCreateProgramWithBinary() or clCreateProgramWithBuiltInKernels(), respectively (the later requires OpenCL >= 1.2). cf4ocl provides a set of CCLProgram* program wrapper constructors which not only map the native OpenCL program constructors, but also extend some of their functionality.
For creating programs from source code, cf4ocl provides the following constructors:
Program constructors which use binary data follow the same pattern as their source code counterparts:
The ccl_program_new_from_built_in_kernels() constructor directly wraps the native OpenCL clCreateProgramWithBuiltInKernels() function, allowing to create programs from built-in kernels. This method is only available for platforms which support OpenCL version 1.2 or higher.
Like most cf4ocl wrapper objects, program wrapper objects follow the new/destroy rule, and should be released with the ccl_program_destroy() destructor.
The ccl_program_build() and ccl_program_build_full() methods allow to build a program executable from the program source or binary. While the later directly maps the native clBuildProgram() OpenCL function, the former provides a simpler interface which will be useful in many situations.
Compilation and linking (which require OpenCL >= 1.2) are provided by the ccl_program_compile() and ccl_program_link() functions.
Information about program objects can be obtained using the program module info macros:
However, program binaries cannot be retrieved using these macros. Consequently, cf4ocl provides a specific and straightforward API for handling them:
Program build information can be obtained using a specific set of info macros:
For simple programs and kernels, the program wrapper module offers three functions, which can be used after a program is built:
NULL
-terminated variable list of parameters.NULL
-terminated array of parameters.Program wrapper objects only keep one kernel wrapper instance per kernel function; as such, for a given kernel function, these methods will always use the same kernel wrapper instance (and consequently, the same OpenCL kernel object). While this will work for single-threaded host code, it will fail if the same kernel wrapper is invoked from different threads. In such cases, use the kernel wrapper module API for handling kernel wrapper objects.
The CCLProgram* class extends the CCLDevContainer* class; as such, it provides methods for handling a list of devices associated with the program:
Example:
Kernel code:
Host code:
#define ccl_program_get_build_info | ( | prg, | |
dev, | |||
param_name, | |||
err | |||
) |
Get a CCLWrapperInfo program build information object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 496 of file ccl_program_wrapper.h.
#define ccl_program_get_build_info | ( | prg, | |
dev, | |||
param_name, | |||
err | |||
) |
Get a CCLWrapperInfo program build information object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 496 of file ccl_program_wrapper.h.
#define ccl_program_get_build_info_array | ( | prg, | |
dev, | |||
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns an array program build information value.
Use with care. In case an error occurs, NULL is returned, which might be ambiguous if NULL is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. char*, size_t*, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 540 of file ccl_program_wrapper.h.
#define ccl_program_get_build_info_array | ( | prg, | |
dev, | |||
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns an array program build information value.
Use with care. In case an error occurs, NULL is returned, which might be ambiguous if NULL is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. char*, size_t*, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 540 of file ccl_program_wrapper.h.
#define ccl_program_get_build_info_scalar | ( | prg, | |
dev, | |||
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns a scalar program build information value.
Use with care. In case an error occurs, zero is returned, which might be ambiguous if zero is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. cl_uint, size_t, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 517 of file ccl_program_wrapper.h.
#define ccl_program_get_build_info_scalar | ( | prg, | |
dev, | |||
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns a scalar program build information value.
Use with care. In case an error occurs, zero is returned, which might be ambiguous if zero is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. cl_uint, size_t, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 517 of file ccl_program_wrapper.h.
#define ccl_program_get_info | ( | prg, | |
param_name, | |||
err | |||
) |
Get a CCLWrapperInfo program information object.
To get the program binaries use the ccl_program_get_binary() function instead, as this macro will return NULL when the CL_PROGRAM_BINARIES parameter is requested.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 427 of file ccl_program_wrapper.h.
#define ccl_program_get_info | ( | prg, | |
param_name, | |||
err | |||
) |
Get a CCLWrapperInfo program information object.
To get the program binaries use the ccl_program_get_binary() function instead, as this macro will return NULL when the CL_PROGRAM_BINARIES parameter is requested.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 427 of file ccl_program_wrapper.h.
#define ccl_program_get_info_array | ( | prg, | |
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns an array program information value.
To get the program binaries use the ccl_program_get_binary() function instead, as this macro will return NULL when the CL_PROGRAM_BINARIES parameter is requested.
Use with care. In case an error occurs, NULL is returned, which might be ambiguous if NULL is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. char*, size_t*, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 477 of file ccl_program_wrapper.h.
#define ccl_program_get_info_array | ( | prg, | |
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns an array program information value.
To get the program binaries use the ccl_program_get_binary() function instead, as this macro will return NULL when the CL_PROGRAM_BINARIES parameter is requested.
Use with care. In case an error occurs, NULL is returned, which might be ambiguous if NULL is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. char*, size_t*, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 477 of file ccl_program_wrapper.h.
#define ccl_program_get_info_scalar | ( | prg, | |
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns a scalar program information value.
Use with care. In case an error occurs, zero is returned, which might be ambiguous if zero is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. cl_uint, size_t, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 450 of file ccl_program_wrapper.h.
#define ccl_program_get_info_scalar | ( | prg, | |
param_name, | |||
param_type, | |||
err | |||
) |
Macro which returns a scalar program information value.
Use with care. In case an error occurs, zero is returned, which might be ambiguous if zero is a valid return value. In this case, it is necessary to check the error object.
[in] | prg | The program wrapper object. |
[in] | param_name | Name of information/parameter to get value of. |
[in] | param_type | Type of parameter (e.g. cl_uint, size_t, etc.). |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 450 of file ccl_program_wrapper.h.
#define ccl_program_ref | ( | prg | ) | ccl_wrapper_ref((CCLWrapper*) prg) |
Increase the reference count of the program object.
[in] | prg | The program wrapper object. |
Definition at line 551 of file ccl_program_wrapper.h.
#define ccl_program_ref | ( | prg | ) | ccl_wrapper_ref((CCLWrapper*) prg) |
Increase the reference count of the program object.
[in] | prg | The program wrapper object. |
Definition at line 551 of file ccl_program_wrapper.h.
#define ccl_program_unref | ( | prg | ) | ccl_program_destroy(prg) |
Alias to ccl_program_destroy().
[in] | prg | Program wrapper object to destroy if reference count is 1, otherwise just decrement the reference count. |
Definition at line 560 of file ccl_program_wrapper.h.
#define ccl_program_unref | ( | prg | ) | ccl_program_destroy(prg) |
Alias to ccl_program_destroy().
[in] | prg | Program wrapper object to destroy if reference count is 1, otherwise just decrement the reference count. |
Definition at line 560 of file ccl_program_wrapper.h.
#define ccl_program_unwrap | ( | prg | ) | ((cl_program) ccl_wrapper_unwrap((CCLWrapper*) prg)) |
Get the OpenCL program object.
[in] | prg | The program wrapper object. |
Definition at line 568 of file ccl_program_wrapper.h.
#define ccl_program_unwrap | ( | prg | ) | ((cl_program) ccl_wrapper_unwrap((CCLWrapper*) prg)) |
Get the OpenCL program object.
[in] | prg | The program wrapper object. |
Definition at line 568 of file ccl_program_wrapper.h.
typedef void(* ccl_program_callback)(cl_program program, void *user_data) |
Prototype of callback functions for program build, compile and link.
[in] | program | Program wrapper object. |
[in] | user_data | A pointer to user supplied data. |
Definition at line 206 of file ccl_program_wrapper.h.
typedef void(* ccl_program_callback)(cl_program program, void *user_data) |
Prototype of callback functions for program build, compile and link.
[in] | program | Program wrapper object. |
[in] | user_data | A pointer to user supplied data. |
Definition at line 206 of file ccl_program_wrapper.h.
typedef struct ccl_program_binary CCLProgramBinary |
Class which represents a binary object associated with a program and a device.
Definition at line 195 of file ccl_program_wrapper.h.
typedef struct ccl_program_binary CCLProgramBinary |
Class which represents a binary object associated with a program and a device.
Definition at line 195 of file ccl_program_wrapper.h.
cl_bool ccl_program_build | ( | CCLProgram * | prg, |
const char * | options, | ||
CCLErr ** | err | ||
) |
Utility function which builds (compiles and links) a program executable from the program source or binary.
This function calls the ccl_program_build_full() function, passing NULL
to the following parameters: devices
, pfn_notify
and user_data
. In other words, the program executable is built for all devices associated with the program and no callback function is registered.
[in] | prg | The program wrapper object. |
[in] | options | A null-terminated string of characters that describes the build options to be used for building the program executable. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
CL_TRUE
if operation is successful, or CL_FALSE
otherwise. Definition at line 818 of file ccl_program_wrapper.c.
cl_bool ccl_program_build_full | ( | CCLProgram * | prg, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
const char * | options, | ||
ccl_program_callback | pfn_notify, | ||
void * | user_data, | ||
CCLErr ** | err | ||
) |
Builds (compiles and links) a program executable from the program source or binary.
This function wraps the clBuildProgram() OpenCL function.
[in] | prg | The program wrapper object. |
[in] | num_devices | The number of devices listed in devs . |
[in] | devs | List of device wrappers associated with program. If NULL , the program executable is built for all devices associated with program for which a source or binary has been loaded. |
[in] | options | A null-terminated string of characters that describes the build options to be used for building the program executable. |
[in] | pfn_notify | A callback function that can be registered and which will be called when the program executable has been built (successfully or unsuccessfully). |
[in] | user_data | User supplied data for the callback function. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
CL_TRUE
if operation is successful, or CL_FALSE
otherwise. Definition at line 850 of file ccl_program_wrapper.c.
cl_bool ccl_program_compile | ( | CCLProgram * | prg, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
const char * | options, | ||
cl_uint | num_input_headers, | ||
CCLProgram ** | prg_input_headers, | ||
const char ** | header_include_names, | ||
ccl_program_callback | pfn_notify, | ||
void * | user_data, | ||
CCLErr ** | err | ||
) |
Compile a program's source code.
This function wraps the clCompileProgram() OpenCL function.
[in] | prg | The program wrapper that holds the program to be compiled. |
[in] | num_devices | Number of devices in devs . |
[in] | devs | List of device wrappers associated with the program. If NULL , the compile is performed for all devices associated with the program. |
[in] | options | A null-terminated string of characters that describes the compilation options to be used for building the program executable. |
[in] | num_input_headers | The number of programs wrappers that describe headers in the array referenced by prg_input_headers . |
[in] | prg_input_headers | An array of program wrapper embedded headers created with any of the ccl_program_new_from_source*() functions. |
[in] | header_include_names | An array that has a one to one correspondence with prg_input_headers . Each entry specifies the include name used by source in program that comes from an embedded header. |
[in] | pfn_notify | A function pointer to a callback function that an application can register and which will be called when the program executable has been built (successfully or unsuccessfully). |
[in] | user_data | User supplied data for the callback function. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
CL_TRUE
if operation is successful, or CL_FALSE
otherwise. Definition at line 1115 of file ccl_program_wrapper.c.
void ccl_program_destroy | ( | CCLProgram * | prg | ) |
Decrements the reference count of the program wrapper object.
If it reaches 0, the program wrapper object is destroyed.
[in] | prg | The program wrapper object. |
Definition at line 276 of file ccl_program_wrapper.c.
CCLEvent * ccl_program_enqueue_kernel | ( | CCLProgram * | prg, |
const char * | kernel_name, | ||
CCLQueue * | cq, | ||
cl_uint | work_dim, | ||
const size_t * | global_work_offset, | ||
const size_t * | global_work_size, | ||
const size_t * | local_work_size, | ||
CCLEventWaitList * | evt_wait_lst, | ||
CCLErr ** | err, | ||
... | |||
) |
Enqueues a program kernel function for execution on a device.
This is a utility function which handles one kernel wrapper instance for each kernel function name.
The operations performed by this function are equivalent to getting the program's internally kept kernel wrapper instance for the given kernel name using ccl_program_get_kernel(), and then enqueing it for execution with ccl_kernel_set_args_and_enqueue_ndrange(). that
NULL
.[in] | prg | The program wrapper object. |
[in] | kernel_name | Name of kernel function. |
[in] | cq | Command queue wrapper object where to enqueue kernel execution. |
[in] | work_dim | The number of dimensions used to specify the global work-items and work-items in the work-group. |
[in] | global_work_offset | Can be used to specify an array of work_dim unsigned values that describe the offset used to calculate the global ID of a work-item. |
[in] | global_work_size | An array of work_dim unsigned values that describe the number of global work-items in work_dim dimensions that will execute the kernel function. |
[in] | local_work_size | An array of work_dim unsigned values that describe the number of work-items that make up a work-group that will execute the specified kernel. |
[in,out] | evt_wait_lst | List of events that need to complete before this command can be executed. The list will be cleared and can be reused by client code. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
[in] | ... | A NULL -terminated list of arguments to set. |
Definition at line 1572 of file ccl_program_wrapper.c.
CCLEvent * ccl_program_enqueue_kernel_v | ( | CCLProgram * | prg, |
const char * | kernel_name, | ||
CCLQueue * | cq, | ||
cl_uint | work_dim, | ||
const size_t * | global_work_offset, | ||
const size_t * | global_work_size, | ||
const size_t * | local_work_size, | ||
CCLEventWaitList * | evt_wait_lst, | ||
void ** | args, | ||
CCLErr ** | err | ||
) |
Enqueues a program kernel function for execution on a device.
This is a utility function which handles one kernel wrapper instance for each kernel function name.
This function gets the program's internally kept kernel wrapper instance for the given kernel name using ccl_program_get_kernel(), and then enqueues it for execution with ccl_kernel_set_args_and_enqueue_ndrange_v().
[in] | prg | The program wrapper object. |
[in] | kernel_name | Name of kernel function. |
[in] | cq | Command queue wrapper object where to enqueue kernel execution. |
[in] | work_dim | The number of dimensions used to specify the global work-items and work-items in the work-group. |
[in] | global_work_offset | Can be used to specify an array of work_dim unsigned values that describe the offset used to calculate the global ID of a work-item. |
[in] | global_work_size | An array of work_dim unsigned values that describe the number of global work-items in work_dim dimensions that will execute the kernel function. |
[in] | local_work_size | An array of work_dim unsigned values that describe the number of work-items that make up a work-group that will execute the specified kernel. |
[in,out] | evt_wait_lst | List of events that need to complete before this command can be executed. The list will be cleared and can be reused by client code. |
[in] | args | A NULL -terminated array of arguments to set. Arguments must be of type CCLArg*, CCLBuffer*, CCLImage* or CCLSampler*. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 1683 of file ccl_program_wrapper.c.
CCLDevice *const * ccl_program_get_all_devices | ( | CCLProgram * | prg, |
CCLErr ** | err | ||
) |
Get all device wrappers in program.
This function returns the internal array containing the program device wrappers. As such, clients should not modify the returned array (e.g. they should not free it directly).
[in] | prg | The program wrapper object. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 2123 of file ccl_program_wrapper.c.
CCLProgramBinary * ccl_program_get_binary | ( | CCLProgram * | prg, |
CCLDevice * | dev, | ||
CCLErr ** | err | ||
) |
Get the program binary object for the specified device.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 1806 of file ccl_program_wrapper.c.
const char * ccl_program_get_build_log | ( | CCLProgram * | prg, |
CCLErr ** | err | ||
) |
Get a general build log of most recent build, compile or link, for all devices.
Individual build logs for each device associated with the program are returned in a concatenated fashion, with a header (identifying the device) and footer separating them.
[in] | prg | Program wrapper object. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
or an empty string if no build, compile or link was performed, or if no build log is available. Definition at line 928 of file ccl_program_wrapper.c.
CCLDevice * ccl_program_get_device | ( | CCLProgram * | prg, |
cl_uint | index, | ||
CCLErr ** | err | ||
) |
Get CCLDevice wrapper at given index.
[in] | prg | The program wrapper object. |
[in] | index | Index of device in program. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 2081 of file ccl_program_wrapper.c.
const char * ccl_program_get_device_build_log | ( | CCLProgram * | prg, |
CCLDevice * | dev, | ||
CCLErr ** | err | ||
) |
Get build log for most recent build, compile or link for the specified device.
[in] | prg | Program wrapper object. |
[in] | dev | Device for which to get the build log. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
or an empty string if no build, compile or link was performed, or if no build log is available. Definition at line 1022 of file ccl_program_wrapper.c.
CCLKernel * ccl_program_get_kernel | ( | CCLProgram * | prg, |
const char * | kernel_name, | ||
CCLErr ** | err | ||
) |
Get the kernel wrapper object for the given program kernel function.
This is a utility function which returns the same kernel wrapper instance for each kernel function name. The returned kernel wrapper object is automatically released when the program wrapper object which contains it is destroyed; as such, it must not be externally destroyed with ccl_kernel_destroy().
[in] | prg | The program wrapper object. |
[in] | kernel_name | Name of kernel function. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 1470 of file ccl_program_wrapper.c.
cl_uint ccl_program_get_num_devices | ( | CCLProgram * | prg, |
CCLErr ** | err | ||
) |
Return number of devices in program.
[in] | prg | The program wrapper object. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 2100 of file ccl_program_wrapper.c.
cl_uint ccl_program_get_opencl_version | ( | CCLProgram * | prg, |
CCLErr ** | err | ||
) |
Get the OpenCL version of the platform associated with this program.
The version is returned as an integer, in the following format:
[in] | prg | A program wrapper object. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
Definition at line 1404 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_link | ( | CCLContext * | ctx, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
const char * | options, | ||
cl_uint | num_input_programs, | ||
CCLProgram ** | input_prgs, | ||
ccl_program_callback | pfn_notify, | ||
void * | user_data, | ||
CCLErr ** | err | ||
) |
Link a set of compiled programs and create an executable program wrapper.
The return program wrapper must be freed with ccl_program_destroy(). This function wraps the clLinkProgram() OpenCL function.
[in] | ctx | A context wrapper object. |
[in] | num_devices | Number of devices in devs . |
[in] | devs | List of device wrappers associated with the context. If NULL , the link is performed for all devices associated with the context for which a compiled object is available. |
[in] | options | A null-terminated string of characters that describes the link options to be used for building the program executable. |
[in] | num_input_programs | The number of program wrapper objects in input_prgs . |
[in] | input_prgs | An array of program wrapper objects that contain compiled binaries or libraries that are to be linked to create the program executable. |
[in] | pfn_notify | A function pointer to a callback function that an application can register and which will be called when the program executable has been built (successfully or unsuccessfully). |
[in] | user_data | User supplied data for the callback function. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 1266 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_binaries | ( | CCLContext * | ctx, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
CCLProgramBinary ** | bins, | ||
cl_int * | binary_status, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from a list of binary code strings executable on the given device list, one binary string per device.
This function is a wrapper for the clCreateProgramWithBinary() OpenCL function.
[in] | ctx | The context wrapper object. |
[in] | num_devices | Number of devices (and of binary strings). |
[in] | devs | List of devices for which to create the program, and on which the binary code can be executed. |
[in] | bins | List of binary code strings, one per device. |
[out] | binary_status | Returns whether the program binary for each device specified in devs was loaded successfully or not. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 615 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_binary | ( | CCLContext * | ctx, |
CCLDevice * | dev, | ||
CCLProgramBinary * | binary, | ||
cl_int * | binary_status, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from binary code executable on a specific device.
This is a utility function which calls the ccl_program_new_from_binaries() function for the specified device only.
[in] | ctx | The context wrapper object. |
[in] | dev | Device for which to create the program, and on which the binary code can be executed. |
[in] | binary | Binary code. |
[out] | binary_status | Returns whether the program binary was loaded successfully or not. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 588 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_binary_file | ( | CCLContext * | ctx, |
CCLDevice * | dev, | ||
const char * | filename, | ||
cl_int * | binary_status, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from a file containing binary code executable on a specific device.
This is a utility function which calls the ccl_program_new_from_binary_files() function for the specified device only.
[in] | ctx | The context wrapper object. |
[in] | dev | Device for which to create the program, and on which the binary code can be executed. |
[in] | filename | Path to binary file. |
[out] | binary_status | Returns whether the program binary was loaded successfully or not. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 482 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_binary_files | ( | CCLContext * | ctx, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
const char ** | filenames, | ||
cl_int * | binary_status, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from files containing binary code executable on the given device list, one file per device.
This function delegates the actual program creation to the ccl_program_new_from_binaries() function.
[in] | ctx | The context wrapper object. |
[in] | num_devices | Number of devices (and of files). |
[in] | devs | List of devices for which to create the program, and on which the binary code loaded from the files can be executed. |
[in] | filenames | Path to binary files, one per device. |
[out] | binary_status | Returns whether the program binary for each device specified in devs was loaded successfully or not. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 510 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_built_in_kernels | ( | CCLContext * | ctx, |
cl_uint | num_devices, | ||
CCLDevice *const * | devs, | ||
const char * | kernel_names, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from device built-in kernels.
This function is a wrapper for the clCreateProgramWithBuiltInKernels() OpenCL function.
[in] | ctx | The context wrapper object. |
[in] | num_devices | Number of devices. |
[in] | devs | List of devices for which to create the program, and on which all the built-in kernels can be executed. |
[in] | kernel_names | A semi-colon separated list of built-in kernel names. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 701 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_source | ( | CCLContext * | ctx, |
const char * | string, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from a null-terminated source string.
This is a utility function which calls the ccl_program_new_from_sources() function with count
equal to 1 and assumes the passed source string is null-terminated.
[in] | ctx | The context wrapper object. |
[in] | string | Null-terminated source string. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 398 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_source_file | ( | CCLContext * | ctx, |
const char * | filename, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from a source file.
This is a utility function which calls the ccl_program_new_from_source_files() function with count
equal to 1.
[in] | ctx | The context wrapper object. |
[in] | filename | Path to source file. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 298 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_source_files | ( | CCLContext * | ctx, |
cl_uint | count, | ||
const char ** | filenames, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from several source files.
This function delegates the actual program creation to the ccl_program_new_from_sources() function.
[in] | ctx | The context wrapper object. |
[in] | count | Number of source files. |
[in] | filenames | List of source file paths. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 320 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_from_sources | ( | CCLContext * | ctx, |
cl_uint | count, | ||
const char ** | strings, | ||
const size_t * | lengths, | ||
CCLErr ** | err | ||
) |
Create a new program wrapper object from several source code strings.
This function directly wraps the clCreateProgramWithSource() OpenCL function.
[in] | ctx | The context wrapper object. |
[in] | count | Number of source strings. |
[in] | strings | Source strings. |
[in] | lengths | An array with the number of chars in each string (the string length). If an element in lengths is zero, its accompanying string is null-terminated. If lengths is NULL , all strings in the strings argument are considered null-terminated. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
NULL
if an error occurs. Definition at line 423 of file ccl_program_wrapper.c.
CCLProgram * ccl_program_new_wrap | ( | cl_program | program | ) |
Get the program wrapper for the given OpenCL program.
If the wrapper doesn't exist, its created with a reference count of 1. Otherwise, the existing wrapper is returned and its reference count is incremented by 1.
This function will rarely be called from client code, except when clients wish to create the OpenCL program directly (using the clCreateProgramWith*() functions) and then wrap the OpenCL program in a CCLProgram wrapper object.
[in] | program | The OpenCL program to be wrapped. |
Definition at line 260 of file ccl_program_wrapper.c.
cl_bool ccl_program_save_all_binaries | ( | CCLProgram * | prg, |
const char * | file_prefix, | ||
const char * | file_suffix, | ||
char *** | filenames, | ||
CCLErr ** | err | ||
) |
Save the program binaries for all associated devices to files, one file per device.
Applications can specify the prefix and suffix of saved files. The variable part of the filename is obtained via the device name and the device index.
[in] | prg | The program wrapper object. |
[in] | file_prefix | Prefix of files to save, can include full or relative paths. |
[in] | file_suffix | Suffix of files to save. |
[out] | filenames | Location where to place array of strings containing the saved binaries filenames, or NULL if this information is not required. If not NULL this variable will point to an array containg n strings, where n is the number of devices associated with the program, obtained with the ccl_program_get_num_devices() function. If not NULL the value pointed to by this variable should be freed with the ccl_strv_clear() function. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
CL_TRUE
if operation is successful, or CL_FALSE
otherwise. Definition at line 1972 of file ccl_program_wrapper.c.
cl_bool ccl_program_save_binary | ( | CCLProgram * | prg, |
CCLDevice * | dev, | ||
const char * | filename, | ||
CCLErr ** | err | ||
) |
Save the program binary code for a specified device to a file.
[in] | prg | The program wrapper object. |
[in] | dev | The device wrapper object. |
[in] | filename | Name of file where to save the program's binary code. |
[out] | err | Return location for a CCLErr object, or NULL if error reporting is to be ignored. |
CL_TRUE
if operation is successful, or CL_FALSE
otherwise. Definition at line 1890 of file ccl_program_wrapper.c.