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

Operator types #40

Closed SimeonEhrig closed 2 years ago

SimeonEhrig commented 2 years ago

The operator trait has two tasks:

  1. restrict the number of data arguments of a functor
  2. provide a functor interface with an optional acc object
SimeonEhrig commented 2 years ago

@sbastrakov Bernhard helped me to find the problem, why I cannot use plain __device__ functions with the CUDA and the HIP backend in vikunja. The reason is I use the attribute ALPAKA_FN_HOST_ACC (__host__ __device__) and I pass the function pointer of the host version to vikunja and not the pointer of the device version. To get the device pointer, I need the function cudaMemcpyFromSymbol like in this example: https://newbedev.com/cuda-function-pointers

I think, this is the same reason, why we does not support plain __device__ functions in alpaka. Can you confirm this?

bernhardmgruber commented 2 years ago

I think you are right wrt. function pointers, but lambda functions and functors should work. Maybe it is fine for vikunja to just not allow function pointers.

sbastrakov commented 2 years ago

I also think you are right about __device__ functions in CUDA, but labmdas should work.

SimeonEhrig commented 2 years ago

Yes, I forbid it. We have with structs with operator() and lambda two working options and plain function would be only semantic sugar.

SimeonEhrig commented 2 years ago

ready for review