Jump to content
  • Advertisement
Sign in to follow this  
jeff8j

OpenCL Continuous Kernel?

This topic is 2131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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 will run out of buffer memory, so it's not a great idea.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!