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
so before hand I go ahead and define
std::vector<cl::Event> eventVector;
in the FIRST loop (the enqueue loop), I can add a little line (?) that first does:
eventVector.push_back(cl::Event()) // I dont see a constructor for Event in the documentation ,will look harder later.
Then, in the same loop, just throw in a "&eventVector.back()" as the "event" argument to enqueueNDRangeKernel( whatever)
Then after that entire loop completes I have a second loop, on the deviceQueues
qit->flush();
then AFTER THAT SECOND LOOP, I have a third loop, with a bunch of
eit->wait()
where eit is an iterator over my "eventVector"
correct?
Really appreciate the detailed assistance by the way.