kokkos-kernels
kokkos-kernels copied to clipboard
axpby won't compile for static-size view with clang
#include <Kokkos_Core.hpp>
#include <KokkosBlas1_axpby.hpp>
using ExecutionSpace = Kokkos::DefaultExecutionSpace;
using MemorySpace = ExecutionSpace::memory_space;
using Device = Kokkos::Device<ExecutionSpace,MemorySpace>;
int main(int argc, char* argv[]) {
Kokkos::initialize(argc,argv); {
float a = 3, b = 2;
Kokkos::View<float[3],Device> x("x"), y("y");
Kokkos::deep_copy(x, 1);
Kokkos::deep_copy(y, 4);
KokkosBlas::axpby(a, x, b, y);
} Kokkos::finalize();
}
gives this compilation error with clang 12.0.1 on OpenMP backend
/home/aznb/mycodes/testKokkos/build_clang/_deps/kokkos-src/core/src/Kokkos_View.hpp:1437:5: error: static_assert failed due to requirement 'ViewMapping<Kokkos::ViewTraits<float const[3], Kokkos::LayoutLeft, Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>, Kokkos::MemoryTraits<1>>, Kokkos::ViewTraits<float [3], Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>>, void>::is_assignable' "Incompatible View copy construction"
static_assert(Mapping::is_assignable,
^ ~~~~~~~~~~~~~~~~~~~~~~
/home/aznb/mycodes/testKokkos/build_clang/_deps/kokkos-kernels-src/src/blas/KokkosBlas1_axpby.hpp:111:29: note: in instantiation of function template specialization 'Kokkos::View<float const[3], Kokkos::LayoutLeft, Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>, Kokkos::MemoryTraits<1>>::View<float [3], Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>>' requested here
XMV_Internal X_internal = X;
^
/home/aznb/mycodes/testKokkos/testKokkosKernels.cpp:36:15: note: in instantiation of function template specialization 'KokkosBlas::axpby<float, Kokkos::View<float [3], Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>>, float, Kokkos::View<float [3], Kokkos::Device<Kokkos::OpenMP, Kokkos::HostSpace>>>' requested here
KokkosBlas::axpby(a, x, b, y);
However, this works on the CUDA backend. Changing the static-size views to dynamic-size ones also works.
This could be related: https://github.com/kokkos/kokkos/issues/3766