alpaka-group / alpaka

Abstraction Library for Parallel Kernel Acceleration :llama:
https://alpaka.readthedocs.io
Mozilla Public License 2.0
353 stars 72 forks source link

[WIP] Use executionTask+enqueue instead of exec in examples #2219

Closed mehmetyusufoglu closed 8 months ago

mehmetyusufoglu commented 8 months ago

There are 2 ways of running a kernel. Some of the examples use alpaka::exec<Acc>(queue, workdiv...) + wait(queue) some others use createTaskKernel<Acc> and enqueue functions.

All of the exec and wait function call pairs converted to createTaskKernel + enqueue calls.

Tests All example results are the same as before these changes.

Clarification Needed:

alpaka::createTaskKernel<Acc>(
        workDiv2,
        kernel2, ...
)

for any new block and grid configuration. So the user code becomes longer. IMO we should provide additionally an enqueue which has the same signature as exec has and provide two interfaces of enqueue. Let us have a short discussion in the next developer meeting.

fwyzard commented 8 months ago

@mehmetyusufoglu these changes are not equivalent:

That said, why do you want to migrate back from exec to createTaskKernel + enqueue ? I'd rather always use exec and avoid the explicit creation of the temporary task.

mehmetyusufoglu commented 8 months ago

@mehmetyusufoglu these changes are not equivalent:

* `alpaka::exec<Acc>(queue, ...);` is equivalent to `task = alpaka::createTaskKernel<Acc>(...);  alpaka::enqueue(queue, task);`

* the call to `alpaka::wait(queue);` is needed in either case, if one wants to wait for the kernel execution to complete.

That said, why do you want to migrate back from exec to createTaskKernel + enqueue ? I'd rather always use exec and avoid the explicit creation of the temporary task.

.

@mehmetyusufoglu these changes are not equivalent:

* `alpaka::exec<Acc>(queue, ...);` is equivalent to `task = alpaka::createTaskKernel<Acc>(...);  alpaka::enqueue(queue, task);`

* the call to `alpaka::wait(queue);` is needed in either case, if one wants to wait for the kernel execution to complete.

That said, why do you want to migrate back from exec to createTaskKernel + enqueue ? I'd rather always use exec and avoid the explicit creation of the temporary task.

These changes are requested by Rene while we were talking about "why there are 2 different ways of calling kernels in examples". This is WIP, to be discussed. I can close the pull request if it is not needed.

About wait(), yes, I was doubted about it certainly. Thanks.

mehmetyusufoglu commented 8 months ago

Closed, not needed currently.

psychocoderHPC commented 8 months ago

@mehmetyusufoglu these changes are not equivalent:

  • alpaka::exec<Acc>(queue, ...); is equivalent to task = alpaka::createTaskKernel<Acc>(...); alpaka::enqueue(queue, task);
  • the call to alpaka::wait(queue); is needed in either case, if one wants to wait for the kernel execution to complete.

That said, why do you want to migrate back from exec to createTaskKernel + enqueue ? I'd rather always use exec and avoid the explicit creation of the temporary task.

@fwyzard Independent of the wrong removed waits. I am wondering if it makes more sense to remove alpaka::exec<Acc>() and provide alpaka::enqueue<Acc>(queue, workdiv, kernel) or alpaka::enqueue(alpaka::TagGpuCudaRt, queue, workdiv, kernel)? I do not see a real reason why we have two different naming to enqueue an kernel. That we have different function signatures makes IMO sense.