alpaka-group / alpaka

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

simplification of workdiv creation #2240

Closed mehmetyusufoglu closed 4 months ago

mehmetyusufoglu commented 4 months ago

Workdiv constructor needs 2 class template parameters and 3 alpaka::Vec arguments. auto const workdiv = alpaka::WorkDivMembers<Dim, Idx>{arraySize / blockSize, (int)blockSize, 1u};

The aim is being able to create workdiv, without template parameters, for example auto const workdiv = createWorkDiv(arraySize / blockSize, blockSize, 1);

Update: Factory method is not used, a new constructor is introduced, no need for explicit type params in the new constructor call. All 3 input types must be alpaka::Vec with the same TDim type. auto const workDiv2D = alpaka::WorkDivMembers(blocksPerGrid2D, threadsPerBlock2D, elementsPerThread2D);

Another PR [2243] is provided onto this one, for using std::array instead of alpaka vectors as arguments. Class template parameters are not needed.

bernhardmgruber commented 4 months ago

Just tried it, if you add the constructor:

        ALPAKA_FN_HOST_ACC WorkDivMembers(
            alpaka::Vec<TDim, TIdx> const& gridBlockExtent,
            alpaka::Vec<TDim, TIdx> const& blockThreadExtent,
            alpaka::Vec<TDim, TIdx> const& elemExtent)
            : m_gridBlockExtent(gridBlockExtent)
            , m_blockThreadExtent(blockThreadExtent)
            , m_threadElemExtent(elemExtent)
        {
        }

your unit test can be written using:

    auto ref = alpaka::WorkDivMembers(blocksPerGrid3D, threadsPerBlock3D, elementsPerThread3D);

and compiles and passes the tests.

psychocoderHPC commented 4 months ago

we need to fix the OSX CI before we can merge this.

psychocoderHPC commented 4 months ago

@mehmetyusufoglu could you please rebase this against the develop branch? I merged the OSX CI fix