Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6802643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:14:52+00:00 2026-05-26T19:14:52+00:00

I am writing a OpenCL program in which multiple kernels are being called on

  • 0

I am writing a OpenCL program in which multiple kernels are being called on multiple devices. After I have enqueued all of the kernels I would like to wait until any of them has finished and then enqueue work for that device afterwords.

For instance, I have devices A and B and each of them have a kernel. If A finishes first, I want to enqueue a new kernel in it after doing some work. If B finishes first I want to enqueue a new kernel for it after doing some work. I’m looking for something like a clWaitForAnyEvent which will return after any event passed in has finished.

Looking at the spec, I see a clWaitForEvents method, but it seems that it will wait for all of the event to finish before continuing, and I want to continue after one event (and need to know which event finished).

The options I can think of right now are:

  1. Busy-wait using clGetEventInfo to test for event completion.

  2. Multi-thread having one thread for each event (will only need a few threads, but am using the CPU as one of the devices)

  3. Missed something in the specification and there is actually a method that does this for me.

Any suggestions of how to proceed or something that I am missing?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:14:53+00:00Added an answer on May 26, 2026 at 7:14 pm

    Your answer is 3.

    clWaitForEvents will do exactly what you want. Let’s say you have a command queue for a device which we will call klee_dev. You can enqueue work on klee_dev like this:

    cl_event event;
    cl_int status = clEnqueueNDRangeKernel(queue_for_klee_dev, ..., &event);
    
    /* enqueue other work on other devices, perhaps even klee_dev */
    
    clWaitForEvents(1, &event);
    

    The call to clWaitForEvents will block until the work you enqueued on klee_dev‘s command queue completes. It will not wait for other work to complete; just the work specified by enqueue call associated with that one event.

    EDIT:

    I misunderstood the original question, which was clarified below. The OP was asking if there is a method in the CL specification that, given a set of events, will block until any one of the events completes. There is currently no such method.

    EDIT, again:

    You could register a callback method for each event with clSetEventCallback. Within the callback, you can query the event with clGetEventInfo to find out what command queue was associated with the event.

    That gives you what you require, I think: notification of any event completion, and the ability to find out what command queue is associated with the event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program using JOGL/openCL to utilize the GPU. I have code that
I am writing a small program in OpenGL on my Mac. I have a
I have been writing an OpenGL game engine for a while which uses SDL
I am writing an opengl based iphone app and would like to allow a
I'm writing a program which calculates the Mandelbrot Set (and then renders it in
I am writing an android program in which I built a box using opengl
I'm writing an algorithm in OpenCL which needs a data structure temporarily (during execution)
I am writing a simple OpenGL program with Qt Creator which basically creates a
Does anyone have experience writing professional OpenGL games on Windows? For the Mac, due
I'm writing a basic planet viewer OpenGL Perl application, just for fun. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.