3

I have a system with an NVidia graphics card and I'm looking at using openCL to replace openMP for some small on CPU tasks (thanks to VS2010 making openMP useless)

Since I have NVidia's opencl SDK installed clGetPlatformIDs() only returns a single platform (NVidia's) and so only a single device (the GPU).

Do I need to also install Intel's openCL sdk to get access to the CPU platform?
Shouldn't the CPU platform always be available - I mean, how do you NOT have a cpu?
How do you manage to build against two openCL SDKs simultaneously?

Community
  • 1
  • 1
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • Ok so I need the Intel opencl sdk installed aswell - this question should probably be "how to distribute opencl apps to machines without the SDK installed?" – Martin Beckett Mar 28 '12 at 18:25
  • I am very new to this, but I could not understand what computational benefit you will get by running your OpenCL code on CPU instead of running on GPU? – Koder101 Aug 26 '18 at 14:43
  • @Koder101, in this case I was developing on a desktop machine with Nvidia but targeting an embedded PC with only a CPU. – Martin Beckett Aug 26 '18 at 19:05
  • Okay thanks for your answer. But, if the ultimate goal is to use only the CPU (on any platform), then whats the point in using GPU based library, why not the conventional language (with cross-platform framework) directly..? – Koder101 Aug 27 '18 at 04:35
  • 1
    @Koder101 the opencl would compile into optimized parallel instructions on the CPU (SIMD etc) so might be better than a regular C compiler. Although there is a big overhead of compiling the opencl on the first pass – Martin Beckett Aug 27 '18 at 15:07

2 Answers2

8

You need to have a SDK which provides interface to CPU. nVidia does not, AMD and Intel's SDKs do; in my case the one from Intel is significantly (something like 10x) faster, which might due to bad programming on my part however.

You don't need the SDK for programs to run, just the runtime. In Linux, each vendor installs a file in /etc/OpenCL/vendors/*.icd, which contains path of the runtime library to use. That is scanned by the OpenCL runtime you link to (libOpenCL.so), which then calls each of the vendor's libs when querying for devices on that particular platform.

In Linux, the GPU drivers install OpenCL runtime automatically, the Intel runtime is likely to be downloadable separately from the SDK, but is part of the SDK as well, of course.

eudoxos
  • 18,545
  • 10
  • 61
  • 110
  • It's still pretty unclear what you need to distribute with your opencl app (at least on windows) the Intel bin folder is 35files and 68Mb. – Martin Beckett Mar 28 '12 at 20:02
  • The `/usr/lib64/OpenCL/vendors/intel` has 82M here. Not surprising, since it contains the clang compiler, which alone has 25M. The files are 35 in number as well. The SDK contains, in addition, a few header files. – eudoxos Mar 28 '12 at 20:09
  • @eudoxos According to the specification the ICD concept is just an extension and hence optional. So do you know how OpenCL could work without this extension? With the extension you link against the ICD loader (libOpenCL.so/OpenCL.dll), but what do you link against without ICD extension? – Niklas Peter May 26 '16 at 20:07
-1

Today i finally got around to trying to start doing openCl development and wow... it is not straight forward at all.

There's an AMD sdk, there's an intel sdk, there's an nvidia sdk, each with their own properties (CPU only vs GPU only vs specific video card support only perhaps?)

There may be valid technical reasons for it having to be this way but i really wish there was just one sdk, and that when programming perhaps you could specify GPU / CPU tasks, or that maybe it would use whatever resources made most sense / preformed best or SOMETHING.

Time to dive in though I guess... trying to decide though if i go CPU or GPU. I have a pretty new 4000$ alienware laptop with SLI video cards, but then also an 8 core cpu so yeah... guess ill have to try a couple sdk's and see which preforms best for my needs?

Not sure what end users of my applications would do though... it doesnt seem like they can flip a switch to make it run on cpu or gpu instead.

The OpenCL landscape really needs some help...

Alan
  • 1
  • 2
    It doesn't matter which OpenCL SDK you use, use any one and your binary will work everywhere. You might have the Intel (CPU) OpenCL, and the NVidia OpenCL, so you could literally "flip a switch" and run opencl on the cpu. AMD opencl supports running your kernel on CPU. With some clever preprocessor tricks, a kernel can be compiled right into an app for the CPU code path, and run with opencl if available. – doug65536 Jun 03 '12 at 09:10
  • @doug65536 can you please answer my question http://stackoverflow.com/questions/21937673/develop-opencl-application-without-gpu-support-on-laptop? I am really in a desperate situation and cant seem to find any help online on this topic... – Cool_Coder Feb 21 '14 at 15:14