CLsmith

Getting CLsmith and building

Prerequisites:

In order to get the source code for CLsmith, you will need to clone the git repository available here:

The directory in which the repository has been clone will be refered to as <CLsmith-dir>. NOTE: When running make the first time, the linking will fail; this is expected.

After this step, you should have cl_launcher and CLSmith in <CLsmith-dir>/src/CLSmith.

Usage

To setup a testing directory (requires Python):

This will create the folder $HOME/<test-dir> and move all required files in it.

To generate a random OpenCL kernel:

This will produce CLProg.c, containing the random kernel.

To execute the generated kernel:

The expected output is a comma-separated list of hexadecimal numbers. Each number corresponds to the result of a thread. The d and p parameters of cl_launcher control the platform and device index to be used by OpenCL. If you have multiple OpenCL compatible devices available, you can use these parameters to control which to use.

In order to execute a kernel without having run the Python setup script, move the following files to a folder and run cl_launcher as above:

For information about options available to pass to the generator and others, click here.

Oclgrind

A way to test out the tool without having access to an OpenCL device is with Oclgrind, an OpenCL emulator. Obtain it by following the instructions available at its Github page. After installation, the only change in regards to CLsmith is, during execution, the way to run cl_launcher with Oclgrind is by: