Results 1 to 8 of 8

Thread: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

  1. #1

    CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    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

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

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

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    3

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    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.

  4. #4

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    Code :
     /*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

  5. #5
    Junior Member
    Join Date
    Sep 2009
    Posts
    3

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    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.

  6. #6

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    Thank you so much, that answers my question!

  7. #7
    Junior Member
    Join Date
    Mar 2010
    Posts
    2

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    Quote Originally Posted by mpw
    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.

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    2

    Re: CL_CONTEXT_DEVICES info different from clGetDeviceIDs

    Quote Originally Posted by seraulu1
    Quote Originally Posted by mpw
    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

Similar Threads

  1. SegFault at clGetDeviceIDs?
    By ds789 in forum OpenCL
    Replies: 1
    Last Post: 12-28-2012, 03:48 PM
  2. clGetDeviceIDs() failing
    By clunis_immensus in forum OpenCL
    Replies: 5
    Last Post: 01-04-2012, 07:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •