Skip to content

alpaka::onAcc::SimdAlgo.concurent() does not respect const modifier #374

@SimeonEhrig

Description

@SimeonEhrig

In the babelstream benchmark kernel, all IMdSpan objects in the SimdForEachKernel kernel are annotate with const. Therefore they should be not writable.

struct SimdForEachKernel
{
//! \param acc The accelerator to be executed on.
//! \param func functor applied to each SIMD package.
//! \param arg0 MdSpan from which the problem size is derived
//! \param args MdSpan other spans
ALPAKA_FN_ACC void operator()(
auto const& acc,
auto const& func,
alpaka::concepts::MdSpan auto const& arg0,
alpaka::concepts::MdSpan auto const&... args) const
{
auto simdGrid = onAcc::SimdAlgo{onAcc::worker::threadsInGrid};
simdGrid.concurrent(acc, arg0.getExtents(), func, arg0, args...);
}
};

The kernel is called with the functor SimdCopyOp functor, which writes to a buffer, which should be forbidden.

struct SimdCopyOp
{
constexpr void operator()(auto const&, auto const a, auto c) const
{
c = a.load();
}
};

measureKernelExec(
[&]()
{
queue.enqueue(
exec,
dataBlocking,
KernelBundle{SimdForEachKernel{}, SimdCopyOp{}, bufAccInputA, bufAccOutputC});
},
"CopyKernel");

I didn't check the code, but I think we lost the const information when access to memory pointer to create the simd types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions