- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Does the following code, invokes the kernel to run like the attached image? or they runs one after another ?
clCreateCommandQueue(context, device, NULL, &status);
clEnqueueTask(command, task1, 0, NULL, &event1);
clEnqueueTask(command, task2, 0, NULL, &event1);
clEnqueueTask(command, task3, 0, NULL, &event1);
https://alteraforum.com/forum/attachment.php?attachmentid=14715&stc=1
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the tasks do not depend on each other such as using channels or pipes, then they should all run immediately one after the other (appearing to launch almost at the same time) once event1 has been completed. Enqueuing only places the task in the command queue and are executed sequentially as a FIFO without blocking on the host. If task2 depends on task1, some sort of management needs to be handled through events, channels, or barriers.
So ideally it would look like this, having them overlap each other right from the start:
| Task_3
| Task_2
| Task_1
|------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- If the tasks do not depend on each other such as using channels or pipes, then they should all run immediately one after the other (appearing to launch almost at the same time) once event1 has been completed. --- Quote End --- Not really; the last parameter of clEnqueueTask() is "an event object that identifies this particular kernel execution instance" (https://www.khronos.org/registry/opencl/sdk/1.2/docs/man/xhtml/clenqueuetask.html). So, in the code above I'm not sure what will happen. Probably, it will work but you have no control over what is in event1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I mistook the last parameter as an event waitlist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I put the wrong code. Suppose,
clEnqueueTask(command, task1, 0, NULL, &eventtask1); clEnqueueTask(command, task2, 0, NULL, &eventtask2); clEnqueueTask(command, task3, 0, NULL, &eventtask3); Say, Task 1 load 1 Million floats from global memory and channel pass it to task 2. Task 2 then perform summation and channel it to Task 3 Task 3 then write back to Global memory.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Ah, I put the wrong code. Suppose, clEnqueueTask(command, task1, 0, NULL, &eventtask1); clEnqueueTask(command, task2, 0, NULL, &eventtask2); clEnqueueTask(command, task3, 0, NULL, &eventtask3); Say, Task 1 load 1 Million floats from global memory and channel pass it to task 2. Task 2 then perform summation and channel it to Task 3 Task 3 then write back to Global memory. --- Quote End --- If you are using channels between the kernels, you do not need events, and probably should not use them, since the channels have synchronization built-in, and will stall the reader kernel when the channel is empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@HRZ
So the all tasks run like the attached image, just that, Task 2 will stall for data from channel(task1) and Task 3 will stall for data from channel(task2) ?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Ah, I put the wrong code. Suppose, clEnqueueTask(command, task1, 0, NULL, &eventtask1); clEnqueueTask(command, task2, 0, NULL, &eventtask2); clEnqueueTask(command, task3, 0, NULL, &eventtask3); Say, Task 1 load 1 Million floats from global memory and channel pass it to task 2. Task 2 then perform summation and channel it to Task 3 Task 3 then write back to Global memory. --- Quote End --- If you want the kernels to execute in pipeline fashion like your picture, you should use different command queues and pass data via channels, no need for event. Altera have excellent examples like FFT example and channelizer here (https://www.altera.com/products/design-software/embedded-software-developers/opencl/developer-zone.html).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks HRZ, matt. I think i got what i came for.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page