45 #ifndef KOKKOS_SYCLSPACE_HPP 46 #define KOKKOS_SYCLSPACE_HPP 48 #include <Kokkos_Core_fwd.hpp> 50 #ifdef KOKKOS_ENABLE_SYCL 51 #include <Kokkos_Concepts.hpp> 52 #include <Kokkos_ScratchSpace.hpp> 53 #include <SYCL/Kokkos_SYCL_Instance.hpp> 54 #include <impl/Kokkos_SharedAlloc.hpp> 55 #include <impl/Kokkos_Tools.hpp> 60 class SYCLDeviceUSMSpace {
62 using execution_space = SYCL;
63 using memory_space = SYCLDeviceUSMSpace;
64 using device_type = Kokkos::Device<execution_space, memory_space>;
65 using size_type = Impl::SYCLInternal::size_type;
68 explicit SYCLDeviceUSMSpace(sycl::queue queue);
70 void* allocate(
const std::size_t arg_alloc_size)
const;
71 void* allocate(
const char* arg_label,
const size_t arg_alloc_size,
72 const size_t arg_logical_size = 0)
const;
74 void deallocate(
void*
const arg_alloc_ptr,
75 const std::size_t arg_alloc_size)
const;
76 void deallocate(
const char* arg_label,
void*
const arg_alloc_ptr,
77 const size_t arg_alloc_size,
78 const size_t arg_logical_size = 0)
const;
81 template <
class,
class,
class,
class>
82 friend class LogicalMemorySpace;
85 static constexpr
const char* name() {
return "SYCLDeviceUSM"; };
91 class SYCLSharedUSMSpace {
93 using execution_space = SYCL;
94 using memory_space = SYCLSharedUSMSpace;
95 using device_type = Kokkos::Device<execution_space, memory_space>;
96 using size_type = Impl::SYCLInternal::size_type;
99 explicit SYCLSharedUSMSpace(sycl::queue queue);
101 void* allocate(
const std::size_t arg_alloc_size)
const;
102 void* allocate(
const char* arg_label,
const size_t arg_alloc_size,
103 const size_t arg_logical_size = 0)
const;
105 void deallocate(
void*
const arg_alloc_ptr,
106 const std::size_t arg_alloc_size)
const;
107 void deallocate(
const char* arg_label,
void*
const arg_alloc_ptr,
108 const size_t arg_alloc_size,
109 const size_t arg_logical_size = 0)
const;
112 template <
class,
class,
class,
class>
113 friend class LogicalMemorySpace;
116 static constexpr
const char* name() {
return "SYCLSharedUSM"; };
125 Kokkos::Experimental::SYCLDeviceUSMSpace,
126 Kokkos::Experimental::SYCLDeviceUSMSpace>::assignable,
130 Kokkos::Experimental::SYCLSharedUSMSpace,
131 Kokkos::Experimental::SYCLSharedUSMSpace>::assignable,
135 struct MemorySpaceAccess<
Kokkos::HostSpace,
136 Kokkos::Experimental::SYCLDeviceUSMSpace> {
137 enum :
bool { assignable =
false };
138 enum :
bool { accessible =
false };
139 enum :
bool { deepcopy =
true };
143 struct MemorySpaceAccess<
Kokkos::HostSpace,
144 Kokkos::Experimental::SYCLSharedUSMSpace> {
146 enum :
bool { assignable =
false };
147 enum :
bool { accessible =
true };
148 enum :
bool { deepcopy =
true };
152 struct MemorySpaceAccess<
Kokkos::Experimental::SYCLDeviceUSMSpace,
154 enum :
bool { assignable =
false };
155 enum :
bool { accessible =
false };
156 enum :
bool { deepcopy =
true };
160 struct MemorySpaceAccess<
Kokkos::Experimental::SYCLDeviceUSMSpace,
161 Kokkos::Experimental::SYCLSharedUSMSpace> {
163 enum :
bool { assignable =
true };
164 enum :
bool { accessible =
true };
165 enum :
bool { deepcopy =
true };
173 struct MemorySpaceAccess<
Kokkos::Experimental::SYCLSharedUSMSpace,
175 enum :
bool { assignable =
false };
176 enum :
bool { accessible =
false };
177 enum :
bool { deepcopy =
true };
181 struct MemorySpaceAccess<
Kokkos::Experimental::SYCLSharedUSMSpace,
182 Kokkos::Experimental::SYCLDeviceUSMSpace> {
186 enum :
bool { assignable =
false };
189 enum :
bool { accessible =
true };
190 enum :
bool { deepcopy =
true };
194 struct MemorySpaceAccess<
195 Kokkos::Experimental::SYCLDeviceUSMSpace,
197 enum :
bool { assignable =
false };
198 enum :
bool { accessible =
true };
199 enum :
bool { deepcopy =
false };
203 struct MemorySpaceAccess<
204 Kokkos::Experimental::SYCLSharedUSMSpace,
206 enum :
bool { assignable =
false };
207 enum :
bool { accessible =
true };
208 enum :
bool { deepcopy =
false };
216 class SharedAllocationRecord<
Kokkos::Experimental::SYCLDeviceUSMSpace, void>
217 :
public HostInaccessibleSharedAllocationRecordCommon<
218 Kokkos::Experimental::SYCLDeviceUSMSpace> {
220 friend class SharedAllocationRecordCommon<
221 Kokkos::Experimental::SYCLDeviceUSMSpace>;
222 friend class HostInaccessibleSharedAllocationRecordCommon<
223 Kokkos::Experimental::SYCLDeviceUSMSpace>;
224 using base_t = HostInaccessibleSharedAllocationRecordCommon<
225 Kokkos::Experimental::SYCLDeviceUSMSpace>;
226 using RecordBase = SharedAllocationRecord<void, void>;
228 SharedAllocationRecord(const SharedAllocationRecord&) = delete;
229 SharedAllocationRecord(SharedAllocationRecord&&) = delete;
230 SharedAllocationRecord& operator=(const SharedAllocationRecord&) = delete;
231 SharedAllocationRecord& operator=(SharedAllocationRecord&&) = delete;
233 #ifdef KOKKOS_ENABLE_DEBUG 234 static RecordBase s_root_record;
237 const Kokkos::Experimental::SYCLDeviceUSMSpace m_space;
240 ~SharedAllocationRecord();
242 SharedAllocationRecord(
243 const Kokkos::Experimental::SYCLDeviceUSMSpace& arg_space,
244 const std::string& arg_label, const size_t arg_alloc_size,
245 const RecordBase::function_type arg_dealloc = &base_t::deallocate);
249 class SharedAllocationRecord<Kokkos::Experimental::SYCLSharedUSMSpace, void>
250 :
public SharedAllocationRecordCommon<
251 Kokkos::Experimental::SYCLSharedUSMSpace> {
253 friend class SharedAllocationRecordCommon<
254 Kokkos::Experimental::SYCLSharedUSMSpace>;
256 SharedAllocationRecordCommon<Kokkos::Experimental::SYCLSharedUSMSpace>;
257 using RecordBase = SharedAllocationRecord<void, void>;
259 SharedAllocationRecord(const SharedAllocationRecord&) = delete;
260 SharedAllocationRecord(SharedAllocationRecord&&) = delete;
261 SharedAllocationRecord& operator=(const SharedAllocationRecord&) = delete;
262 SharedAllocationRecord& operator=(SharedAllocationRecord&&) = delete;
264 static RecordBase s_root_record;
266 const Kokkos::Experimental::SYCLSharedUSMSpace m_space;
269 ~SharedAllocationRecord();
271 SharedAllocationRecord() = default;
273 SharedAllocationRecord(
274 const Kokkos::Experimental::SYCLSharedUSMSpace& arg_space,
275 const std::string& arg_label, const size_t arg_alloc_size,
276 const RecordBase::function_type arg_dealloc = &base_t::deallocate);
Scratch memory space associated with an execution space.
Memory management for host memory.
Access relationship between DstMemorySpace and SrcMemorySpace.