kokkos-execution 0.0.1
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
10namespace Tests::Utils {
11
12template <Kokkos::ExecutionSpace Exec, Kokkos::ExecutionSpace OtherExec>
13bool 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
21template <Kokkos::ExecutionSpace Exec>
22constexpr 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
32template <Kokkos::ExecutionSpace Exec>
33void 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
38} // namespace Tests::Utils
39
40#endif // KOKKOS_EXECUTION_TESTS_UTILS_KOKKOS_HPP
void show_exec_space_id(const Exec &exec, std::string_view label="", std::ostream &out=std::cout)
Definition kokkos.hpp:33
constexpr bool on_device()
Definition kokkos.hpp:22
bool are_same_instances(const Exec &exec, const OtherExec &other_exec)
Definition kokkos.hpp:13