LLVM 20.0.0git
|
PerThreadAllocator is used in conjunction with ThreadPoolExecutor to allow per-thread allocations. More...
#include "llvm/Support/PerThreadBumpPtrAllocator.h"
Public Member Functions | |
PerThreadAllocator () | |
void * | Allocate (size_t Size, size_t Alignment) |
Allocate Size bytes of Alignment aligned memory. | |
void | Deallocate (const void *Ptr, size_t Size, size_t Alignment) |
Deallocate Ptr to Size bytes of memory allocated by this allocator. | |
AllocatorTy & | getThreadLocalAllocator () |
Return allocator corresponding to the current thread. | |
size_t | getNumberOfAllocators () const |
void | Reset () |
Reset state of allocators. | |
size_t | getTotalMemory () const |
Return total memory size used by all allocators. | |
size_t | getBytesAllocated () const |
Return allocated size by all allocators. | |
void | setRedZoneSize (size_t NewSize) |
Set red zone for all allocators. | |
void | PrintStats () const |
Print statistic for each allocator. | |
Public Member Functions inherited from llvm::AllocatorBase< PerThreadAllocator< AllocatorTy > > | |
void * | Allocate (size_t Size, size_t Alignment) |
Allocate Size bytes of Alignment aligned memory. | |
T * | Allocate (size_t Num=1) |
Allocate space for a sequence of objects without constructing them. | |
void | Deallocate (const void *Ptr, size_t Size, size_t Alignment) |
Deallocate Ptr to Size bytes of memory allocated by this allocator. | |
std::enable_if_t<!std::is_same_v< std::remove_cv_t< T >, void >, void > | Deallocate (T *Ptr, size_t Num=1) |
Deallocate space for a sequence of objects without constructing them. | |
Protected Attributes | |
size_t | NumOfAllocators |
std::unique_ptr< AllocatorTy[]> | Allocators |
PerThreadAllocator is used in conjunction with ThreadPoolExecutor to allow per-thread allocations.
It wraps a possibly thread-unsafe allocator, e.g. BumpPtrAllocator. PerThreadAllocator must be used with only main thread or threads created by ThreadPoolExecutor, as it utilizes getThreadIndex, which is set by ThreadPoolExecutor. To work properly, ThreadPoolExecutor should be initialized before PerThreadAllocator is created. TODO: The same approach might be implemented for ThreadPool.
Definition at line 27 of file PerThreadBumpPtrAllocator.h.
|
inline |
Definition at line 30 of file PerThreadBumpPtrAllocator.h.
|
protected |
Definition at line 112 of file PerThreadBumpPtrAllocator.h.
Referenced by llvm::parallel::PerThreadAllocator< AllocatorTy >::Allocate(), llvm::parallel::PerThreadAllocator< AllocatorTy >::Deallocate(), llvm::parallel::PerThreadAllocator< AllocatorTy >::getBytesAllocated(), llvm::parallel::PerThreadAllocator< AllocatorTy >::getThreadLocalAllocator(), llvm::parallel::PerThreadAllocator< AllocatorTy >::getTotalMemory(), llvm::parallel::PerThreadAllocator< AllocatorTy >::PrintStats(), llvm::parallel::PerThreadAllocator< AllocatorTy >::Reset(), and llvm::parallel::PerThreadAllocator< AllocatorTy >::setRedZoneSize().
|
protected |
Definition at line 111 of file PerThreadBumpPtrAllocator.h.
Referenced by llvm::parallel::PerThreadAllocator< AllocatorTy >::Allocate(), llvm::parallel::PerThreadAllocator< AllocatorTy >::Deallocate(), llvm::parallel::PerThreadAllocator< AllocatorTy >::getNumberOfAllocators(), and llvm::parallel::PerThreadAllocator< AllocatorTy >::getThreadLocalAllocator().