PDA

View Full Version : How OpenCL chooses which vendor's library to link @ runtime?



airthimble
02-13-2013, 02:27 PM
I am a little naive with how this works, I was hoping to get some clarification here.

Say I have a PC with an intel CPU and an AMD GPU. From what I understand, there will be implementations of the OpenCL standard provided by both Intel and AMD.

In my OpenCL program, I should see two separate platforms, one platform has the Intel device, the second platform has the AMD device.

I go on to write code to utilize both devices, compile program, etc...

I typically code on a Linux platform, and understand how to write a Makefile which gives the right include paths and link directories. I would like to know specifically, when I execute my program, how does it know which OpenCL libraries to link with? What is the process it uses to find these libraries?

matthiasv
02-14-2013, 03:47 AM
The point is, you never directly link against the vendor implementation of the OpenCL functions. You link against some libOpenCL.so that fills out function pointer tables to the actual implementations at run-time and forwards the calls depending on which context you created. You can read about the so-called ICD mechanism here (http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt).

airthimble
02-14-2013, 06:27 PM
This is exactly what I was looking for, thanks!