kokkos-kernels icon indicating copy to clipboard operation
kokkos-kernels copied to clipboard

axpby won't compile for static-size view with clang

Open Char-Aznable opened this issue 4 years ago • 1 comments

#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.

Char-Aznable avatar Nov 03 '21 04:11 Char-Aznable

This could be related: https://github.com/kokkos/kokkos/issues/3766

Char-Aznable avatar Nov 19 '21 17:11 Char-Aznable