PDA

View Full Version : CL_CONTEXT_DEVICES info different from clGetDeviceIDs



isa_restrepo
11-23-2009, 09:05 AM
Hello,
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

dbs2
11-23-2009, 12:22 PM
Sounds like a bug. I would suggest you file a bug report with Apple.

mpw
11-23-2009, 02:54 PM
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.

isa_restrepo
11-23-2009, 03:33 PM
/*Definitions*/
size_t device_list_size_;
cl_context context_; /**< CL context */
cl_device_id *devices_; /**< CL device list */
cl_int status = CL_SUCCESS;


context_ = clCreateContextFromType(
0,
CL_DEVICE_TYPE_CPU,
NULL,
NULL,
&status);

/* First, get the size of device list data */
status = clGetContextInfo(
context_,
CL_CONTEXT_DEVICES,
0,
NULL,
&device_list_size_);

/* 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).\n";
return false;
}

/* Now, get the device list data */
status = clGetContextInfo(
context_,
CL_CONTEXT_DEVICES,
device_list_size_,
devices_,
NULL);

cout << "Context Description\n"
<< " Number of devices: " << device_list_size_ << '\n'


The output of this code is
Number of devices: 8

mpw
11-23-2009, 08:22 PM
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.

isa_restrepo
11-24-2009, 08:41 AM
Thank you so much, that answers my question!

seraulu1
03-29-2010, 08:37 AM
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.

seraulu1
03-29-2010, 08:42 AM
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.



Thanks for that!!!!! hypnosis downloads (http://theartofcoverthypnosis.com/)