2

I'm just starting to learn OpenCL. This is on a simple Desktop machine with Intel Haswell CPU + Intel HD Graphics 4600. For now I use PyOpenCL and the provided examples. My question is, if the code is running on CPU or GPU?

platforms = cl.get_platforms()
platforms[0].get_devices()
[<pyopencl.Device 'Intel(R) Core(TM) i5-4570S CPU @ 2.90GHz' on 'Intel(R) OpenCL' at 0x706ac40>]

This looks like CPU. But is there any distinction at all or is it the Intel driver that decides where the kernel runs (CPU or GPU)? if this is the CPU only how do I make it run on the iGPU?

Michael Haidl
  • 5,384
  • 25
  • 43
beginner_
  • 7,230
  • 18
  • 70
  • 127

2 Answers2

1

Well I never used pyopencl but you should be able to query the device type in pyopencl as well as in C/C++.

Looking at the pyopencl documentation:

class pyopencl.device_info
    ...
    TYPE
    VENDOR
    VENDOR_ID
    VERSION

You should be able to get the device type from the device_info instance of your current device.

OpenCL defines three (four) different device types in the standard:

CL_DEVICE_TYPE_CPU 
CL_DEVICE_TYPE_GPU 
CL_DEVICE_TYPE_ACCELERATOR 
CL_DEVICE_TYPE_DEFAULT

Comparing the type of your actual device to the pyopencl representation of CL_DEVICE_TYPE_CPU and CL_DEVICE_TYPE_GPU should give you the information you need about your executing device.

Michael Haidl
  • 5,384
  • 25
  • 43
  • It's a CPU. Does Intel does make a distinction between the 2? If you have a CPU with Intel HD Graphics, should there be 2 devices? – beginner_ Mar 09 '16 at 09:39
  • Yes. However, Intel drivers supporting OpenCL on linux for Intel HD GPUs is quite new. Maybe you are missing a driver: https://software.intel.com/en-us/articles/opencl-drivers here you can get linux and windows drivers to enable OpenCL on your Intel devices. – Michael Haidl Mar 09 '16 at 09:43
1

I found the issue. It is only using the CPU and no GPU is listed. I'm on Windows 7. The issue/solution I I found on this other SO question.

Maxim Shevtsov (Intel): Likely this is the actual root-cause. Currently Processor Graphics OCL device in unavailable in the "headless" configuration (without a monitor plugged in).

I'm connecting to said PC via Remote Desktop (don't ask why...) and hence it's headless and hence iGPU not available as OpenCL device.

According to this thread on Intel forums with newest drivers and Windows 8 or higher this works. But not in Windows 7 (and as far as I can tell not on 3rd Gen core-i processors eg. Ivy bridge).

Good enough for me for now as I get started. Later I would like to actually see if I gain anything from the GPU.

Community
  • 1
  • 1
beginner_
  • 7,230
  • 18
  • 70
  • 127
  • GPU should be like orders of magnitude better. So, don't rus into conclusions with CPU results. – DarkZeros Mar 09 '16 at 16:29
  • Yeah, if done right. But I'm really just getting started with OpenCL out of personal interest. So performance is not really that important for now. Just wanted to be sure I understood everything correctly. – beginner_ Mar 10 '16 at 05:54