Hello all,

This time I will go on how to setup and run OpenCL applications on openSUSE using an Intel HD Graphics 4400 GPU. As long you’re having an Intel integrated GPU that supports OpenCL, these steps should be able to work for your as well.

You can check in Intel_HD_and_Iris_Graphics [en.wikipedia.org] about your hardware’s compatibility and what version of OpenCL you can work with.

[Note: 1] Important: This would be more or less how to setup OpenCL on a computer. The only thing that would differ from this guide is how to deal with the “Missing OpenCL environment” section.

[Note: 2] I will be skipping the verification of the binaries.

My specifications:

  • openSUSE tumbleweed
  • Intel(R) Core(TM) i5-4300U CPU
  • Intel(R) HD Graphics 4400
  • g++ (SUSE Linux) 6.2.1 20161209 [gcc-6-branch revision 243481]

I point to clDeviceQuery.cpp [github.com]  as the test source code that will be trying to run.

Now, lets try to compile it. First of all we need to add the -lOpenCL library in order to compile an OpenCL application.

To add the library to the system install libOpenCl1.

 > zypper in libOpenCL1

// Missing headers

Lets try to compile the source code

 > gcc -lOpenCL clDeviceQuery.cpp
0clDeviceQuery.cpp:8:19: fatal error: CL/cl.h: No such file or directory
#include <CL/cl.h>
^
compilation terminated.

We see that the OpenCL headers are absent. To install them we need the package called opencl-headers.

 > zypper in opencl-headers

// Link problem

Lets try to compile it again.

 > g++ -lOpenCL clDeviceQuery.cpp
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status

Now we have a different problem, g++ can’t find libOpenCL. We need to add a symbolic link for /usr/lib64/libOpenCL.so to point to /usr/lib64/libOpenCL.so.1.

 > ln -s /usr/lib64/libOpenCL.so.1 /usr/lib64/libOpenCL.so

// Missing OpenCL environment

Compilation succeeds this time.

 > g++ -lOpenCL clDeviceQuery.cpp
 > ./a.out
clDeviceQuery Starting...

Error -1001 in clGetPlatformIDs Call!
System Info:

Local Time/Date = 13:52:14, 01/31/2017
CPU Name: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
# of CPU processors: 4
Linux version 4.9.6-1-default (geeko@buildhost) (gcc version 6.2.1 20161209 [gcc-6-branch revision 243481] (SUSE Linux) ) #1 SMP PREEMPT Thu Jan 26 09:09:16 UTC 2017 (d1207ac)
TEST FAILED !!!

Again we hit on another problem, we are missing the OpenCL runtime environment/driver for my GPU. It is required to install the OpenCL runtime for the specific computer. This will work more or less with most (?) Intel Integrated GPUs. We will need to download “OpenCL™ 2.0 GPU/CPU driver package for Linux (64-bit)” from Intel’s page containing “Driver and library(runtime) packages” [software.intel.com].

After downloading and unpacking we have to install the file called intel-opencl-r4.0-59481.x86_64.rpm.

 > zypper in intel-opencl-r4.0-59481.x86_64.rpm

// All working

Trying again to compile and run will give us the following result.

 > g++ -lOpenCL clDeviceQuery.cpp
 > ./a.out
clDeviceQuery Starting...

1 OpenCL Platforms found

CL_PLATFORM_NAME: Intel(R) OpenCL
CL_PLATFORM_VERSION: OpenCL 1.2
OpenCL Device Info:

1 devices found supporting OpenCL on: Intel(R) OpenCL

----------------------------------
Device Intel(R) HD Graphics
---------------------------------
CL_DEVICE_NAME: Intel(R) HD Graphics
CL_DEVICE_VENDOR: Intel(R) Corporation
CL_DRIVER_VERSION: r4.0.59481
CL_DEVICE_TYPE: CL_DEVICE_TYPE_GPU
CL_DEVICE_MAX_COMPUTE_UNITS: 20
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
CL_DEVICE_MAX_WORK_ITEM_SIZES: 256 / 256 / 256
CL_DEVICE_MAX_WORK_GROUP_SIZE: 256
CL_DEVICE_MAX_CLOCK_FREQUENCY: 1100 MHz
CL_DEVICE_ADDRESS_BITS: 64
CL_DEVICE_MAX_MEM_ALLOC_SIZE: 815 MByte
CL_DEVICE_GLOBAL_MEM_SIZE: 1630 MByte
CL_DEVICE_ERROR_CORRECTION_SUPPORT: no
CL_DEVICE_LOCAL_MEM_TYPE: local
CL_DEVICE_LOCAL_MEM_SIZE: 64 KByte
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 834764 KByte
CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_PROFILING_ENABLE
CL_DEVICE_IMAGE_SUPPORT: 1
CL_DEVICE_MAX_READ_IMAGE_ARGS: 128
CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 128

CL_DEVICE_IMAGE  2D_MAX_WIDTH 16384
2D_MAX_HEIGHT 16384
3D_MAX_WIDTH 2048
3D_MAX_HEIGHT 2048
3D_MAX_DEPTH 2048
CL_DEVICE_PREFERRED_VECTOR_WIDTH_ CHAR 16, SHORT 8, INT 4, FLOAT 1, DOUBLE 1
clDeviceQuery, Platform Name = Intel(R) OpenCL, Platform Version = OpenCL 1.2 , NumDevs = 1, Device = Intel(R) HD Graphics

System Info:

Local Time/Date = 14:16:40, 01/31/2017
CPU Name: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz
# of CPU processors: 4
Linux version 4.9.6-1-default (geeko@buildhost) (gcc version 6.2.1 20161209 [gcc-6-branch revision 243481] (SUSE Linux) ) #1 SMP PREEMPT Thu Jan 26 09:09:16 UTC 2017 (d1207ac)
TEST PASSED

All tests have passed! This is the point that we wanted to reach. We can also see that my I run OpenCL 1.2.

Have lots of fun with your OpenCL programming.

Enjoy until next time

— flanaras

Advertisements