Finding your GPU's device/vendor ID

Discussion in 'Mac Programming' started by blueshogun96, Feb 28, 2016.

  1. blueshogun96 macrumors regular

    blueshogun96

    Joined:
    Nov 24, 2012
    #1
    Are there any APIs that can be used to retrieve the device/vendor ID from the user's GPU? I've tried searching through google, but didn't find anything yet. Any ideas? Thanks.

    Shogun
     
  2. teagls macrumors regular

    Joined:
    May 16, 2013
    #2
    You can use OpenCL or Metal. Here is an example with OpenCL.

    // CL_DEVICE_NAME

    clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_string), &device_string, NULL);

    printf(" CL_DEVICE_NAME: \t\t\t%s\n", device_string);


    // CL_DEVICE_VENDOR

    clGetDeviceInfo(device, CL_DEVICE_VENDOR, sizeof(device_string), &device_string, NULL);

    printf(" CL_DEVICE_VENDOR: \t\t\t%s\n", device_string);


    // CL_DRIVER_VERSION

    clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(device_string), &device_string, NULL);

    printf(" CL_DRIVER_VERSION: \t\t\t%s\n", device_string);


    // CL_DEVICE_INFO

    cl_device_type type;

    clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);

    if( type & CL_DEVICE_TYPE_CPU )

    printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU");

    if( type & CL_DEVICE_TYPE_GPU )

    printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU");

    if( type & CL_DEVICE_TYPE_ACCELERATOR )

    printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR");

    if( type & CL_DEVICE_TYPE_DEFAULT )

    printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
     
  3. blueshogun96 thread starter macrumors regular

    blueshogun96

    Joined:
    Nov 24, 2012
    #3
    Very informative, thanks. I just hope that the majority of Macs support OpenCL. I've never used or learned it before.

    Shogun
     
  4. marksatt macrumors regular

    Joined:
    Jun 26, 2013
    Location:
    Epic UK
    #4
    You can find the device ID from IOKit, though the process is a little convoluted. For example Chromium implemented this approach for their logging (https://chromiumcodereview.appspot.com/10383146/patch/8001/1005) - if you download the Hardware IO Tools from Apple's developer website's additional downloads page it contains IORegistryExplorer which you can use to find even more GPU information, which you can then query in your own application.
     
  5. blueshogun96 thread starter macrumors regular

    blueshogun96

    Joined:
    Nov 24, 2012
    #5
    Ah, just was I was looking for. Thanks.

    Shogun.
     

Share This Page