1#ifndef FREE_TENSOR_ALLOCATOR_H
2#define FREE_TENSOR_ALLOCATOR_H
38 std::vector<SmallItemBlock *> blocks_;
39 std::atomic_flag spinLock_ = ATOMIC_FLAG_INIT;
59 if (instance_ ==
nullptr) {
80 return (T *)malloc(
n *
sizeof(T));
82 return (T *)smallItemAllocator_->
allocate();
94 template <
class... Args>
void construct(T *p, Args &&...args) {
95 ::new ((
void *)p) T(std::forward<Args>(args)...);
Definition: allocator.h:66
Allocator(Allocator< U > &&other)
Definition: allocator.h:76
T * allocate(size_t n)
Definition: allocator.h:78
T value_type
Definition: allocator.h:70
Allocator()
Definition: allocator.h:73
Allocator(const Allocator< U > &other)
Definition: allocator.h:75
void construct(T *p, Args &&...args)
Definition: allocator.h:94
void deallocate(T *p, size_t n)
Definition: allocator.h:86
std::true_type is_always_equal
Definition: allocator.h:71
Definition: allocator.h:36
void * allocate()
Definition: allocator.cc:53
SmallItemAllocator()
Definition: allocator.cc:34
static SmallItemAllocator * instance()
Definition: allocator.h:58
~SmallItemAllocator()
Definition: allocator.cc:37
void deallocate(void *p)
Definition: allocator.cc:71
Definition: allocator.h:19
static void delBlk(SmallItemBlock *blk)
Definition: allocator.cc:30
static SmallItemBlock * newBlk()
Definition: allocator.cc:20
SmallItem * allocate()
Definition: allocator.cc:9
void deallocate(SmallItem *item)
Definition: allocator.cc:15
bool full() const
Definition: allocator.cc:7
Definition: allocator.h:9
constexpr int SMALL_ITEM_PER_BLOCK
Definition: allocator.h:12
auto && lhs
Definition: const_fold.cc:70
constexpr int SMALL_ITEM_SIZE
Definition: allocator.h:11
bool operator==(const Allocator< T > &lhs, const Allocator< T > &rhs)
Definition: allocator.h:100
auto auto && rhs
Definition: const_fold.cc:70
Definition: allocator.h:14
uint8_t data_[SMALL_ITEM_SIZE]
Definition: allocator.h:16
SmallItem * next_
Definition: allocator.h:15