71 g_return_val_if_fail(err == NULL || *err == NULL, NULL);
84 cl_platform_id* platf_ids = NULL;
90 ocl_status = clGetPlatformIDs(0, NULL, &platforms->num_platfs);
93 error_handler,
"%s: no OpenCL platforms found.", CCL_STRD);
95 CL_SUCCESS != ocl_status, ocl_status, error_handler,
96 "%s: get number of platforms (OpenCL error %d: %s).",
97 CCL_STRD, ocl_status,
ccl_err(ocl_status));
100 platf_ids_size =
sizeof(cl_platform_id) * platforms->num_platfs;
103 platf_ids = (cl_platform_id*) g_slice_alloc(platf_ids_size);
106 ocl_status = clGetPlatformIDs(
107 platforms->num_platfs, platf_ids, NULL);
109 CL_SUCCESS != ocl_status, ocl_status, error_handler,
110 "%s: get platforms IDs (OpenCL error %d: %s).",
111 CCL_STRD, ocl_status,
ccl_err(ocl_status));
115 g_slice_alloc(
sizeof(
CCLPlatform*) * platforms->num_platfs);
118 for (guint i = 0; i < platforms->num_platfs; i++) {
124 g_slice_free1(platf_ids_size, platf_ids);
127 g_assert(err == NULL || *err == NULL);
133 g_assert(err == NULL || *err != NULL);
163 g_return_if_fail(platforms != NULL);
166 for (guint i = 0; i < platforms->num_platfs; i++) {
172 sizeof(
CCLPlatform*) * platforms->num_platfs, platforms->platfs);
192 g_return_val_if_fail(platforms != NULL, 0);
195 return platforms->num_platfs;
212 g_return_val_if_fail(platforms != NULL, NULL);
216 g_return_val_if_fail(index < platforms->num_platfs, NULL);
219 return platforms->platfs[index];
#define CCL_OCL_ERROR
Resolves to error category identifying string, in this case an error in the OpenCL library...
#define ccl_if_err_create_goto(err, quark, error_condition, error_code, label, msg,...)
If error is detected (error_code != no_error_code), create an error object (CCLErr) and go to the spe...
Useful definitions used internally by cf4ocl.
const char * ccl_err(int code)
Convert OpenCL error code to a readable string.
void ccl_platforms_destroy(CCLPlatforms *platforms)
Destroy a CCLPlatforms* object, including all underlying platforms, devices and data.
CCLPlatforms * ccl_platforms_new(CCLErr **err)
Creates a new CCLPlatforms* object, which contains the list of OpenCL platforms available in the syst...
cl_uint ccl_platforms_count(CCLPlatforms *platforms)
Return number of OpenCL platforms found in CCLPlatforms object.
#define CCL_ERROR
Resolves to error category identifying string, in this case an error in cf4ocl.
The requested OpenCL device was not found.
#define ccl_platform_unref(platform)
Alias to ccl_platform_destroy().
CCLPlatform * ccl_platform_new_wrap(cl_platform_id platform)
Get the platform wrapper for the given OpenCL platform.
GError CCLErr
Error handling class.
CCLPlatform * ccl_platforms_get(CCLPlatforms *platforms, cl_uint index)
Get platform wrapper object at given index.