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." 131 typedef Kokkos::Device< execution_space, memory_space >
device_type;
149 void *
allocate(
const size_t arg_alloc_size )
const;
153 ,
const size_t arg_alloc_size )
const;
156 static constexpr
const char*
name() {
return m_name; }
160 static constexpr
const char* m_name =
"Host";
161 friend class Kokkos::Impl::SharedAllocationRecord<
Kokkos::
HostSpace, void >;
174 template<
typename S >
189 typedef typename std::conditional
190 < keep_exe && keep_mem
192 ,
typename std::conditional
194 , Kokkos::Device< Kokkos::HostSpace::execution_space
195 ,
typename S::memory_space >
213 :
public SharedAllocationRecord< void, void >
218 typedef SharedAllocationRecord< void, void > RecordBase;
220 SharedAllocationRecord(
const SharedAllocationRecord & ) =
delete;
221 SharedAllocationRecord & operator = (
const SharedAllocationRecord & ) =
delete;
227 static RecordBase s_root_record;
233 ~SharedAllocationRecord();
234 SharedAllocationRecord() =
default;
237 ,
const std::string & arg_label
238 ,
const size_t arg_alloc_size
239 ,
const RecordBase::function_type arg_dealloc = &
deallocate 245 std::string get_label()
const 247 return std::string( RecordBase::head()->m_label );
250 KOKKOS_INLINE_FUNCTION
static 252 ,
const std::string & arg_label
253 ,
const size_t arg_alloc_size
256 #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST ) 257 return new SharedAllocationRecord( arg_space, arg_label, arg_alloc_size );
259 return (SharedAllocationRecord *) 0;
267 ,
const std::string & arg_label
268 ,
const size_t arg_alloc_size );
272 void * reallocate_tracked(
void *
const arg_alloc_ptr
273 ,
const size_t arg_alloc_size );
277 void deallocate_tracked(
void *
const arg_alloc_ptr );
279 static SharedAllocationRecord * get_record(
void * arg_alloc_ptr );
281 static void print_records( std::ostream &,
const Kokkos::HostSpace &,
bool detail =
false );
294 template<
class ExecutionSpace >
296 DeepCopy(
void * dst,
const void * src,
size_t n ) {
297 memcpy( dst, src, n );
300 DeepCopy(
const ExecutionSpace& exec,
void * dst,
const void * src,
size_t n ) {
302 memcpy( dst, src, n );
310 #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.
void * allocate(const size_t arg_alloc_size) const
Allocate untracked memory in the space.
Memory management for host memory.
static constexpr const char * name()
Return Name of the MemorySpace.
HostSpace()
Default memory space instance.
HostSpace memory_space
Tag this class as a kokkos memory space.
void deallocate(void *const arg_alloc_ptr, const size_t arg_alloc_size) const
Deallocate untracked memory in the space.
Access relationship between DstMemorySpace and SrcMemorySpace.