kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
kokkos.hpp
Go to the documentation of this file.
1
#ifndef KOKKOS_EXECUTION_TESTS_UTILS_KOKKOS_HPP
2
#define KOKKOS_EXECUTION_TESTS_UTILS_KOKKOS_HPP
3
4
#include <concepts>
5
#include <iostream>
6
#include <string_view>
7
8
#include "Kokkos_Core.hpp"
9
10
namespace
Tests::Utils
{
11
12
template
<Kokkos::ExecutionSpace Exec, Kokkos::ExecutionSpace OtherExec>
13
bool
are_same_instances
(
const
Exec& exec,
const
OtherExec& other_exec) {
14
if
constexpr
(std::same_as<Exec, OtherExec>) {
15
return
exec == other_exec;
16
}
else
{
17
return
false
;
18
}
19
}
20
21
template
<Kokkos::ExecutionSpace Exec>
22
constexpr
bool
on_device
() {
23
#if defined(KOKKOS_ENABLE_CUDA)
24
return
std::same_as<Exec, Kokkos::Cuda>;
25
#elif defined(KOKKOS_ENABLE_HIP)
26
return
std::same_as<Exec, Kokkos::HIP>;
27
#else
28
return
false
;
29
#endif
30
}
31
32
template
<Kokkos::ExecutionSpace Exec>
33
void
show_exec_space_id
(
const
Exec& exec, std::string_view label =
""
, std::ostream& out = std::cout) {
34
out <<
"Execution space instance "
<< label <<
" has device ID "
<< Kokkos::Tools::Experimental::device_id(exec)
35
<<
'.'
<< std::endl;
36
}
37
39
template
<
typename
ViewType>
40
requires
(ViewType::rank() == 1)
41
auto
span_from
(
const
ViewType& view)
noexcept
{
42
return
std::span{view.data(), view.size()};
43
}
44
45
}
// namespace Tests::Utils
46
47
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_KOKKOS_HPP
Tests::Utils
Definition
atomic.hpp:59
Tests::Utils::show_exec_space_id
void show_exec_space_id(const Exec &exec, std::string_view label="", std::ostream &out=std::cout)
Definition
kokkos.hpp:33
Tests::Utils::span_from
auto span_from(const ViewType &view) noexcept
Get a std::span from a rank-one Kokkos::View.
Definition
kokkos.hpp:41
Tests::Utils::on_device
constexpr bool on_device()
Definition
kokkos.hpp:22
Tests::Utils::are_same_instances
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Definition
kokkos.hpp:13
tests
utils
kokkos.hpp
Generated on
for kokkos-execution by
1.18.0