alpaka-group / alpaka

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

Examples with switches for all possible compilers? #502

Open tdd11235813 opened 6 years ago

tdd11235813 commented 6 years ago

The alpaka examples should provide all possible compiler switches, for instance:

#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
    using Acc = alpaka::acc::AccGpuCudaRt<Dim, Idx>;
    using QueueAcc = alpaka::queue::QueueCudaRtSync;
#elif defined(ALPAKA_ACC_GPU_HIP_ENABLED)
    using Acc = alpaka::acc::AccGpuHipRt<Dim, Idx>;
    using QueueAcc = alpaka::queue::QueueHipRtSync;
#else
    using Acc = alpaka::acc::AccCpuSerial<Dim, Idx>;
    using QueueAcc = alpaka::queue::QueueCpuSync;
// ...
// use Acc, QueueAcc, ...

That can probably a long thing, but can be a code snippet in a header used by all examples?

At the moment vectorAdd uses only the CPU backend. For a testing scenario I switched by cmake to CUDA, but I still had to change code in main.cpp to test it on CUDA. So what could be a common approach to have a proper code that tests backends as configured by cmake?

Edit: fixed code snippet

BenjaminW3 commented 6 years ago

The examples do not do this on desire. This would make the code unnecessarily larger/complex.

All the unit tests as well as the integration tests are already tested for all available accelerators with multiple dimensions and index types.

tdd11235813 commented 6 years ago

agreed. I had assumed that the examples shall work on different accelerators. But there should be kind of an advanced example, which show handling of multiple accelerators. If someone uses alpaka, he likely wants to see that.

bernhardmgruber commented 1 year ago

Isn't this already solved by the <alpaka/example/ExampleDefaultAcc.hpp>>. See here. And the queue can be created from the accelerator selected by that header.