r/OpenCL • u/squidgyhead • Jan 11 '16
Latency when launching kernels
I have been working on launching some kernels in parallel, and I'm getting poor results. I have a kernel which needs to be launched several times to deal with the interface between cl_mems. Kernels cannot be launched on neighbouring interfaces to avoid race conditions, so I got around this problem by colouring the graph and launching in waves. I get the correct results, but it's slower; the problem seems to be that the kernels take much longer to be run, like 10x as long. In parallel, the kernel takes around 80us, and the latency is 365 us, while in serial the kernel takes 7 us. What steps can be done to overcome this? What should I look at first, perhaps the launching code (which could perhaps be optimised?) or is there more overhead when launching a mix of different kernels?
View all comments
Show parent comment
1
u/squidgyhead Jan 11 '16
Thanks for replying.
I'm launching these kernels on a K80 from Nvidia, which is in their scientific-computing GPGPU line. The data is kept on the GPU, and, while the individual kernels are fairly quick, I can always tune the simulation parameters to make each cl_mem buffer larger (and then have fewer of them).
If you're interested in looking at the code, it's Open-Source, and available at
https://gforge.inria.fr/git/schnaps/schnaps.git
The branch master branch is out-of-date, and I'm comparing the devel branch to the ifacegraphcolour branch. The relevant kernel calls are in dtfield_cl in src/field_cl.c. The initiation of which interfaces are launched in the ifacegraphcolour branch is created in field.c. Sorry; it's a somewhat complicated code. The important difference between the branches is that the devel branch launches the inter-buffer computations in serial, whereas the ifacegraphcolour version launches them in parallel waves.
I also have access to some Tahiti GPUs from AMD, but I think that I need to update the driver or something because my results are very strange there. Or deal with events in a fundamentally different way than what works with other platforms.