Class MemoryResource¶
Defined in File MemoryResource.hpp
Inheritance Relationships¶
Base Type¶
public umpire::strategy::AllocationStrategy
(Class AllocationStrategy)
Derived Types¶
public umpire::resource::CudaConstantMemoryResource
(Class CudaConstantMemoryResource)public umpire::resource::CudaDeviceMemoryResource
(Class CudaDeviceMemoryResource)public umpire::resource::DefaultMemoryResource< _allocator >
(Template Class DefaultMemoryResource)public umpire::resource::HipConstantMemoryResource
(Class HipConstantMemoryResource)public umpire::resource::NullMemoryResource
(Class NullMemoryResource)
Class Documentation¶
-
class
umpire::resource
::
MemoryResource
: public umpire::strategy::AllocationStrategy¶ Base class to represent the available hardware resources for memory allocation in the system.
Objects of this inherit from strategy::AllocationStrategy, allowing them to be used directly.
Subclassed by umpire::resource::CudaConstantMemoryResource, umpire::resource::CudaDeviceMemoryResource, umpire::resource::DefaultMemoryResource< _allocator >, umpire::resource::HipConstantMemoryResource, umpire::resource::NullMemoryResource
Public Functions
-
MemoryResource
(const std::string &name, int id, MemoryResourceTraits traits)¶ Construct a MemoryResource with the given name and id.
- Parameters
name
: Name of the MemoryResource.id
: ID of the MemoryResource (must be unique).
-
~MemoryResource
() = default¶
-
void *
allocate
(std::size_t bytes) override = 0¶ Allocate bytes of memory.
This function is pure virtual and must be implemented by the inheriting class.
- Return
Pointer to start of allocation.
- Parameters
bytes
: Number of bytes to allocate.
-
void
deallocate
(void *ptr) override = 0¶ Free the memory at ptr.
This function is pure virtual and must be implemented by the inheriting class.
- Parameters
ptr
: Pointer to free.
-
std::size_t
getCurrentSize
() const noexcept override = 0¶ Return the current size of this MemoryResource.
This is sum of the sizes of all the tracked allocations. Note that this doesn’t ever have to be equal to getHighWatermark.
- Return
current total size of active allocations in this MemoryResource.
-
std::size_t
getHighWatermark
() const noexcept override = 0¶ Return the memory high watermark for this MemoryResource.
This is the largest amount of memory allocated by this Allocator. Note that this may be larger than the largest value returned by getCurrentSize.
- Return
Memory high watermark.
-
Platform
getPlatform
() noexcept override = 0¶ Get the Platform assocatiated with this MemoryResource.
This function is pure virtual and must be implemented by the inheriting class.
- Return
Platform associated with this MemoryResource.
-
MemoryResourceTraits
getTraits
() const noexcept override¶
-
void
release
()¶ Release any and all unused memory held by this AllocationStrategy.
-
std::size_t
getActualSize
() const noexcept¶ Get the current amount of memory allocated by this allocator.
Note that this can be larger than getCurrentSize(), particularly if the AllocationStrategy implements some kind of pooling.
- Return
The total size of all the memory this object has allocated.
-
std::size_t
getAllocationCount
() const noexcept¶ Get the total number of active allocations by this allocator.
- Return
The total number of active allocations this object has allocated.
-
const std::string &
getName
() noexcept¶ Get the name of this AllocationStrategy.
- Return
The name of this AllocationStrategy.
-
int
getId
() noexcept¶ Get the id of this AllocationStrategy.
- Return
The id of this AllocationStrategy.
-