cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

ash
Journeyman III

How to implement cl_khr_icd?

Hi,

I want to run my application on both intel CPU and nvidia GPU. As I read some other posts, I clearly understood that I need 2 SDK for this configuration so I chose : AMD SDK and NVIDIA SDK. A part from the "FATA error no flgrx found", when I run my application it can find the 2 devices.

But how can I load dynamically the good library? I heard of the extension cl_khr_icd but I can't manage to understand ho to use it. Can anybody help please?

Best regards,

Jacq

Tags (2)
0 Likes
Reply
71 Replies
himanshu_gautam
Grandmaster

Re: How to implement cl_khr_icd?

End users need not worry about ICD. You can link to one OpenCL runtime and that will load the other runtimes and daisy-chain them transparently.

When you query the platforms -- you should get both platforms listed. Then, everything is fine.

Just select your platform, create the context and get going...

ash
Journeyman III

Re: How to implement cl_khr_icd?

Hi,

Thanks for your quick reply. Sorry, I didn't explain well my case. Actually the application is for some clients ( doing an internship in a company ). So I don't know in advance if the client has installed both SDK. How can I find which one is installed? Because let's say it has only Nvidia GPU then I should load the libOpenCL.so from Nvidia, how will the program know? And also when I look for platforms with Nvidia it doesn't see my CPU only the GPU is found. Whereas the AMD SDK can see both.

My question might be dumb so please excuse my ignorance, but it's kind of confusing for me.

0 Likes
Reply
himanshu_gautam
Grandmaster

Re: How to implement cl_khr_icd?

Hi,

Just link your app against libOpenCL.so on your local machine and ship the app.

When your client runs the code, it will try to load "OpenCL" library. Whatever library (nvidia or amd or intel etc..) is in the LD_LIBRARY_PATH (or) in the standard system search path will be loaded. Now, this library (by the virtue of ICD) will load all other installed platforms transparently. Your app can query the platforms and get going.

AMD as a company ships both AMD CPUs as well as AMD Radeon GPUs. AMD's OpenCL SDK will support both CPU and GPU devices. However, companies like NVIDIA who sell only GPUs will expose only the GPU device. There is nothing wrong with it.

Your app should find out the platforms installed, whether the devices are GPUs or CPUs, how many CUs they have etc... and decide what devices it should work on.

Note that: an OpenCL context can only be formed out of devices from one platform.

If you intend to work on multiple platforms, you need to separately create contexts and partition your problem manually among the different platforms.

Hope this is clear.

0 Likes
Reply
himanshu_gautam
Grandmaster

Re: How to implement cl_khr_icd?

Just a quick addition:

Test your app before you ship to the client.

And, Please inform the client to make sure that relevant OpenCL libraries are in the LD_LIBRARY_PATH (or) system search path. Otherwise, they will face "failed to load shared libraries" error.

Just be aware.

This is a classic "redistribution" problem. You will have to just take your app and run on a different machine and make sure it runs when all libraries are found.

0 Likes
Reply
ash
Journeyman III

Re: How to implement cl_khr_icd?

Thanks a lot for your reply, it's much more clearer. I just still have one doubt : if by linking with one library openCL it will find other all others platforms. Then I don't understand why by putting the NVidia library in the LIBRARY_PATH the AMD samples don't work anymore. Is is because of the openCL version ( 1.2 vS 1.1) ? What should I do to make them work again with this setup?

0 Likes
Reply
himanshu_gautam
Grandmaster

Re: How to implement cl_khr_icd?

Mixing NVIDIA and AMD platforms should technically work. Can you tell which sample did not work?

Mixing 1.1 and 1.2 is a problem if you are using 1.2 APIs. For example: "clinfo" might seg-fault if you do that.

Some samples may not work

You can do 2 things here:

1. Run a simple sample that does not use 1.2 API

2. Write your own application to query and list the platforms that you have.

0 Likes
Reply
ash
Journeyman III

Re: How to implement cl_khr_icd?

Yes it's true, clinfo gave me en error when I first linked with AMD SDK and now it prints with Nvidia:

clinfo: relocation error: clinfo: symbol clRetainDevice, version OPENCL_1.2 not defined in file libOpenCL.so.1 with link time reference

For the sampels,actually you're right :

- some  don't run because of the openCL version 1.2 such as  :

GaussianNoise, DeviceFission, HDRToneMapping, ImageOverlap, MatrixMulDouble, SimpleImage, SobelFilterImage, TransferOverlapCPP.

- And some don't run because they can't find the libGlew such as :

FluidSimulation, MandelBrot, NBody, SimpleGL, NoiseGL.

- And finally the samples where GPU is compulsory to run don't run, such as :

ImageBandWidth, BufferBandWidth, SimpleMultiDevice.

Others run just fine, except this error : FATAL: Module fglrx not found.

I know thatsomeone already explained it on the forum which will probably taken care of in the next release : 

But where is it? I'd like to hide it since it's kind of frightening for a client I suppose

Thanks again for your precious help, I think I'm making progress.

0 Likes
Reply
himanshu_gautam
Grandmaster

Re: How to implement cl_khr_icd?

Hi,

Thats good amount of detail.

I don't understand why "BufferBandwidth" cannot work. If it sees an AMD GPU, it should work.

So, You have an x86 CPU + NVIDIA GPU combo?

Regarding the fatal error, you are right. It will be fixed in a subsequent driver release.

You can just wrap it up in a shell script as

"./yourApp 2>/dev/null"

I hope the library is printing to stderr... but doing this will also remove other messages to stderr.

OR may be, [./yourApp 2>&1 | grep -v -i "FATAL: Module fglrx" ] might help.

0 Likes
Reply
ash
Journeyman III

Re: How to implement cl_khr_icd?

Hi again,

For the BufferBandWith the message error is :

Platform found : Advanced Micro Devices, Inc.

This sample requires a GPU to be present in order to execute

And it just stops like that. I haven't yet looked deep in the code but maybe i'll find some clues as why it doesn't find my GPU.

To be precise my combo is : Intel Xeon E5430 64bits and Nvidia GTX 650. I also added another GPU Nvidia and by command line I can switch my app on the device I want, which is really nice. I couldn't manage to use your command line to hide the error message. I have "ambiguous redirection", maybe because I have an argument for my program.

I'll look into that at least it gives me some ideas.

0 Likes
Reply