44 #ifndef KOKKOS_HOSTSPACE_HPP 45 #define KOKKOS_HOSTSPACE_HPP 52 #include <Kokkos_Core_fwd.hpp> 53 #include <Kokkos_Concepts.hpp> 54 #include <Kokkos_MemoryTraits.hpp> 56 #include <impl/Kokkos_Traits.hpp> 57 #include <impl/Kokkos_Error.hpp> 58 #include <impl/Kokkos_SharedAlloc.hpp> 72 void init_lock_array_host_space();
79 bool lock_address_host_space(
void* ptr);
87 void unlock_address_host_space(
void* ptr );
104 typedef size_t size_type;
112 #if defined( KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP ) 113 typedef Kokkos::OpenMP execution_space;
114 #elif defined( KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS ) 115 typedef Kokkos::Threads execution_space;
118 #elif defined( KOKKOS_ENABLE_OPENMP ) 119 typedef Kokkos::OpenMP execution_space;
120 #elif defined( KOKKOS_ENABLE_THREADS ) 121 typedef Kokkos::Threads execution_space;
124 #elif defined( KOKKOS_ENABLE_SERIAL ) 125 typedef Kokkos::Serial execution_space;
127 # error "At least one of the following host execution spaces must be defined: Kokkos::OpenMP, Kokkos::Threads, Kokkos::Qthreads, or Kokkos::Serial. You might be seeing this message if you disabled the Kokkos::Serial device explicitly using the Kokkos_ENABLE_Serial:BOOL=OFF CMake option, but did not enable any of the other host execution space devices." 135 static int in_parallel();
137 static void register_in_parallel(
int (*)() );
157 void * allocate(
const size_t arg_alloc_size )
const;
160 void deallocate(
void *
const arg_alloc_ptr
161 ,
const size_t arg_alloc_size )
const;
164 static constexpr
const char* name();
168 static constexpr
const char* m_name =
"Host";
169 friend class Kokkos::Impl::SharedAllocationRecord< Kokkos::
HostSpace, void >;
182 template<
typename S >
197 typedef typename std::conditional
198 < keep_exe && keep_mem
200 ,
typename std::conditional
203 ,
typename S::memory_space >
220 class SharedAllocationRecord< Kokkos::
HostSpace, void >
221 :
public SharedAllocationRecord< void, void >
226 typedef SharedAllocationRecord< void, void > RecordBase;
228 SharedAllocationRecord(
const SharedAllocationRecord & ) =
delete;
229 SharedAllocationRecord & operator = (
const SharedAllocationRecord & ) =
delete;
231 static void deallocate( RecordBase * );
234 static RecordBase s_root_record;
239 ~SharedAllocationRecord();
240 SharedAllocationRecord() =
default;
243 ,
const std::string & arg_label
244 ,
const size_t arg_alloc_size
245 ,
const RecordBase::function_type arg_dealloc = & deallocate
251 std::string get_label()
const 253 return std::string( RecordBase::head()->m_label );
256 KOKKOS_INLINE_FUNCTION
static 258 ,
const std::string & arg_label
259 ,
const size_t arg_alloc_size
262 #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST ) 263 return new SharedAllocationRecord( arg_space, arg_label, arg_alloc_size );
265 return (SharedAllocationRecord *) 0;
273 ,
const std::string & arg_label
274 ,
const size_t arg_alloc_size );
278 void * reallocate_tracked(
void *
const arg_alloc_ptr
279 ,
const size_t arg_alloc_size );
283 void deallocate_tracked(
void *
const arg_alloc_ptr );
285 static SharedAllocationRecord * get_record(
void * arg_alloc_ptr );
287 static void print_records( std::ostream &,
const Kokkos::HostSpace &,
bool detail =
false );
300 template<
class DstSpace,
class SrcSpace,
class ExecutionSpace =
typename DstSpace::execution_space >
struct DeepCopy;
302 template<
class ExecutionSpace >
303 struct DeepCopy< HostSpace, HostSpace, ExecutionSpace > {
304 DeepCopy(
void * dst,
const void * src,
size_t n ) {
305 memcpy( dst, src, n );
308 DeepCopy(
const ExecutionSpace& exec,
void * dst,
const void * src,
size_t n ) {
310 memcpy( dst, src, n );
318 #endif // #define KOKKOS_HOSTSPACE_HPP Kokkos::Device< execution_space, memory_space > device_type
This memory space preferred device_type.
AllocationMechanism
Non-default memory space instance to choose allocation mechansim, if available.
Memory space for main process and CPU execution spaces.
Memory management for host memory.
HostSpace memory_space
Tag this class as a kokkos memory space.
Access relationship between DstMemorySpace and SrcMemorySpace.