From b2faf609c2c132e7946f2d49c72d5ea44d3115cd Mon Sep 17 00:00:00 2001 From: Francesco Rizzi Date: Mon, 11 Oct 2021 18:15:39 +0200 Subject: [PATCH] dot: customization point to Kokkos-kernels and example --- examples/kokkos-based/dot_kokkos.cpp | 30 +++++++++++++++++++ .../experimental/__p1673_bits/blas1_dot.hpp | 21 ------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/examples/kokkos-based/dot_kokkos.cpp b/examples/kokkos-based/dot_kokkos.cpp index 1617c108..6e6060a5 100644 --- a/examples/kokkos-based/dot_kokkos.cpp +++ b/examples/kokkos-based/dot_kokkos.cpp @@ -4,6 +4,7 @@ int main(int argc, char* argv[]) { +<<<<<<< HEAD std::cout << "dot example: calling kokkos-kernels" << std::endl; std::size_t N = 50; @@ -21,11 +22,28 @@ int main(int argc, char* argv[]) mdspan_type a(a_ptr,N); mdspan_type b(b_ptr,N); for(std::size_t i=0; i a_view("A",N); + Kokkos::View b_view("B",N); + double* a_ptr = a_view.data(); + double* b_ptr = b_view.data(); + + using dyn_1d_ext_type = std::experimental::extents; + using mdspan_type = std::experimental::mdspan; + mdspan_type a(a_ptr,N); + mdspan_type b(b_ptr,N); + for(int i=0; i>>>>>> dot: customization point to Kokkos-kernels and example a(i) = i; b(i) = i; } namespace stdla = std::experimental::linalg; +<<<<<<< HEAD const value_type init_value(2.0); // This goes to the base implementation @@ -35,6 +53,18 @@ int main(int argc, char* argv[]) // This forwards to KokkosKernels const auto res_kk = stdla::dot(KokkosKernelsSTD::kokkos_exec<>(), a, b, init_value); printf("Kokkos result = %lf\n", res_kk); +======= + const double init_value = 2.0; + + // This goes to the base implementation + const auto res_seq = stdla::dot(std::execution::seq, a, b, init_value); + + // This forwards to KokkosKernels + auto res_kk = stdla::dot(KokkosKernelsSTD::kokkos_exec<>(), a, b, init_value); + + printf("Kokkos result = %lf\n", res_kk); + printf("Seq result = %lf\n", res_seq); +>>>>>>> dot: customization point to Kokkos-kernels and example } Kokkos::finalize(); } diff --git a/include/experimental/__p1673_bits/blas1_dot.hpp b/include/experimental/__p1673_bits/blas1_dot.hpp index 134d8081..59ba132f 100644 --- a/include/experimental/__p1673_bits/blas1_dot.hpp +++ b/include/experimental/__p1673_bits/blas1_dot.hpp @@ -78,15 +78,12 @@ struct is_custom_dot_avail< } // end anonymous namespace -<<<<<<< HEAD -======= // ------------ // PUBLIC API: // ------------ // dot, with init value ->>>>>>> dot: customization point to Kokkos-kernels and example template::size_type ext1, @@ -103,12 +100,9 @@ Scalar dot( std::experimental::mdspan, Layout2, Accessor2> v2, Scalar init) { -<<<<<<< HEAD static_assert(v1.static_extent(0) == dynamic_extent || v2.static_extent(0) == dynamic_extent || v1.static_extent(0) == v2.static_extent(0)); -======= ->>>>>>> dot: customization point to Kokkos-kernels and example constexpr bool use_custom = is_custom_dot_avail< decltype(execpolicy_mapper(exec)), decltype(v1), decltype(v2), Scalar @@ -141,10 +135,6 @@ Scalar dot(std::experimental::mdspan>>>>>> dot: customization point to Kokkos-kernels and example template::size_type ext1, class Layout1, @@ -201,8 +191,6 @@ namespace dot_detail { -> decltype(x(0) * y(0)); } // namespace dot_detail - -// dot, without init value template::size_type ext1, class Layout1, @@ -239,10 +227,6 @@ auto dot( return dot(exec, v1, v2, return_t{}); } -<<<<<<< HEAD -======= -// Conjugated dot, without init value ->>>>>>> dot: customization point to Kokkos-kernels and example template::size_type ext1, class Layout1, @@ -256,15 +240,10 @@ auto dotc( std::experimental::mdspan, Layout2, Accessor2> v2) -> decltype(dot_detail::dot_return_type_deducer(conjugated(v1), v2)) { -<<<<<<< HEAD using return_t = decltype(dot_detail::dot_return_type_deducer(conjugated(v1), v2)); -======= - using return_t = decltype(dot_detail::dot_return_type_deducer(v1, v2)); ->>>>>>> dot: customization point to Kokkos-kernels and example return dotc(v1, v2, return_t{}); } - template::size_type ext1,