cf4ocl (C Framework for OpenCL)  v2.1.0
Object-oriented framework for developing and benchmarking OpenCL projects in C/C++
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Program wrapper

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...
 
CCLEventccl_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...
 
CCLEventccl_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...
 
CCLProgramBinaryccl_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...
 
CCLDeviceccl_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...
 
CCLKernelccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_program_new_from_source (CCLContext *ctx, const char *string, CCLErr **err)
 Create a new program wrapper object from a null-terminated source string. More...
 
CCLProgramccl_program_new_from_source_file (CCLContext *ctx, const char *filename, CCLErr **err)
 Create a new program wrapper object from a source file. More...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 
CCLProgramccl_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...
 

Detailed Description

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:

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:

__kernel void sum(__global const uint *a, __global const uint *b,
__global uint *c, uint d, uint buf_size) {
/* Get global ID. */
uint gid = get_global_id(0);
/* Only perform sum if this workitem is within the size of the
* vector. */
if (gid < buf_size)
c[gid] = a[gid] + b[gid] + d;
}

Host code:

int main(int argc, char** argv) {

/* Wrappers. */
CCLContext* ctx = NULL;
CCLProgram* prg = NULL;
CCLDevice* dev = NULL;
CCLQueue* queue = NULL;
CCLKernel* krnl = NULL;
CCLBuffer* a_dev;
CCLBuffer* b_dev;
CCLBuffer* c_dev;
CCLEvent* evt_exec;

/* Global and local worksizes. */
size_t gws = 0;
size_t lws = 0;

/* Error reporting object. */
CCLErr* err = NULL;

/* Create a new program from kernel source. */
prg = ccl_program_new_from_source(ctx, KERNEL_SRC, &err);

/* Build program. */
ccl_program_build(prg, NULL, &err);

evt_exec = ccl_program_enqueue_kernel(prg, KERNEL_NAME, queue, 1,
NULL, &gws, &lws, &ewl, &err,
/* Kernel arguments. */
a_dev, b_dev, c_dev,
ccl_arg_priv(d_host, cl_uint), ccl_arg_priv(buf_n, cl_uint),
NULL);

/* Destroy wrappers. */

}

Macro Definition Documentation

#define ccl_program_get_build_info (   prg,
  dev,
  param_name,
  err 
)
Value:
param_name, 0, CCL_INFO_PROGRAM_BUILD, CL_FALSE, err)
CCLWrapperInfo * ccl_wrapper_get_info(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get information about any wrapped OpenCL object.
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151

Get a CCLWrapperInfo program build information object.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information object. This object will be automatically freed when the program wrapper object is destroyed. If an error occurs, NULL is returned.

Definition at line 496 of file ccl_program_wrapper.h.

#define ccl_program_get_build_info (   prg,
  dev,
  param_name,
  err 
)
Value:
param_name, 0, CCL_INFO_PROGRAM_BUILD, CL_FALSE, err)
CCLWrapperInfo * ccl_wrapper_get_info(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get information about any wrapped OpenCL object.
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151

Get a CCLWrapperInfo program build information object.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information object. This object will be automatically freed when the program wrapper object is destroyed. If an error occurs, NULL is returned.

Definition at line 496 of file ccl_program_wrapper.h.

#define ccl_program_get_build_info_array (   prg,
  dev,
  param_name,
  param_type,
  err 
)
Value:
(param_type) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
(CCLWrapper*) dev, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM_BUILD, CL_FALSE, err)
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.

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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. char*, size_t*, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs, NULL is returned.

Definition at line 540 of file ccl_program_wrapper.h.

#define ccl_program_get_build_info_array (   prg,
  dev,
  param_name,
  param_type,
  err 
)
Value:
(param_type) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
(CCLWrapper*) dev, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM_BUILD, CL_FALSE, err)
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.

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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. char*, size_t*, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs, NULL is returned.

Definition at line 540 of file ccl_program_wrapper.h.

#define ccl_program_get_build_info_scalar (   prg,
  dev,
  param_name,
  param_type,
  err 
)
Value:
*((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
(CCLWrapper*) dev, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM_BUILD, CL_FALSE, err))
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.

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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. cl_uint, size_t, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs, zero is returned.

Definition at line 517 of file ccl_program_wrapper.h.

#define ccl_program_get_build_info_scalar (   prg,
  dev,
  param_name,
  param_type,
  err 
)
Value:
*((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
(CCLWrapper*) dev, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM_BUILD, CL_FALSE, err))
Base class for all OpenCL wrappers.
Request information about program builds.
Definition: ccl_common.h:151
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.

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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. cl_uint, size_t, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program build information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs, zero is returned.

Definition at line 517 of file ccl_program_wrapper.h.

#define ccl_program_get_info (   prg,
  param_name,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? NULL \
: ccl_wrapper_get_info((CCLWrapper*) prg, NULL, param_name, 0, \
CCL_INFO_PROGRAM, CL_FALSE, err)
CCLWrapperInfo * ccl_wrapper_get_info(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get information about any wrapped OpenCL object.
Base class for all OpenCL wrappers.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information object. This object will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, NULL is returned.

Definition at line 427 of file ccl_program_wrapper.h.

#define ccl_program_get_info (   prg,
  param_name,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? NULL \
: ccl_wrapper_get_info((CCLWrapper*) prg, NULL, param_name, 0, \
CCL_INFO_PROGRAM, CL_FALSE, err)
CCLWrapperInfo * ccl_wrapper_get_info(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get information about any wrapped OpenCL object.
Base class for all OpenCL wrappers.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information object. This object will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, NULL is returned.

Definition at line 427 of file ccl_program_wrapper.h.

#define ccl_program_get_info_array (   prg,
  param_name,
  param_type,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? NULL \
: (param_type) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
NULL, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM, CL_FALSE, err)
Base class for all OpenCL wrappers.
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. char*, size_t*, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, NULL is returned.

Definition at line 477 of file ccl_program_wrapper.h.

#define ccl_program_get_info_array (   prg,
  param_name,
  param_type,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? NULL \
: (param_type) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
NULL, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM, CL_FALSE, err)
Base class for all OpenCL wrappers.
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. char*, size_t*, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, NULL is returned.

Definition at line 477 of file ccl_program_wrapper.h.

#define ccl_program_get_info_scalar (   prg,
  param_name,
  param_type,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? (param_type) 0 \
: *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
NULL, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM, CL_FALSE, err))
Base class for all OpenCL wrappers.
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. cl_uint, size_t, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, zero is returned.

Definition at line 450 of file ccl_program_wrapper.h.

#define ccl_program_get_info_scalar (   prg,
  param_name,
  param_type,
  err 
)
Value:
(param_name == CL_PROGRAM_BINARIES) \
? (param_type) 0 \
: *((param_type*) ccl_wrapper_get_info_value((CCLWrapper*) prg, \
NULL, param_name, sizeof(param_type), \
CCL_INFO_PROGRAM, CL_FALSE, err))
Base class for all OpenCL wrappers.
void * ccl_wrapper_get_info_value(CCLWrapper *wrapper1, CCLWrapper *wrapper2, cl_uint param_name, size_t min_size, CCLInfo info_type, cl_bool use_cache, CCLErr **err)
Get pointer to information value.
Request information about program objects.
Definition: ccl_common.h:149

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.

Parameters
[in]prgThe program wrapper object.
[in]param_nameName of information/parameter to get value of.
[in]param_typeType of parameter (e.g. cl_uint, size_t, etc.).
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The requested program information value. This value will be automatically freed when the program wrapper object is destroyed. If an error occurs or if the CL_PROGRAM_BINARIES parameter is requested, zero is returned.

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.

Parameters
[in]prgThe 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.

Parameters
[in]prgThe 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().

Parameters
[in]prgProgram 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().

Parameters
[in]prgProgram 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.

Parameters
[in]prgThe program wrapper object.
Returns
The OpenCL program 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.

Parameters
[in]prgThe program wrapper object.
Returns
The OpenCL program object.

Definition at line 568 of file ccl_program_wrapper.h.

Typedef Documentation

typedef void(* ccl_program_callback)(cl_program program, void *user_data)

Prototype of callback functions for program build, compile and link.

Parameters
[in]programProgram wrapper object.
[in]user_dataA 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.

Parameters
[in]programProgram wrapper object.
[in]user_dataA pointer to user supplied data.

Definition at line 206 of file ccl_program_wrapper.h.

Class which represents a binary object associated with a program and a device.

Definition at line 195 of file ccl_program_wrapper.h.

Class which represents a binary object associated with a program and a device.

Definition at line 195 of file ccl_program_wrapper.h.

Function Documentation

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.

Parameters
[in]prgThe program wrapper object.
[in]optionsA null-terminated string of characters that describes the build options to be used for building the program executable.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
CL_TRUE if operation is successful, or CL_FALSE otherwise.
Examples:
ca.c, canon.c, and image_filter.c.

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.

Parameters
[in]prgThe program wrapper object.
[in]num_devicesThe number of devices listed in devs.
[in]devsList 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]optionsA null-terminated string of characters that describes the build options to be used for building the program executable.
[in]pfn_notifyA callback function that can be registered and which will be called when the program executable has been built (successfully or unsuccessfully).
[in]user_dataUser supplied data for the callback function.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
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.

Note
Requires OpenCL >= 1.2
Parameters
[in]prgThe program wrapper that holds the program to be compiled.
[in]num_devicesNumber of devices in devs.
[in]devsList of device wrappers associated with the program. If NULL, the compile is performed for all devices associated with the program.
[in]optionsA null-terminated string of characters that describes the compilation options to be used for building the program executable.
[in]num_input_headersThe number of programs wrappers that describe headers in the array referenced by prg_input_headers.
[in]prg_input_headersAn array of program wrapper embedded headers created with any of the ccl_program_new_from_source*() functions.
[in]header_include_namesAn 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_notifyA 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_dataUser supplied data for the callback function.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
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.

Parameters
[in]prgThe program wrapper object.
Examples:
ca.c, canon.c, and image_filter.c.

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

Attention
The variable argument list must end with NULL.
Warning
For multi-threaded execution of the same kernel function, create different kernel wrapper instances with the ccl_kernel_new() function and use the kernel module API to enqueue kernel executions.
Parameters
[in]prgThe program wrapper object.
[in]kernel_nameName of kernel function.
[in]cqCommand queue wrapper object where to enqueue kernel execution.
[in]work_dimThe number of dimensions used to specify the global work-items and work-items in the work-group.
[in]global_work_offsetCan 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_sizeAn 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_sizeAn 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_lstList 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]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
[in]...A NULL-terminated list of arguments to set.
Returns
Event wrapper object that identifies this command.
Examples:
canon.c.

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().

Warning
For multi-threaded execution of the same kernel function, create different kernel wrapper instances with the ccl_kernel_new() function and use the kernel module API to enqueue kernel executions.
Parameters
[in]prgThe program wrapper object.
[in]kernel_nameName of kernel function.
[in]cqCommand queue wrapper object where to enqueue kernel execution.
[in]work_dimThe number of dimensions used to specify the global work-items and work-items in the work-group.
[in]global_work_offsetCan 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_sizeAn 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_sizeAn 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_lstList 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]argsA NULL-terminated array of arguments to set. Arguments must be of type CCLArg*, CCLBuffer*, CCLImage* or CCLSampler*.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
Event wrapper object that identifies this command.

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).

Parameters
[in]prgThe program wrapper object.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
An array containing the CCLDevice wrappers which belong to the given program, or 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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The program's binary object for the the specified device. The returned object will be freed when the associated program is destroyed.

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.

Parameters
[in]prgProgram wrapper object.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The build log for most recent build, compile or link. May be 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.

Parameters
[in]prgThe program wrapper object.
[in]indexIndex of device in program.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The CCLDevice wrapper at given index or 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.

Parameters
[in]prgProgram wrapper object.
[in]devDevice for which to get the build log.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The build log for most recent build, compile or link. May be 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().

Warning
For multi-threaded handling and execution of the same kernel function, create different kernel wrapper instances with the ccl_kernel_new() function.
Parameters
[in]prgThe program wrapper object.
[in]kernel_nameName of kernel function.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The kernel wrapper object for the given program kernel function.
Examples:
ca.c, canon.c, and image_filter.c.

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.

Parameters
[in]prgThe program wrapper object.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The number of devices in program or 0 if an error occurs or is otherwise not possible to get any device.

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:

  • 100 for OpenCL 1.0
  • 110 for OpenCL 1.1
  • 120 for OpenCL 1.2
  • 200 for OpenCL 2.0
  • etc.
Parameters
[in]prgA program wrapper object.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
The OpenCL version of the platform associated with this program as an integer. If an error occurs, 0 is returned.

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.

Note
Requires OpenCL >= 1.2
Parameters
[in]ctxA context wrapper object.
[in]num_devicesNumber of devices in devs.
[in]devsList 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]optionsA null-terminated string of characters that describes the link options to be used for building the program executable.
[in]num_input_programsThe number of program wrapper objects in input_prgs.
[in]input_prgsAn array of program wrapper objects that contain compiled binaries or libraries that are to be linked to create the program executable.
[in]pfn_notifyA 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_dataUser supplied data for the callback function.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]num_devicesNumber of devices (and of binary strings).
[in]devsList of devices for which to create the program, and on which the binary code can be executed.
[in]binsList of binary code strings, one per device.
[out]binary_statusReturns whether the program binary for each device specified in devs was loaded successfully or not.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]devDevice for which to create the program, and on which the binary code can be executed.
[in]binaryBinary code.
[out]binary_statusReturns whether the program binary was loaded successfully or not.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]devDevice for which to create the program, and on which the binary code can be executed.
[in]filenamePath to binary file.
[out]binary_statusReturns whether the program binary was loaded successfully or not.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]num_devicesNumber of devices (and of files).
[in]devsList of devices for which to create the program, and on which the binary code loaded from the files can be executed.
[in]filenamesPath to binary files, one per device.
[out]binary_statusReturns whether the program binary for each device specified in devs was loaded successfully or not.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Note
Requires OpenCL >= 1.2
Parameters
[in]ctxThe context wrapper object.
[in]num_devicesNumber of devices.
[in]devsList of devices for which to create the program, and on which all the built-in kernels can be executed.
[in]kernel_namesA semi-colon separated list of built-in kernel names.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]stringNull-terminated source string.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or NULL if an error occurs.
Examples:
ca.c, canon.c, and image_filter.c.

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.

Parameters
[in]ctxThe context wrapper object.
[in]filenamePath to source file.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]countNumber of source files.
[in]filenamesList of source file paths.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]ctxThe context wrapper object.
[in]countNumber of source strings.
[in]stringsSource strings.
[in]lengthsAn 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]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
A new program wrapper object, or 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.

Parameters
[in]programThe OpenCL program to be wrapped.
Returns
The CCLProgram wrapper for the given OpenCL program.

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.

Attention
Depending on the OpenCL implementation, this function might throw an error if program has not been built for all devices associated with the program context. Use ccl_program_save_binary() for saving binaries associated with specific devices.
Parameters
[in]prgThe program wrapper object.
[in]file_prefixPrefix of files to save, can include full or relative paths.
[in]file_suffixSuffix of files to save.
[out]filenamesLocation 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]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
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.

Parameters
[in]prgThe program wrapper object.
[in]devThe device wrapper object.
[in]filenameName of file where to save the program's binary code.
[out]errReturn location for a CCLErr object, or NULL if error reporting is to be ignored.
Returns
CL_TRUE if operation is successful, or CL_FALSE otherwise.

Definition at line 1890 of file ccl_program_wrapper.c.