ofxMSAOpenCl particles example on integrated graphics card?

Hello All

I’ve been working with ofxMSAOpenCl for a while. But I’ve never managed to get it to run with openGl interop on a mac integrated Intel graphics card.

As a test, I’ve set up the simple particles example on my Mac. When I call opencl.setupFromOpenGL(); the example runs well; and reports device #0 as Intel Iris Pro, device #1 as AMD Radeon etc.

I assume that the above is running using the AMD, as when I subsequently call opencl.setupFromOpenGL(1); the example continues to compile fine. However, when I then call to use the Intel card (i.e. opencl.setupFromOpenGL(0); ) I get a crash on the initialisation of the buffers:

[ error ] Error creating command queue.
[verbose] OpenCLBuffer::initBuffer
[verbose] OpenCLMemoryObject::memoryObjectInit
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: CL_INVALID_COMMAND_QUEUE

Does anyone else have this issue, or a workaround? I understand that I can just run using the AMD card, but on mac laptops without a discrete card, this isn’t an option; and I want to test for these.

Thanks
Sam

On my laptop (PC) the first device (#0) is labeled 1.
I set Opencl to run on it with opencl.setupFromOpenGL(1)
on the second one with opencl.setupFromOpenGL(2)

I had bad experiences with opencl.setupFromOpenGL() as it worked sometimes (one time for 5 try)…

If it’s possible, try to reduce your graphics consumption (no extended desktop, …). It can helps

Hello,

Thanks for the reply. But I don’t think this is the issue. Using opencl.setupFromOpenGL(2) equally reports the error. In the notes above the function definition it says:

// initializes openCL with the passed in device number
// use zero-based device number (0, 1, 2 etc) NOT clDeviceId
// use getDeviceInfos to see what devices are available
// or use deviceNumber = 0 to use first device found
// or use deviceNumber = -1 to use last device found (best for Macs with multiple GPUs)

I’ve run checks on both deviceNumber = 0 and = 2 by calling cout<<opencl.getDevice()<<endl; and it reports the correct device id for the integrated intel card. So the setup is running, and it looks as though it is failing at the line: clQueue = clCreateCommandQueue(clContext, clDevice, 0, &err);

Which is what returns [ error ] Error creating command queue.

S

UPDATE: testing the &err return on the clCreateCommandQueue gives error code -33; i.e. CL_INVALID_DEVICE; so it seems that the intel device isn’t being recognised??

Ok, found the issue

On a mac, with more than one graphics card, the card needs to be definitely switched on before the clCreateCommandQueue call. But, with dynamic switching, usually normally the higher powered discrete card is active at this point. As a result, calls to deviceNumber = 1, etc, work, as they find the discrete card; but deviceNumber = 0 finds the intel card, which is fast asleep.

I downloaded gfxCardStatus and forced the machine to integrated only, and hey presto, opencl.setupFromOpenGL(0); compiles and runs happily enough. A bit annoying but fine for just testing the app on the intel device.

S

1 Like