Reputation: 1949
When I call an OpenCL function I wouldn't imagine would create new threads, in this case to simply get platform IDs, my program creates 8 new threads.
cl_platform_id platforms[10] = {0}; cl_uint numberofplatforms = 0; clGetPlatformIDs(10, platforms, &numberofplatforms);//this creates 8 threads
Due to me not creating a context, but simply asking for platform IDs to see what is available, why does this function create all these threads? I'm using Windows 7 64 bit, i7 920 with HT (I am suspicious it is creating 8 threads because I have 8 cores), both the Intel and Nvidia SDK( I have a GTS 250 and GTX 560), while I'm linking with the Nvidia OpenCL libraries and using its headers.
This isn't a big concern, but what if I decide to not use OpenCL after analyzing the devices, only to have 8 useless threads "lying around". Anyone know why this happens?
Upvotes: 2
Views: 236
Reputation: 1019
A lot of the OpenCL functions are non-blocking, meaning that they issue commands to the device in the form of a queue and I'm pretty sure the threads are used to control the device while the host program continues to run the rest of the code.
To illustrate: When you call clEnqueueNDRangeKernel, the kernel is not necessarily run at once, but the program continues to run code after the clEnqueueNDRangeKernel call. So I guess this functions passes some information to separate threads that controls the compute device and makes sure that the kernel is run eventually.
Upvotes: 0