cms-sw / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
1.06k stars 4.24k forks source link

Investigate moving alpaka device code to .dev.cc files #44625

Open fwyzard opened 3 months ago

fwyzard commented 3 months ago

The common approach for alpaka device code is to template all functions on the accelerator type:

template <typename TAcc>
ALPAKA_ACC_FN int sum(TAcc const& acc, int a, int b) { ... }

Another approach could be to move the code inside the ALPAKA_ACCELERATOR_NAMESPACE and use the accelerator type explicitly:

namespace ALPAKA_ACCELERATOR_NAMESPACE {
  ALPAKA_ACC_FN int sum(Acc1D const& acc, int a, int b) { ... }
}

This should let us move alpaka code that is not otherwise templated from header files to .dev.cc files.

Now that we start to have a sizeable alpaka-based code base, we should maybe re-evaluate both options.

cmsbuild commented 3 months ago

cms-bot internal usage

cmsbuild commented 3 months ago

A new Issue was created by @fwyzard.

@Dr15Jones, @antoniovilela, @smuzaffar, @rappoccio, @makortel, @sextonkennedy can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

fwyzard commented 3 months ago

assign heterogeneous

cmsbuild commented 3 months ago

New categories assigned: heterogeneous

@fwyzard,@makortel you have been requested to review this Pull request/Issue and eventually sign? Thanks

makortel commented 3 months ago

I agree the explicit Acc1D would be worth of exploring.

I'd further argue the Acc1D might be interesting option also when the function is otherwise templated, because the function (usually?) makes some assumption on the dimensionality of the Acc, and I'd assume the explicit Acc1D would ensure consistency between the function and the alpaka::exec() that calls the kernel calling the function.