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>
60 #include "impl/Kokkos_HostSpace_deepcopy.hpp"
74 void init_lock_array_host_space();
81 bool lock_address_host_space(
void* ptr);
89 void unlock_address_host_space(
void* ptr );
106 typedef size_t size_type;
114 #if defined( KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP )
115 typedef Kokkos::OpenMP execution_space;
116 #elif defined( KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS )
117 typedef Kokkos::Threads execution_space;
120 #elif defined( KOKKOS_ENABLE_OPENMP )
121 typedef Kokkos::OpenMP execution_space;
122 #elif defined( KOKKOS_ENABLE_THREADS )
123 typedef Kokkos::Threads execution_space;
126 #elif defined( KOKKOS_ENABLE_SERIAL )
127 typedef Kokkos::Serial execution_space;
129 # 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."
133 typedef Kokkos::Device< execution_space, memory_space >
device_type;
151 void *
allocate(
const size_t arg_alloc_size )
const;
155 ,
const size_t arg_alloc_size )
const;
158 static constexpr
const char*
name() {
return m_name; }
162 static constexpr
const char* m_name =
"Host";
163 friend class Kokkos::Impl::SharedAllocationRecord< Kokkos::
HostSpace, void >;
176 template<
typename S >
191 typedef typename std::conditional
192 < keep_exe && keep_mem
194 ,
typename std::conditional
196 , Kokkos::Device< Kokkos::HostSpace::execution_space
197 ,
typename S::memory_space >
214 class SharedAllocationRecord< Kokkos::
HostSpace, void >
215 :
public SharedAllocationRecord< void, void >
220 typedef SharedAllocationRecord< void, void > RecordBase;
222 SharedAllocationRecord(
const SharedAllocationRecord & ) =
delete;
223 SharedAllocationRecord & operator = (
const SharedAllocationRecord & ) =
delete;
229 static RecordBase s_root_record;
235 ~SharedAllocationRecord();
236 SharedAllocationRecord() =
default;
239 ,
const std::string & arg_label
240 ,
const size_t arg_alloc_size
241 ,
const RecordBase::function_type arg_dealloc = &
deallocate
247 std::string get_label()
const
249 return std::string( RecordBase::head()->m_label );
252 KOKKOS_INLINE_FUNCTION
static
254 ,
const std::string & arg_label
255 ,
const size_t arg_alloc_size
258 #if defined( KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST )
259 return new SharedAllocationRecord( arg_space, arg_label, arg_alloc_size );
261 return (SharedAllocationRecord *) 0;
269 ,
const std::string & arg_label
270 ,
const size_t arg_alloc_size );
274 void * reallocate_tracked(
void *
const arg_alloc_ptr
275 ,
const size_t arg_alloc_size );
279 void deallocate_tracked(
void *
const arg_alloc_ptr );
281 static SharedAllocationRecord * get_record(
void * arg_alloc_ptr );
283 static void print_records( std::ostream &,
const Kokkos::HostSpace &,
bool detail =
false );
296 #define PAR_DEEP_COPY_USE_MEMCPY
298 template<
class ExecutionSpace >
300 DeepCopy(
void * dst,
const void * src,
size_t n ) {
301 hostspace_parallel_deepcopy(dst,src,n);
304 DeepCopy(
const ExecutionSpace& exec,
void * dst,
const void * src,
size_t n ) {
306 hostspace_parallel_deepcopy(dst,src,n);
314 #endif // #define KOKKOS_HOSTSPACE_HPP
void * allocate(const size_t arg_alloc_size) const
Allocate untracked memory in the space.
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 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.
HostSpace()
Default memory space instance.
HostSpace memory_space
Tag this class as a kokkos memory space.
Access relationship between DstMemorySpace and SrcMemorySpace.