ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
An abstract base class for memory allocators. More...
#include <allocator.h>
Public Member Functions | |
virtual void * | allocate (size_t size)=0 |
Allocate a block of memory with the given size and default alignment. | |
virtual void * | allocate (size_t size, size_t alignment)=0 |
Allocate a block of memory with the given size and alignment. | |
virtual void | free (void *ptr)=0 |
Free a block of memory that was previously allocated by this allocator. | |
virtual size_t | AllocatedSize (void *ptr) |
Get the allocated size of a given pointer. | |
virtual container::DeviceType | GetDeviceType ()=0 |
Get the type of memory used by the TensorBuffer. | |
virtual | ~Allocator ()=default |
Protected Attributes | |
size_t | allocated_size_ = 0 |
The total number of bytes allocated by this allocator. | |
An abstract base class for memory allocators.
This class defines an interface for memory allocators. Subclasses of this class can provide different implementations of memory allocation/deallocation strategies.
All memory allocated by an Allocator must be freed using the same allocator that allocated it.
|
virtualdefault |
|
pure virtual |
Allocate a block of memory with the given size and default alignment.
size | The size of the memory block to allocate. |
Implemented in base::core::BFCAllocator, base::core::CPUAllocator, and base::core::GPUAllocator.
|
pure virtual |
Allocate a block of memory with the given size and alignment.
size | The size of the memory block to allocate. |
alignment | The alignment of the memory block to allocate. |
Implemented in base::core::BFCAllocator, base::core::CPUAllocator, and base::core::GPUAllocator.
|
inlinevirtual |
Get the allocated size of a given pointer.
ptr | The pointer to get the allocated size of. |
|
pure virtual |
Free a block of memory that was previously allocated by this allocator.
ptr | A pointer to the memory block to free. |
Implemented in base::core::BFCAllocator, base::core::CPUAllocator, and base::core::GPUAllocator.
|
pure virtual |
Get the type of memory used by the TensorBuffer.
Implemented in base::core::BFCAllocator, base::core::CPUAllocator, and base::core::GPUAllocator.
|
protected |
The total number of bytes allocated by this allocator.