Home

Awesome

clew

The OpenCL Extension Wrangler Library

This basically works like glew, but for OpenCL

Code history

To use in your code

Include it

#include "clew.h"

Initialize it

bool clpresent = 0 == clewInit();
if( !clpresent ) {
    throw std::runtime_error("OpenCL library not found");
}

Use standard OpenCL method calls, as though you were linking directly with OpenCL:

context = new cl_context();
*context = clCreateContext(0, 1, &device, NULL, NULL, &error);
if (error != CL_SUCCESS) {
   throw std::runtime_error( "Error creating context: " + errorMessage(error) );
}
// Command-queue
queue = new cl_command_queue;
*queue = clCreateCommandQueue(*context, device, 0, &error);
if (error != CL_SUCCESS) {
   throw std::runtime_error( "Error creating command queue: " + errorMessage(error) );
}
// etc ...

To build

On linux

You'll need:

Procedure:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../dist
make -j 4 install

To test it works ok. You'll need at least one OpenCL-enabled device to do this bit:

LD_LIBRARY_PATH=../dist/lib ../dist/bin/clewTest

=> should see something like 'num platforms: 1'

On Windows

You'll need:

Procedure:

To test it works ok. You'll need at least one OpenCL-enabled device to do this bit:

Build options