1#ifndef BASE_CORE_BFC_ALLOCATOR_H_
2#define BASE_CORE_BFC_ALLOCATOR_H_
42 void*
allocate(
size_t size,
size_t alignment)
override;
49 void free(
void* ptr)
override;
An abstract base class for memory allocators.
Definition allocator.h:17
Definition bfc_allocator.h:110
chunk_comparator(BFCAllocator *allocator)
Definition bfc_allocator.h:112
BFCAllocator * allocator_
Definition bfc_allocator.h:125
bool operator()(const chunk_handle_t ha, const chunk_handle_t hb) const
Definition bfc_allocator.h:114
An allocator that allocates memory on a GPU device.
Definition bfc_allocator.h:14
void * allocate(size_t size) override
Allocate a block of memory with the given size and default alignment on GPU.
std::unique_ptr< Allocator > sub_alloc_
Definition bfc_allocator.h:61
int bin_index_t
Definition bfc_allocator.h:71
void * allocate(size_t size, size_t alignment) override
Allocate a block of memory with the given size and alignment on GPU.
static constexpr chunk_handle_t kInvalidChunkHandle
Definition bfc_allocator.h:69
std::mutex mtx_
Definition bfc_allocator.h:64
void free(void *ptr) override
Free a block of GPU memory that was previously allocated by this allocator.
static constexpr int kInvalidBinNum
Definition bfc_allocator.h:72
static constexpr int kNumBins
Definition bfc_allocator.h:74
BFCAllocator(std::unique_ptr< Allocator > sub_alloc, const size_t &total_memory, const Options &options=Options())
size_t chunk_handle_t
Definition bfc_allocator.h:68
DeviceType GetDeviceType() override
Get the type of memory used by the TensorBuffer.
Definition bfc_allocator.h:17
double fragment_fraction
Definition bfc_allocator.h:19
bool allow_growth
Definition bfc_allocator.h:18
Definition bfc_allocator.h:100
std::set< ChunkHandle, ChunkComparator > free_chunk_set_t
Definition bfc_allocator.h:128
chunk_handle_t last_chunk_handle
Definition bfc_allocator.h:108
size_t bin_size
Definition bfc_allocator.h:102
chunk_handle_t first_chunk_handle
Definition bfc_allocator.h:106
size_t num_chunks
Definition bfc_allocator.h:104
Definition bfc_allocator.h:76
void * ptr
Definition bfc_allocator.h:92
size_t size
Definition bfc_allocator.h:78
bin_index_t bin_index
Definition bfc_allocator.h:80
size_t requested_size
Definition bfc_allocator.h:85
int64_t allocation_id
Definition bfc_allocator.h:90
bool allocated() const
Definition bfc_allocator.h:97
chunk_handle_t prev_chunk_handle
Definition bfc_allocator.h:95
chunk_handle_t next_chunk_handle
Definition bfc_allocator.h:93