CL_CONTEXT_DEVICES info different from clGetDeviceIDs

I’m new to OpenCL. I’m developing in Snow Leopard. There is a part of the specification that is not clear to me. When I gather my devices using clGetDeviceIDs for type CPU I obtain one device (I have have a MacPro with 2-QuadCore Xeon). This result is expected according to the specification. However, if I create a context form type clCreateContextFromType, for CPU and then gather the context info for CL_CONTEXT_DEVICES, it returns 8 devices. My understanding is , this should also return one device, or is it returning the number of computing units? Why is there a difference? I post this for platform specific, because the same code running on a dual core, with AMD SDK, returns 1 device in both cases. Thanks in advance

Sounds like a bug. I would suggest you file a bug report with Apple.

This case seems to work fine for me on SnowLeopard 10.6.2. Can you please post the code for this case? Note that clGetContextInfo returns the number of bytes returned in the param_value.

  size_t device_list_size_;
  cl_context context_;                 /**< CL context */
  cl_device_id *devices_;              /**< CL device list */  
  cl_int status = CL_SUCCESS;

  context_ = clCreateContextFromType(

  /* First, get the size of device list data */
  status = clGetContextInfo(

  /* Now allocate memory for device list based on the size we got earlier */
  devices_ = (cl_device_id *)malloc(device_list_size_);
  if(devices_==NULL) {
		cout << "Failed to allocate memory (devices).
		return false;

  /* Now, get the device list data */
  status = clGetContextInfo(
cout << "Context Description
           << " Number of devices: " << device_list_size_ << '

The output of this code is
Number of devices: 8

Thanks, this make it clearer. clGetContextInfo returns the number of bytes in device_list_size_. The number of devices in the list is device_list_size_/sizeof(cl_device_id). With a 64 bit app on SnowLeopard, sizeof(cl_device_id) is 8 bytes so there is 1 CPU device returned.

Thank you so much, that answers my question!


Thanks for that!!! hypnosis downloads