Ignore:
Timestamp:
Apr 28, 2018, 3:54:43 PM (12 months ago)
Author:
nmedfort
Message:

Added temporary buffer functionality to the pipeline for single stream source buffers. Fixed memory leak from UCD::UnicodeBreakRE()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5985 r5998  
    7878        return mStreamSetBufferPtr;
    7979    }
    80    
     80
     81    bool supportsCopyBack() const {
     82        return mOverflowBlocks != 0;
     83    }
     84
     85    virtual bool isUnbounded() const {
     86        return false;
     87    }
     88
     89    size_t overflowSize() const {
     90        return mOverflowBlocks;
     91    }
     92
     93    virtual ~StreamSetBuffer() = 0;
     94
     95    kernel::Kernel * getProducer() const {
     96        return mProducer;
     97    }
     98
     99    const std::vector<kernel::Kernel *> & getConsumers() const {
     100        return mConsumers;
     101    }
     102
     103    virtual void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb);
     104
     105    virtual void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const;
     106
     107    llvm::PointerType * getStreamSetPointerType() const {
     108        return getStreamSetBlockType()->getPointerTo(mAddressSpace);
     109    }
     110
     111protected:
     112
    81113    virtual llvm::Type * getStreamSetBlockType() const;
    82    
    83     virtual void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb);
    84 
    85     virtual void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const;
    86114
    87115    virtual llvm::Value * getStreamBlockPtr(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * streamIndex, llvm::Value * blockIndex, const bool readOnly) const;
     
    93121    virtual llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * absolutePosition) const;
    94122
    95     virtual void setBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * addr, llvm::Value *) const;
    96 
    97     virtual void setBufferedSize(IDISA::IDISA_Builder * const b, llvm::Value * size, llvm::Value *) const;
     123    virtual void setBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * addr) const;
     124
     125    virtual void setBufferedSize(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * size) const;
    98126   
    99127    virtual llvm::Value * getBufferedSize(IDISA::IDISA_Builder * const b, llvm::Value * handle) const;
     
    111139   
    112140    virtual void doubleCapacity(IDISA::IDISA_Builder * const b, llvm::Value * handle) const;
    113 
    114     bool supportsCopyBack() const {
    115         return mOverflowBlocks != 0;
    116     }
    117 
    118     virtual bool isUnbounded() const {
    119         return false;
    120     }
    121 
    122     size_t overflowSize() const {
    123         return mOverflowBlocks;
    124     }
    125    
    126     virtual ~StreamSetBuffer() = 0;
    127 
    128     kernel::Kernel * getProducer() const {
    129         return mProducer;
    130     }
    131 
    132     const std::vector<kernel::Kernel *> & getConsumers() const {
    133         return mConsumers;
    134     }
    135 
    136 protected:
    137141
    138142    StreamSetBuffer(BufferKind k, llvm::Type * baseType, llvm::Type * resolvedType, unsigned BufferBlocks, unsigned OverflowBlocks, unsigned AddressSpace);
     
    170174
    171175class SourceBuffer final : public StreamSetBuffer {
     176    friend class kernel::KernelBuilder;
    172177public:
    173178    static inline bool classof(const StreamSetBuffer * b) {
     
    181186    }
    182187
     188protected:
     189
    183190    void setBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * addr) const override;
    184191
     
    201208    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
    202209
    203 protected:
    204    
    205210    enum Field {BaseAddress, BufferedSize, Capacity};
    206211
     
    210215
    211216class ExternalBuffer final : public StreamSetBuffer {
     217    friend class kernel::KernelBuilder;
    212218public:
    213219    static inline bool classof(const StreamSetBuffer * b) {
     
    221227    }
    222228
     229    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
     230
     231    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
     232
     233protected:
     234
    223235    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, llvm::Value * avail, bool reverse = false) const override;
    224236   
    225237    llvm::Value * getLinearlyWritableItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, llvm::Value * consumed, bool reverse = false) const override;
    226238
    227     void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
    228 
    229     void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
    230 
    231239    llvm::Value * getBufferedSize(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
    232240
     
    235243
    236244class CircularBuffer : public StreamSetBuffer {
     245    friend class kernel::KernelBuilder;
    237246public:
    238247    static inline bool classof(const StreamSetBuffer * b) {
     
    242251    CircularBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    243252
     253protected:
     254
    244255    llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * absolutePosition) const final;
    245 
    246 protected:
    247256
    248257    CircularBuffer(const BufferKind kind, const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace);
     
    259268//
    260269class CircularCopybackBuffer final : public CircularBuffer {
     270    friend class kernel::KernelBuilder;
    261271public:
    262272    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::CircularCopybackBuffer;}
     
    270280//
    271281class ExpandableBuffer final : public StreamSetBuffer {
     282    friend class kernel::KernelBuilder;
    272283public:
    273284    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::ExpandableBuffer;}
     
    275286    ExpandableBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    276287
     288    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
     289
     290    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
     291
     292protected:
     293
    277294    llvm::Value * getStreamBlockPtr(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * streamIndex, llvm::Value * blockIndex, const bool readOnly) const override;
    278295
     
    282299   
    283300    llvm::Value * getStreamSetCount(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
    284 
    285     void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
    286 
    287     void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
    288 
    289 protected:
    290301
    291302    llvm::Value * getBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
     
    303314// Dynamically allocated circular buffers: TODO: add copyback, swizzle support, dynamic allocation, producer, consumer, length
    304315class DynamicBuffer final : public StreamSetBuffer {
     316
     317    friend class kernel::KernelBuilder;
     318
    305319    /* Dynamic data fields stored in the buffer struct */
    306320    enum Field {BaseAddress, PriorBaseAddress, AllocatedCapacity, WorkingBlocks, Length, ProducedPosition, ConsumedPosition, FieldCount};
     
    321335   
    322336    DynamicBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t initialCapacity, size_t overflowBlocks = 0, unsigned swizzleFactor = 1, unsigned addrSpace = 0);
    323    
     337
     338    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
     339
     340    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) const override;
     341   
     342protected:
     343
    324344    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, llvm::Value * avail, bool reverse = false) const override;
    325345   
    326346    llvm::Value * getLinearlyWritableItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, llvm::Value * consumed, bool reverse = false) const override;
    327    
    328     void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
    329 
    330     void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) const override;
    331347
    332348    llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * absolutePosition) const override;
     
    336352    void doubleCapacity(IDISA::IDISA_Builder * const b, llvm::Value * handle)  const final;
    337353
    338 protected:
    339354    llvm::Value * getBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
    340355   
Note: See TracChangeset for help on using the changeset viewer.