alpaka-group / vikunja

Vikunja is a performance portable algorithm library that defines functions operating on ranges of elements for a variety of purposes . It supports the execution on multi-core CPUs and various GPUs. Vikunja uses alpaka to implement platform-independent primitives such as reduce or transform.
https://vikunja.readthedocs.io/en/latest/
Mozilla Public License 2.0
14 stars 5 forks source link

Check, if operator() functions of functor structs can be also templated #46

Closed SimeonEhrig closed 2 years ago

SimeonEhrig commented 2 years ago

At the moment, a template struct with operator() needs to use class templates. Check if function templates are also possible.

Currently possible:

template<typename TData>
struct DoubleNum
{
    ALPAKA_FN_HOST_ACC TData operator()(TData const i) const
    {
        return 2 * i;
    }
};

Nice to have:

struct DoubleNum
{
    template<typename TData>
    ALPAKA_FN_HOST_ACC TData operator()(TData const i) const
    {
        return 2 * i;
    }
};

See: https://github.com/alpaka-group/vikunja/pull/40#discussion_r737295713

SimeonEhrig commented 2 years ago

It is working and required because for the CUDA acc another type is automatically deducted then the distribution strategy, which the user defines.