3 #include "ttg/config.h"
12 #if defined(TTG_HAVE_CUDA)
14 #elif defined(TTG_HAVE_HIP)
16 #elif defined(TTG_HAVE_LEVEL_ZERO)
36 throw std::runtime_error(
"No valid ID for Host execution space!");
39 throw std::runtime_error(
"Invalid execution space!");
44 operator int()
const {
71 os <<
"(" << device.
id() <<
")";
77 #if defined(TTG_HAVE_CUDA)
78 #include <cuda_runtime.h>
83 inline thread_local cudaStream_t current_stream_ts = 0;
85 inline void reset_current() {
86 current_device_ts = {};
87 current_stream_ts = 0;
90 inline void set_current(
int device, cudaStream_t stream) {
92 current_stream_ts = stream;
98 return detail::current_device_ts;
103 return detail::current_stream_ts;
107 #elif defined(TTG_HAVE_HIP)
109 #include <hip/hip_runtime.h>
114 inline thread_local hipStream_t current_stream_ts = 0;
116 inline void reset_current() {
117 current_device_ts = {};
118 current_stream_ts = 0;
121 inline void set_current(
int device, hipStream_t stream) {
123 current_stream_ts = stream;
129 return detail::current_device_ts;
134 return detail::current_stream_ts;
138 #elif defined(TTG_HAVE_LEVEL_ZERO)
140 #include <CL/sycl.hpp>
145 inline thread_local sycl::queue* current_stream_ts =
nullptr;
148 inline void reset_current() {
149 current_device_ts = {};
150 current_stream_ts =
nullptr;
153 inline void set_current(
int device, sycl::queue& stream) {
155 current_stream_ts = &stream;
161 return detail::current_device_ts;
166 return *detail::current_stream_ts;
177 template<ttg::ExecutionSpace Space = ttg::ExecutionSpace::Inval
id>
180 "TTG was built without any known device support so we cannot provide a current stream!");
Represents a device in a specific execution space.
ttg::ExecutionSpace space() const
Device(int id, ttg::ExecutionSpace space)
std::ostream & operator<<(std::ostream &os, ttg::device::Device device)
const char * execution_space_name(ExecutionSpace space) noexcept
constexpr ttg::ExecutionSpace available_execution_space
const void * current_stream()
ExecutionSpace
denotes task execution space