This script automatically fetches OpenCL header files from Khronos Group repositories to your local workspace:
Fetch OpenCL headers including cl.h, cl_ext.h, cl_go.h and so on.
sh get-opencl-headers.sh
Fetch cl.hpp header (for OpenCL 1.0, 1.1, 1.2) or cl2.hpp (for OpenCL 2.0, 2.1), simply add an argument "--include-clhpp":
sh get-opencl-headers.sh --include-clhpp
Notice: to get the cl.hpp header, python is required (some function templates in cl.hpp are generated by a python script.)
After fetching is done, the headers are put into include
folder with the following structure:
-include
|-CL10
|-CL11
|-CL12
|-CL20
|-CL21
|-CL
The CL
folder is a symbolic link, by default, pointing to CL11
. You can change it based on your need. For example, if we want CL
to link to CL20
:
rm CL
ln -s CL20 CL
Therefore, in your OpenCL program, you can easily include OpenCL header file by doing the following:
#include <CL/cl.h>
or
#include <CL/cl.hpp>