17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22 #ifndef KOKKOS_HOSTSPACE_HPP
23 #define KOKKOS_HOSTSPACE_HPP
30 #include <Kokkos_Core_fwd.hpp>
31 #include <Kokkos_Concepts.hpp>
32 #include <Kokkos_MemoryTraits.hpp>
34 #include <impl/Kokkos_Traits.hpp>
35 #include <impl/Kokkos_Error.hpp>
36 #include <impl/Kokkos_SharedAlloc.hpp>
37 #include <impl/Kokkos_Tools.hpp>
39 #include "impl/Kokkos_HostSpace_deepcopy.hpp"
53 using size_type = size_t;
64 using device_type = Kokkos::Device<execution_space, memory_space>;
73 #ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
77 #if defined(KOKKOS_COMPILER_GNU) && KOKKOS_COMPILER_GNU < 1100
82 enum KOKKOS_DEPRECATED
92 explicit HostSpace(
const AllocationMechanism&);
96 template <
typename ExecutionSpace>
97 void*
allocate(
const ExecutionSpace&,
const size_t arg_alloc_size)
const {
100 template <
typename ExecutionSpace>
101 void*
allocate(
const ExecutionSpace&,
const char* arg_label,
102 const size_t arg_alloc_size,
103 const size_t arg_logical_size = 0)
const {
104 return allocate(arg_label, arg_alloc_size, arg_logical_size);
106 void*
allocate(
const size_t arg_alloc_size)
const;
107 void*
allocate(
const char* arg_label,
const size_t arg_alloc_size,
108 const size_t arg_logical_size = 0)
const;
111 void deallocate(
void*
const arg_alloc_ptr,
const size_t arg_alloc_size)
const;
112 void deallocate(
const char* arg_label,
void*
const arg_alloc_ptr,
113 const size_t arg_alloc_size,
114 const size_t arg_logical_size = 0)
const;
116 void* impl_allocate(
const char* arg_label,
const size_t arg_alloc_size,
117 const size_t arg_logical_size = 0,
118 const Kokkos::Tools::SpaceHandle =
119 Kokkos::Tools::make_space_handle(
name()))
const;
120 void impl_deallocate(
const char* arg_label,
void*
const arg_alloc_ptr,
121 const size_t arg_alloc_size,
122 const size_t arg_logical_size = 0,
123 const Kokkos::Tools::SpaceHandle =
124 Kokkos::Tools::make_space_handle(
name()))
const;
127 static constexpr
const char*
name() {
return m_name; }
130 static constexpr
const char* m_name =
"Host";
144 template <
typename S>
151 typename S::execution_space::memory_space,
160 typename S::memory_space>::accessible
164 using Space = std::conditional_t<
165 keep_exe && keep_mem, S,
166 std::conditional_t<keep_mem,
168 typename S::memory_space>,
186 template <
class ExecutionSpace>
187 struct DeepCopy<HostSpace, HostSpace, ExecutionSpace> {
188 DeepCopy(
void* dst,
const void* src,
size_t n) {
189 hostspace_parallel_deepcopy(dst, src, n);
192 DeepCopy(
const ExecutionSpace& exec,
void* dst,
const void* src,
size_t n) {
196 "Kokkos::Impl::DeepCopy<HostSpace, HostSpace, "
197 "ExecutionSpace>::DeepCopy: fence before copy");
198 hostspace_parallel_deepcopy_async(dst, src, n);
200 hostspace_parallel_deepcopy_async(exec, dst, src, n);
209 #endif // #define KOKKOS_HOSTSPACE_HPP
Can AccessSpace access MemorySpace ?
void * allocate(const ExecutionSpace &, const size_t arg_alloc_size) const
Allocate untracked memory in the space.
void deallocate(void *const arg_alloc_ptr, const size_t arg_alloc_size) const
Deallocate untracked memory in the space.
Memory management for host memory.
static constexpr const char * name()
Return Name of the MemorySpace.
Kokkos::Device< execution_space, memory_space > device_type
This memory space preferred device_type.
DefaultHostExecutionSpace execution_space
Default execution space for this memory space.
Access relationship between DstMemorySpace and SrcMemorySpace.