Class ResourceManager¶
Defined in File ResourceManager.hpp
Class Documentation¶
-
class
ResourceManager
¶ Public Functions
-
void
initialize
()¶ Initialize the ResourceManager.
This will create all registered MemoryResource objects
-
std::vector<std::string>
getAllocatorNames
() const¶ Get the names of all available Allocator objects.
-
Allocator
getAllocator
(resource::MemoryResourceType resource_type)¶ Get the default Allocator for the given resource_type.
-
Allocator
getDefaultAllocator
()¶ Get the default Allocator.
The default Allocator is used whenever an Allocator is required and one is not provided, or cannot be inferred.
- Return
The default Allocator.
-
void
setDefaultAllocator
(Allocator allocator)¶ Set the default Allocator.
The default Allocator is used whenever an Allocator is required and one is not provided, or cannot be inferred.
- Parameters
allocator
: The Allocator to use as the default.
-
template<typename
Strategy
, boolintrospection
= true, typename ...Args
>
AllocatormakeAllocator
(const std::string &name, Args&&... args)¶ Construct a new Allocator.
-
void
registerAllocator
(const std::string &name, Allocator allocator)¶ Register an Allocator with the ResourceManager.
After registration, the Allocator can be retrieved by calling getAllocator(name).
The same Allocator can be registered under multiple names.
-
bool
isAllocator
(const std::string &name)¶
-
bool
hasAllocator
(void *ptr)¶ Does the given pointer have an associated Allocator.
- Return
True if the pointer has an associated Allocator.
-
void
registerAllocation
(void *ptr, util::AllocationRecord record)¶ register an allocation with the manager.
-
util::AllocationRecord
deregisterAllocation
(void *ptr)¶ de-register the address ptr with the manager.
- Return
the allocation record removed from the manager.
-
const util::AllocationRecord *
findAllocationRecord
(void *ptr) const¶ Find the allocation record associated with an address ptr.
- Return
the record if found, or throws an exception if not found.
-
void
copy
(void *dst_ptr, void *src_ptr, std::size_t size = 0)¶ Copy size bytes of data from src_ptr to dst_ptr.
Both the src_ptr and dst_ptr addresses must be allocated by Umpire. They can be offset from any Umpire-managed base address.
The dst_ptr must be large enough to accommodate size bytes of data.
- Parameters
dst_ptr
: Destination pointer.src_ptr
: Source pointer.size
: Size in bytes.
-
void
memset
(void *ptr, int val, std::size_t length = 0)¶ Set the first length bytes of ptr to the value val.
- Parameters
ptr
: Pointer to data.val
: Value to set.length
: Number of bytes to set to val.
-
void *
reallocate
(void *src_ptr, std::size_t size)¶ Reallocate src_ptr to size.
If src_ptr is null, then the default allocator will be used to allocate data.
- Return
Reallocated pointer.
- Parameters
src_ptr
: Source pointer to reallocate.size
: New size of pointer.
-
void *
reallocate
(void *src_ptr, std::size_t size, Allocator allocator)¶ Reallocate src_ptr to size.
If src_ptr is null, then allocator will be used to allocate the data.
- Return
Reallocated pointer.
- Parameters
src_ptr
: Source pointer to reallocate.size
: New size of pointer.allocator
: Allocator to use if src_ptr is null.
-
void *
move
(void *src_ptr, Allocator allocator)¶ Move src_ptr to memory from allocator.
- Return
Pointer to new location of data.
- Parameters
src_ptr
: Pointer to move.allocator
: Allocator to use to allocate new memory for moved data.
-
void
deallocate
(void *ptr)¶ Deallocate any pointer allocated by an Umpire-managed resource.
- Parameters
ptr
: Pointer to deallocate.
-
std::size_t
getSize
(void *ptr) const¶ Get the size in bytes of the allocation for the given pointer.
- Return
Size of allocation in bytes.
- Parameters
ptr
: Pointer to find size of.
-
~ResourceManager
()¶
-
ResourceManager
(const ResourceManager&)¶
-
ResourceManager &
operator=
(const ResourceManager&)¶
Public Static Functions
-
ResourceManager &
getInstance
()¶
-
void