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_Macros.hpp"
9
#ifdef KOKKOS_ENABLE_EXPERIMENTAL_CXX20_MODULES
10
import
kokkos.core;
11
#else
12
# include "Kokkos_Core.hpp"
13
#endif
14
15
namespace
Tests::Utils
{
16
17
template
<Kokkos::ExecutionSpace Exec, Kokkos::ExecutionSpace OtherExec>
18
bool
are_same_instances
(
const
Exec& exec,
const
OtherExec& other_exec) {
19
if
constexpr
(std::same_as<Exec, OtherExec>) {
20
return
exec == other_exec;
21
}
else
{
22
return
false
;
23
}
24
}
25
26
template
<Kokkos::ExecutionSpace Exec>
27
constexpr
bool
on_device
() {
28
#if defined(KOKKOS_ENABLE_CUDA)
29
return
std::same_as<Exec, Kokkos::Cuda>;
30
#elif defined(KOKKOS_ENABLE_HIP)
31
return
std::same_as<Exec, Kokkos::HIP>;
32
#else
33
return
false
;
34
#endif
35
}
36
37
template
<Kokkos::ExecutionSpace Exec>
38
void
show_exec_space_id
(
const
Exec& exec, std::string_view label =
""
, std::ostream& out = std::cout) {
39
out <<
"Execution space instance "
<< label <<
" has device ID "
<< Kokkos::Tools::Experimental::device_id(exec)
40
<<
'.'
<< std::endl;
41
}
42
44
template
<
typename
ViewType>
45
requires
(ViewType::rank() == 1)
46
auto
span_from
(
const
ViewType& view)
noexcept
{
47
return
std::span{view.data(), view.size()};
48
}
49
50
}
// namespace Tests::Utils
51
52
#endif
// KOKKOS_EXECUTION_TESTS_UTILS_KOKKOS_HPP
Tests::Utils
Definition
test_sync_wait.cpp:20
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:38
Tests::Utils::span_from
auto span_from(const ViewType &view) noexcept
Get a std::span from a rank-one Kokkos::View.
Definition
kokkos.hpp:46
Tests::Utils::on_device
constexpr bool on_device()
Definition
kokkos.hpp:27
Tests::Utils::are_same_instances
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Definition
kokkos.hpp:18
tests
utils
kokkos.hpp
Generated on
for kokkos-execution by
1.18.0