Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blueshogun96

macrumors regular
Original poster
Nov 24, 2012
112
3
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
 
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

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");
 
  • Like
Reactions: blueshogun96
Very informative, thanks. I just hope that the majority of Macs support OpenCL. I've never used or learned it before.

Shogun
 
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.
 
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.
Ah, just was I was looking for. Thanks.

Shogun.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.