I am learning OpenCL from the beginning and get confused by platform = host + device idea. In my work PC there are 2 platforms detected: Platform 0 has only the CPU, Platform 1 has only the NVIDIA GPU. Detected platforms
This PC actually has also an Intel GPU but I assume that it doesn't support OpenCL so it does not show here. My question goes: In an OpenCL application there are host and device. Normally the host and device come from one platform according to my understanding from book . Then in my PC I need to use either the CPU or the NVIDIA GPU as both host and device for the OpenCL application. Is this true?
I tried to search by myself, some answers indeed help me to understand more in this topic like this one: What is a host in opencl?. But about using one hardware for both host and device is not being answered or confirmed by my searching.
I think you're mixing up some terminology here.
A platform may provide multiple different devices: For example, if you have the Nvidia OpenCL driver installed, it provides an OpenCL device for every supported GPU. Meanwhile, the Intel driver provides the Intel CPU as an OpenCL device.
Generally, your program flow will look something like this:
clGetPlatformIds
clGetDeviceIds
for whichever platform(s) you want to use.clCreateContext
, clCreateProgram
, etc.clEnqueueNDRangeKernel
.