I'm trying to get my current OpenCL program to run on my secondary video card. At the moment I'm running two Radeon HD 5800 cards (no crossfire) with a Windows 7 64 bit OS. The program compiles and runs just fine when I select my primary video card but when I try to select my secondary card it gives an invalid device error when I try to create command queue. The device shows up when I do a device query and I don't think I'm doing something wrong when selecting the device since I run the same exact process to pick my primary card. Are there any subtleties I should be aware of that may resolve this?
Solved! Go to Solution.
It is a very nice code, your problem is:
context = clCreateContext(properties, 1, devices, NULL, NULL, &err); |
You are including only the 1st device in the context. You should have
context = clCreateContext(properties, num_devs_returned, devices, NULL, NULL, &err); |
But just as a warning, if you create memory objects, they might get copied to all the devices in the context. So you might instead prefer
context = clCreateContext(properties, 1, &devices[device_used], NULL, NULL, &err);
Is the second device recognized using "clinfo"?
Yes. I have a function that pulls up all pertinent device info before I select which device to use. Both video cards give information back. Of course both are the same make and model so that information in more or less identical (I don't have my program in front of me at the moment so I can't confirm all this), so it's possible that it's showing me the same card twice. But I don't think that's that case.
could you post some sample code?
It is a very nice code, your problem is:
context = clCreateContext(properties, 1, devices, NULL, NULL, &err); |
You are including only the 1st device in the context. You should have
context = clCreateContext(properties, num_devs_returned, devices, NULL, NULL, &err); |
But just as a warning, if you create memory objects, they might get copied to all the devices in the context. So you might instead prefer
context = clCreateContext(properties, 1, &devices[device_used], NULL, NULL, &err);
Thanks! That did the trick.
try run SimpleMultiDevice example program from SDK or any other program with -d N parameter. N is number which one device should be used. it start at 0.