Adding support for a new hardware in OpenCL
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,
Last edited by Gopal_HC; 09-26-2013 at 08:10 AM.
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)
Thanks Rob for replying !
Originally Posted by robmxn
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: Entering directory `/home/lio/Desktop/icd/build'
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: 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:
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
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?
Last edited by Gopal_HC; 09-27-2013 at 04:10 AM.
Tags for this Thread