9

How to compile and run open cl codes on intel i5 processors having intel hd 4000 gpu unit??? Open cl has been istalled in /opt/intel/opencl and versionis ubuntu 12.04. Any help would be of great help... Thanks

7
  • What problem are you encountering?
    – Thomas
    Jan 28, 2014 at 10:26
  • so this emulator works for intel.... Jan 28, 2014 at 12:05
  • @thomas, when i am running the file, its not finding any of the files or library... error says that no such file or directory CL/cl.h not found. Also there is one file called kernelBuilder, when I m trying to execute it, one prompt comes but it stops and says that GCOnf warning ,client failed to connect to the D bus Daemon and did not recieve a reply.... Jan 28, 2014 at 12:12
  • @PiyushKumar sudo apt-get install opencl-headers perhaps. After that it should find the libOpenCL.so, but I've had major issues in the past with Intel failing to register the library and causing linking errors.
    – Thomas
    Jan 28, 2014 at 12:37
  • @Thomas, will try it... Guess I could use ur experiances Jan 28, 2014 at 12:44

2 Answers 2

10

First:
sudo apt-get install beignet opencl-headers

Add the beignet folder to your library search path:

sudo su
echo "/usr/lib/beignet/" > /etc/ld.so.conf.d/beignet.conf
ldconfig
exit

Get a simple test binary:

git clone https://github.com/vpereira/CapsBasic-beignet

Edit the makefile to look more like this:

all: capsbasic

capsbasic: capsbasic.cpp Makefile
    g++ capsbasic.cpp -lcl -ocapsbasic -I/usr/include -L/usr/lib/beignet

clean:
    rm -f capsbasic

There you go. OpenCL working-ish for the intel HD family of video cards...

lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

./capsbasic

Number of available platforms: 1
Platform names:
    [0] Experiment Intel Gen OCL Driver [Selected]
Number of devices available for each type:
    CL_DEVICE_TYPE_CPU: 0
    CL_DEVICE_TYPE_GPU: 1
    CL_DEVICE_TYPE_ACCELERATOR: 0

*** Detailed information for each device ***

CL_DEVICE_TYPE_GPU[0]
    CL_DEVICE_NAME: Intel HD Graphics Family
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.1
    CL_DRIVER_VERSION: 0.2
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.1
    CL_DEVICE_MAX_COMPUTE_UNITS: 128
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 1000
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 512
    CL_DEVICE_ADDRESS_BITS: 32
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 32
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 134217728
    CL_DEVICE_GLOBAL_MEM_SIZE: 4
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
    CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 8192
    CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 128
    CL_DEVICE_LOCAL_MEM_SIZE: 65536
    CL_DEVICE_PROFILING_TIMER_RESOLUTION: 80
    CL_DEVICE_IMAGE_SUPPORT: 1
    CL_DEVICE_ERROR_CORRECTION_SUPPORT: 0
    CL_DEVICE_HOST_UNIFIED_MEMORY: 0
    CL_DEVICE_EXTENSIONS: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_fp64 cl_khr_icd cl_khr_gl_sharing
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 0
    CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: 16
8
  • 1
    Thanks, but according to Intel they don't support OpenCL on the HD 4000 for Linux: OpenCL SDK 1.2 for Linux, without Xeon?. What kind of performance are you getting?
    – nealmcb
    Jan 16, 2015 at 18:38
  • 1
    Aha - now I see that the README.txt for beignet explains that it is an alternative to Intel's OpenCL SDK, which does indeed support the HD 4000. Thank you!! Note that folks do have to actually run make also.... Is the need to run ldconfig evidence of a problem with the package?
    – nealmcb
    Jan 16, 2015 at 19:06
  • 2
    The performance, as opencl goes, is pretty poor and pretty glitchy. Code that runs on other opencl implementations sometimes just crashes or errors out. It does let you build trivial test things without pushing to a compute rig. Jan 16, 2015 at 22:32
  • I don't think the needing to add it to your library search path is a problem with the library. If you're using OpenCL, the assumption is that you have some technical knowhow. Personally, I would like it if the OpenCL packages were all installable concurrently and you could just switch which library was included in your search path and re-run ldconfig to point to a different one. This could be useful if you had a test box with all 3 video chipset "brands" as a testing environment and you worked out a way to benchmark or just run-test your code on all possible targets. Jan 18, 2015 at 12:04
  • 1
    That makes sense. I would be more on board with something like slapping it in jockey, update-alternatives, or whatever. Switch libraries with something that's supposed to switch libraries? Sure, that seems like a good idea for an untenable situation. Jan 21, 2015 at 7:05
0

In order to compile you require a compiler such as gcc. You can download gcc from its repository. (choose the biggest version number for more C++11 feature).

$> sudo apt-get install gcc-4.7

After that you have to link your OpenCL library to the application you are compiling. Lets say the Host application (main.c) code and the kernel application (kernel.cl) code reside in a folder called test. You should do as following:

$test> gcc -I /opt/intel/include -L /opt/intel/lib/[x86 or x86_64]/ main.c -o a.out

It should take care of the compile. You should run the output as:

$test>./a.out

and take care of any runtime error you might get (including correcting the path to you kernel.cl etc).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .