Sign in to follow this  
jeff8j

OpenCL Continuous Kernel?

Recommended Posts

jeff8j    787
I am just starting to learn how to use opencl and from what I can tell there doesnt seem to be a way to run the kernel and read/write the buffers constantly I only see ways of running the kernel then getting the response and restarting the kernel which to me would seem like a huge waste if say some of the threads take longer than others wouldn’t the done ones have to sit around waiting?

Share this post


Link to post
Share on other sites
That's quite hard to read because there's no punctuation. Even though I'm reasonably sure where you intended your sentences to end, I'm confused. There's a question mark at the end but the sentences do not seem to form a question of any kind.

Share this post


Link to post
Share on other sites
Erik Rufelt    5901
It won't matter, if you have lots of work-items, which you should have. The threads that complete the kernel just restart and run it again for another work-item, so if you have a million work-items and a thousand threads it won't even be noticeable if one of those threads takes 100x longer than the others, as the others will run 1000 times anyway. If you only have as many work-items as there are cores, then yes all the others will wait for the slowest one, but if you have such a complex kernel that's run so few times then OpenCL probably isn't the right tool for the job. In that case, either do it on the CPU instead or try to change your kernel into a smaller kernel that runs 10x as many times and does part of the work each time. Edited by Erik Rufelt

Share this post


Link to post
Share on other sites
jeff8j    787
Hi Stroppy
your absolutely correct I wrote it on the way out the door and was pretty exhausted sorry about that.

Hi Erik
That does make sense I wasnt thinking about it that way until today and realize that I cant think of it as a function to a program but an entire program it self.

Another thought is what if I want results back as fast as possible then I would have to stop all the threads so the buffer could be read correct?
Then in that scenario it would have to restart the kernel since I had to stop everything to be read. Or is their a way to read the output but continue processing?

Share this post


Link to post
Share on other sites
Bacterius    13165
You cannot interrupt a kernel in progress except by crashing the driver (and losing all your output buffers in the process). GPU's do not support that kind of execution yet. What I usually do when I need my application to be responsive is to design the kernels to do the absolute minimum amount of work possible in a single kernel enqueue, and just submit them to the card a lot faster, that way I can interrupt it CPU-side whenever and have everything stop quickly.

As for reading back, I suppose you could copy the output buffer to a temporary buffer (still GPU-side), keep launching your kernels and read from that, so that you could still get your card to work while DMA-copying the last execution's results to the CPU, but be wary that if your kernels finish faster than you can actually get your output back to the CPU (for a discrete card, that's generally 4GB/s bandwidth) you [i]will[/i] run out of buffer memory, so it's not a great idea.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this