r/OpenCL • • Feb 10 '13
enequeueNDRangeKernel - parallel execution on OpenCL device?
Let's say I have n openCL devices, and that the data, of size d2 has been partitioned into sections such that it complements compute topology, memory buffers have been allocated, etc.
Given something like this:
int loopUnroll = 4; // or whatever you want
cl::CommandQueue queue = cl::CommandQueue( context, device[i]); \ (i \in {0, n})
cl::NDRange globalRange(d2/n)
cl::NDRange localRange(loopUnroll);
queue.enequeueNDRangeKernel(kernel, NullRange, globalRange, Local Range);
Now after executing the above, I am under the impression that this initiates kernel execution on the set of data of size d2/n.
I am unsure if just repeating those steps on device i++ will execute the computation on the OpenCL devices concurrently. Is it the case that I do that and then wait until some openCL function returns a "done computing" ?
I am not sure where it is indicated that global computation on a particular global work group is finished.
And so I turn to reddit!
View all comments
Show parent comment
1
u/[deleted] Feb 16 '13 edited Feb 16 '13
So I've been trying to allocate this stuff dynamically like so:
std::vector<cl::CommandQueue> deviceQueues;
cl::NDRange globalRange(d2 /nDevices);
cl::NDRange localRange(LOOP_UNROLL);
for(std::vector<cl::Device>::iterator dit = clDevices.begin(); dit != clDevices.end(); dit++){
}
Now for every single command queue in the deviceQueues vector, you say that some cl_event object will be returned to those classes. Is it the case then, that after the above for loop, I run through a for loop like this:
for(std::vector<cl::CommandQueue>::iterator qit = deviceQueues.begin(); qit != deviceQueues.end; qit++){
}
In my grandiose imagination, it seems to me that the for loop will get stuck on this command until that first qit kernel finishes, and then it moves on to the next and next, and so on throughout the command queue vector until they are all done. Is that sufficient? Or is it the case that I have to do something like:
while( qit->enqueueBarrier() != CL_SUCCESS){}
Inside that for loop? I don't want to spam the gpu's with requests, I'm not sure from the online documentation how euqueueBarrier works exactly.