Class ResourceManager

Class Documentation

class ResourceManager

Public Functions

void initialize()

Initialize the ResourceManager.

This will create all registered MemoryResource objects

void finalize()
std::vector<std::string> getAvailableAllocators()

Get the names of all available Allocator objects.

Allocator getAllocator(const std::string &name)

Get the Allocator with the given name.

Allocator getAllocator(resource::MemoryResourceType resource_type)

Get the default Allocator for the given resource_type.

Allocator getAllocator(int id)

Get the Allocator with the given ID.

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, bool introspection = true, typename... Args>
Allocator makeAllocator(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.

Parameters

Allocator getAllocator(void *ptr)

Get the Allocator used to allocate ptr.

Return
Allocator for the given ptr.
Parameters

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)
util::AllocationRecord *deregisterAllocation(void *ptr)
bool isAllocatorRegistered(const std::string &name)

Check whether the named Allocator exists.

void copy(void *dst_ptr, void *src_ptr, 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, 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, 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, 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.

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.

void coalesce(Allocator allocator)

If allocator is some kind of memory pool, try and coalesce memory.

Parameters
Exceptions

Public Static Functions

ResourceManager &getInstance()