Adding support for a new hardware in OpenCL

Hi,

As of my project, I have been assigned to add support for a new hardware device in OpenCL Software stack, which has two major components :

  1. Host Runtime: to provide OpenCL host platform API and runtime API.
  2. OpenCL Compiler: to translate OpenCL kernel c code into a hardware specific ISA.

Among these two components, i started with the first and explored how to do this.
I found that, in order to add a new hardware device in OpenCL stack,

i. first i need to build an OpenCL ICD loader which will load shared library (libOpenCL.so) whose name is on first line of .icd file. Is that enough to find new hardware device in OpenCL?
ii. secondly, i have to modify CL/cl.h file by adding a new device type say for example XYX such as
#define CL_DEVICE_TYPE_XYZ (1 << 5)
and then regenerate libOpenCL.so file. Since I did not found source code for libOpenCL.so library, so how should I get new build libOpenCL.so file?

Are these two requirements correct? What else I need to have in order to add support for a new Hardware device in OpenCL? Note: In this post, I am only concerned with my first component.

Any advise and helpful links will be appreciated.

Thanks and Regards,
Gopal

I don’t think you need to do ii) as those constants are defined per OpenCL spec and subject to change. I think your implementation should identify itself as CL_DEVICE_TYPE_ACCELERATOR if your device is neither a CPU nor GPU.

You can take a look to POCL which is an open source implementation of OpenCL runtime for CPU. Look for pocl project in sourceforge.net (I can’t post links for some reason)

Rob

Thanks Rob for replying !
Surely I will look into POCL and would like to contribute in this.

I installed and built ICD loader from http://www.khronos.org/registry/cl/ and
testing of ICD Test program went successfully, as given below:
i. root@WS1-GOPAL:~# echo /home/lio/Desktop/icd/bin/libOpenCLDriverStub.so > /etc/OpenCL/vendors/test.icd
ii. lio@WS1-GOPAL:~/Desktop/icd$ make test
make -C build test
make[1]: Entering directory /home/lio/Desktop/icd/build' Running tests... Test project /home/lio/Desktop/icd/build Start 1: OPENCL_ICD_LOADER_TEST 1/1 Test #1: OPENCL_ICD_LOADER_TEST ........... Passed 0.06 sec 100% tests passed, 0 tests failed out of 1 Total Test time (real) = 0.08 sec make[1]: Leaving directory/home/lio/Desktop/icd/build’

But when I tried to use the same ICD loader for my OpenCL programs using CL_DEVICE_TYPE_CPU as device type as given below:
lio@WS1-GOPAL:~/Desktop/OpenCL_src_code/$ ./OpenCL_ex01

Querying Platforms…
Platform Found
Number Of Platforms = 1
OpenCL Platform Name = ICD_LOADER_TEST_OPENCL_STUB
Platform Vender = stubvendorxxx
Platform Version = OpenCL 1.2 Stub
Platform Profile = stubprofilexxx
Platform Extensions = cl_khr_icd cl_khr_gl cl_khr_d3d10
Querying Platform Done

Query Devices…
Segmentation fault

In above OpenCL_ex01 program, this ICD loader is not able to detect CL_DEVICE_TYPE_CPU as a device type and i am getting segmentation fault while querying OpenCL devices. Did i miss something ?

Even though, when i change the content of test.icd file with libOpenCL.so.1.2, within /etc/OpenCL/vendors/directory, in this case ICD loader is not finding OpenCL platforms.
How shall I use this ICD loader to detect available CPU platforms as well as all OpenCL devices within each platform?

Regards,
Gopal