How to programmatically discover specific GPU on platform with multiple GPUs (OpenCL 1.1)?

It sounds like you know that you can get the devices in your system with clGetDeviceIds and that you can query them for things like CL_DEVICE_NAME using clGetDeviceInfo.

It sounds like you know that you can get the devices in your system with clGetDeviceIds, and that you can query them for things like CL_DEVICE_NAME using clGetDeviceInfo. Unfortunately, I don't think the OpenCL API currently has a cross-platform way to identify the compute device currently used to drive the display. Most of the time, folks want to get this device so that they can do faster OpenGL / OpenCL sharing by using the same device.In your case, you want to know what device is driving the display in order to ignore it.

However, there is a way to do this that is specific to the Macintosh. Since you mentioned that you're on a Mac, here's process: Create an OpenCL context with your GPU devices. Ask the system for the current OpenGL context.

Ask OpenCL via an extension (from cl_gl_ext. H) which device is driving the display. Use the vendor id to ignore that device.

Here's a complete program which will do this on a Mac. I'm running Lion. // compile with: // clang -o test test.

C -framework GLUT -framework OpenGL -framework OpenCL #include #include #include #include #include #include int main (int argc, char const *argv) { int i; cl_int error; // We need to do *something* to create a GL context: glutInit( &argc, (char**)argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow( "OpenCL OpenGL Test" ); // So we can ask CGL for it: CGLContextObj gl_context = CGLGetCurrentContext(); CGLShareGroupObj share_group = CGLGetShareGroup(gl_context); cl_context_properties properties = { CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (intptr_t)share_group, 0 }; cl_context context = clCreateContext(properties, 0, NULL, 0, 0, &error); // And now we can ask OpenCL which particular device is being used by // OpenGL to do the rendering, currently: cl_device_id renderer; clGetGLContextInfoAPPLE(context, gl_context, CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE, sizeof(renderer), &renderer, NULL); cl_uint id_in_use; clGetDeviceInfo(renderer, CL_DEVICE_VENDOR_ID, sizeof(cl_uint), &id_in_use, NULL); // Determine the number of devices: size_t size; cl_uint num_devices; clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size); num_devices = size / sizeof(cl_device_id); cl_device_id devicesnum_devices; clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, NULL); // Now we have everything we need to use the device that IS NOT doing // rendering to the screen for our compute: char buf128; cl_uint vendor_id; for (i = 0; I Show me your output! I don't have a two GPU box :) On my friend's multi-GPU box, running Mac OS 10.7.2: GeForce GTX 285 (1022600) totally free for compute! GeForce GT 120 (2022600) in use by GL for display Note that there might be a better way than GLUT to get GL up and running.

But GLUT's not so bad -- you don't even have to show a window on the screen. This program doesn't.

Development/etc/gputest 538$ gputest ...ATI Radeon HD 5770 (1021b00) totally free for compute! ATI Radeon HD 5770 (2021b00) totally free for compute! – wjohnson Nov 16 at 19:26 Hmm... that's not good.

I'll try to get access to a multi-card box and see what I get. Likely I have a bug! – James Nov 16 at 21:14 Did you run the program over ssh?

It seems to work on multiple-card machines for me; see above. – James Nov 16 at 21:25 I ran it locally. Please provide the exact command you used so there is no variation.

– wjohnson Nov 16 at 22:25 In a terminal window, I ran clang as prescribed followed by . /test but still with the results reported above. Sw_vers displays ProductVersion 10.7.2; BuildVersion: 11C74.

The machine is only 3 weeks old. I know Unix but I'm too new to the Mac environment to offer ideas for why we're getting different results. – wjohnson Nov 167 at 2:39.

You might be interested in my library: https://github. Com/nbigaouette/oclutils/ I developed that library to manage multiple OpenCL device on a machine. It will sort the list of available devices automatically according to the number of "max_compute_unit" reported.

This way, on my machine, it will always pick up one of the two powerful Nvidia GTX 580 instead of the (crappy) GT220 which drives the display. It supports nvidia (GPU only), amd (CPU and/or GPU), intel (CPU only) and apple (CPU and/or GPU) platforms. Note that it won't be able to distinguish which of two identical cards is running the display so it's not a perfect solution for your problem.

I might try to integrate James' solution as this is something I am interested too.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions