Reputation: 1
I'm writing an OpenCL code for an n-body algorithm. I'm getting an Invalid Context error when I try to execute it. The error comes in the part of the code that calls the kernel for execution on the GPU. I've pasted my code here. If anyone can help me understand why I'm getting this error and help me solve it, I'd be grateful.
if (gpuSize) {
/*launch the kernel on second device (GPU)*/
ret = clEnqueueNDRangeKernel(
accelState.queues[1],
accelState.kernel,
1,
global_work_offset1,
global_work_size1,
NULL, /*let OpenCL determine localWorkSize*/
1, &enqEvents[noOfQEvents-1],
&enqEvents[noOfEvents]
);
/*noOfEvents++;*/
checkResult(ret);
}
I'm getting an error on the last line checkResult(ret) but as I understand it, there's a mismatch between my command queue accelState.queues[1] and something in the kernel? Any help would be much apppreciated. Thank you.
Upvotes: 0
Views: 1865
Reputation: 8410
The problem is clear, you are running a kernel from one context (context B), in a queue of another context (context A).
That is not allowed, all the objects can only interact with their own context objects. That applies to kernel, buffers, queues, events, etc..
However, HW resources like devices can be used in different contexts.
Upvotes: 1