8#include <Kokkos_Core.hpp>
18#if defined(Kokkos_ENABLE_CUDA)
20#include <cuda_runtime_api.h>
23#define SEND_TO_HOST(view) \
24 auto h_##view = Kokkos::create_mirror_view_and_copy( \
25 Kokkos::DefaultHostExecutionSpace{}, view)
31template <
typename ExecSpace>
33 return Kokkos::SpaceAccessibility<
34 Kokkos::DefaultHostExecutionSpace,
35 typename ExecSpace::memory_space>::accessible;
42 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
47#if defined(Kokkos_ENABLE_CUDA)
51 << (
cuda_total) / 1'000'000.0 <<
"MB" << std::endl;
63 size = ViewType::required_allocation_size(
v.extent(0));
64 }
else if (
v.rank() == 2) {
65 size = ViewType::required_allocation_size(
v.extent(0),
v.extent(1));
66 }
else if (
v.rank() == 3) {
67 size = ViewType::required_allocation_size(
v.extent(0),
v.extent(1),
70 size = ViewType::required_allocation_size(
v.size());
72 std::cout <<
v.label() <<
" size: " << size <<
"B = " << size / 1'000'000.0
76template <
typename ViewType>
79 auto m = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
v);
81 std::cout <<
m(
i) <<
sep;
83 std::cout << std::endl;
84 std::cout <<
v.label() <<
".extent(0): " <<
m.extent(0) << std::endl;
87template <
typename DataView>
90 using layout =
typename DataView::array_layout;
91 Kokkos::View<
typename DataView::const_value_type **,
layout,
92 Kokkos::DefaultHostExecutionSpace>
109template <
typename ViewType,
typename Comparator>
112 using T =
typename ViewType::non_const_value_type;
113 using R = Kokkos::pair<T, T>;
114 const int_t n =
v.extent_int(0);
116 R ret = Kokkos::make_pair(
v(0),
v(0));
118 const auto elt =
v(
i);
typename std::remove_cv< typename std::remove_reference< T >::type >::type base_type
Returns a type without reference or const/volatile modifiers.
void ExportMatView(const DataView &data, const index_t rows, const index_t cols, std::fstream &file)
KOKKOS_INLINE_FUNCTION auto RbfPumMinMax(const ViewType &v, const Comparator &op)
A reimplementation of Kokkos::MinMax which works on any backend.
KOKKOS_FORCEINLINE_FUNCTION constexpr bool IsHostAccessible(void)
void PrintSizeOfView(ViewType &v)
Prints the memory usage of a Kokkos::View
void PrintView(ViewType &v, std::string sep=" ")
static void PrintCudaMemoryUsage()
If Cuda is activated, prints the used Nvidia device memory, else do nothing.