cf4ocl

C Framework for OpenCL

View the Project on GitHub FakenMC/cf4ocl

News

17 Jan. 2015

The 2.0.1 version fixes a specific issue with OpenCL <= 1.1 devices and is available in the releases page.

Summary

The C Framework for OpenCL, cf4ocl, is a cross-platform pure C object-oriented framework for developing and benchmarking OpenCL projects in C. It aims to:

  1. Promote the rapid development of OpenCL host programs in C (with support for C++) and avoid the tedious and error-prone boilerplate code usually required.
  2. Assist in the benchmarking of OpenCL events, such as kernel execution and data transfers. Profiling comes for free with cf4ocl.
  3. Simplify the analysis of the OpenCL environment and of kernel requirements.
  4. Allow for all levels of integration with existing OpenCL code: use as much or as few of cf4ocl required for your project, with full access to the underlying OpenCL objects and functions at all times.

Features

Documentation

Feedback and collaboration

Download or clone cf4ocl, build and install it, and build a small example, such as the one bellow, which shows a nice and fast way to get an OpenCL context with a user-selected device:

#include <cf4ocl2.h>
int main() {

    /* Variables. */
    CCLContext * ctx = NULL;

    /* Code. */
    ctx = ccl_context_new_from_menu(NULL);
    if (ctx == NULL) exit(-1);

    /* Destroy context wrapper. */
    ccl_context_destroy(ctx);

    return 0;
}

If you like this project and want to contribute, take a look at the existing issues. We also need help with binary packaging for different OSes. Other improvements or suggestions are of course, welcome. We appreciate any feedback.

Not yet integrated

The following aspects of OpenCL are not yet integrated with cf4ocl:

This functionality is still available to client code, because cf4ocl can be used simultaneously with raw OpenCL objects and functions.

License

Library code is licensed under LGPLv3, while the remaining code (utilities, examples and tests) is licensed under GPLv3.

Other useful C frameworks/utilities for OpenCL

If cf4ocl does not meet your requirements, take a look at the following projects: