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;
117 void* impl_allocate(
const char* arg_label,
const size_t arg_alloc_size,
118 const size_t arg_logical_size = 0,
119 const Kokkos::Tools::SpaceHandle =
120 Kokkos::Tools::make_space_handle(
name()))
const;
121 void impl_deallocate(
const char* arg_label,
void*
const arg_alloc_ptr,
122 const size_t arg_alloc_size,
123 const size_t arg_logical_size = 0,
124 const Kokkos::Tools::SpaceHandle =
125 Kokkos::Tools::make_space_handle(
name()))
const;
129 static constexpr
const char*
name() {
return m_name; }
132 static constexpr
const char* m_name =
"Host";
146 template <
typename S>
153 typename S::execution_space::memory_space,
162 typename S::memory_space>::accessible
166 using Space = std::conditional_t<
167 keep_exe && keep_mem, S,
168 std::conditional_t<keep_mem,
170 typename S::memory_space>,
189 struct DeepCopy<HostSpace, HostSpace, DefaultHostExecutionSpace> {
190 DeepCopy(
void* dst,
const void* src,
size_t n) {
191 hostspace_parallel_deepcopy(dst, src, n);
194 DeepCopy(
const DefaultHostExecutionSpace& exec,
void* dst,
const void* src,
196 hostspace_parallel_deepcopy_async(exec, dst, src, n);
200 template <
class ExecutionSpace>
201 struct DeepCopy<HostSpace, HostSpace, ExecutionSpace> {
202 DeepCopy(
void* dst,
const void* src,
size_t n) {
203 hostspace_parallel_deepcopy(dst, src, n);
206 DeepCopy(
const ExecutionSpace& exec,
void* dst,
const void* src,
size_t n) {
208 "Kokkos::Impl::DeepCopy<HostSpace, HostSpace, "
209 "ExecutionSpace>::DeepCopy: fence before copy");
210 hostspace_parallel_deepcopy_async(dst, src, n);
218 #endif // #define KOKKOS_HOSTSPACE_HPP
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.