Ignore:
Timestamp:
Mar 7, 2016, 3:37:30 PM (3 years ago)
Author:
nmedfort
Message:

Initial modifications to Pablo Compiler and Kernel Builder to support circular buffers for Lookahead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/slab_allocator.h

    r4588 r4959  
    55
    66using LLVMAllocator = llvm::BumpPtrAllocator;
    7 
    8 namespace {
    9 
    10 class __BumpPtrAllocatorProxy {
    11 public:
    12     template <typename T>
    13     static inline T * Allocate(const size_t n) {
    14         return static_cast<T*>(mAllocator.Allocate(n * sizeof(T), sizeof(void*)));
    15     }
    16     template <typename T>
    17     static inline void Deallocate(const T * pointer) {
    18         mAllocator.Deallocate(pointer);
    19     }
    20     static inline void Reset() {
    21         mAllocator.Reset();
    22     }
    23     static LLVMAllocator & get_allocator() {
    24         return mAllocator;
    25     }
    26 private:
    27     static LLVMAllocator mAllocator;
    28 };
    29 
    30 LLVMAllocator __BumpPtrAllocatorProxy::mAllocator;
    31 
    32 }
    337
    348template <typename T>
     
    5024
    5125    inline pointer allocate(size_type n, const_pointer = nullptr) noexcept {
    52         return mAllocator.Allocate<T>(n);
     26        return static_cast<T*>(mAllocator.Allocate(n * sizeof(T), sizeof(void*)));
    5327    }
    5428
    5529    inline void deallocate(pointer p, size_type = 0) noexcept {
    56         mAllocator.Deallocate<T>(p);
     30        mAllocator.Deallocate(p);
    5731    }
    5832
     
    6236
    6337    inline LLVMAllocator & get_allocator() {
    64         return mAllocator.get_allocator();
     38        return mAllocator;
     39    }
     40
     41    void Reset() {
     42        mAllocator.Reset();
    6543    }
    6644
     
    7351    inline ~SlabAllocator() { }
    7452private:
    75     __BumpPtrAllocatorProxy mAllocator;
     53    static LLVMAllocator mAllocator;
    7654};
    7755
     56template <typename T> LLVMAllocator SlabAllocator<T>::mAllocator;
     57
    7858inline void releaseSlabAllocatorMemory() {
    79     __BumpPtrAllocatorProxy::Reset();
     59    SlabAllocator<void *> T;
     60    T.Reset();
    8061}
    8162
Note: See TracChangeset for help on using the changeset viewer.