How to use CLEW

OpenCL Extension Wrangler Library (CLEW) does to OpenCL what GLEW does to OpenGL. It takes out all the pain of dealing with OpenCL libraries from different vendors and on different platforms. The best part is that your code will compile and run even on a computer without a OpenCL device or library. Only when it calls a OpenCL call does it fail.

  • Get the CLEW code from Github:
$ git clone
  • Compile CLEW:
$ mkdir build
$ cd build
$ cmake ..
$ make
  • Test if CLEW works:
$ clewTest/clewTest
num platforms: 1

If you have an OpenCL device and OpenCL library installed, then the number of platforms reported will be greater than zero.

  • For your own code, include the clew.h header file and link with the library file. Call clewInit at the beginning. After that you can follow with any OpenCL calls.

Tried with: NVIDIA 352 drivers, NVIDIA GeForce GTX 750 Ti and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s