Ignore:
Timestamp:
Feb 4, 2017, 9:43:22 PM (2 years ago)
Author:
cameron
Message:

Circular copy-back buffers: initial check-in

File:
1 edited

Legend:

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

    r5297 r5301  
    2020public:
    2121
    22     enum class BufferKind : unsigned {BlockBuffer, ExternalFileBuffer, CircularBuffer, LinearCopybackBuffer, ExpandableBuffer};
     22    enum class BufferKind : unsigned {BlockBuffer, ExternalFileBuffer, CircularBuffer, CircularCopybackBuffer, ExpandableBuffer};
    2323
    2424    BufferKind getBufferKind() const {
     
    3838    }
    3939
    40     size_t getBufferSize() const {
    41         return mBufferSize;
     40    size_t getBufferBlocks() const {
     41        return mBufferBlocks;
    4242    }
    4343
     
    5454    virtual llvm::Value * getStreamView(llvm::Type * type, llvm::Value * self, llvm::Value * blockNo, llvm::Value * index) const;
    5555
     56    // The number of items that cam be linearly accessed from a given logical stream position.
     57    virtual llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const;
     58   
    5659protected:
    5760
     
    6770    IDISA::IDISA_Builder * const    iBuilder;
    6871    llvm::Type * const              mStreamSetType;
    69     const size_t                    mBufferSize;
     72    const size_t                    mBufferBlocks;
    7073    const unsigned                  mAddressSpace;
    7174    llvm::Value *                   mStreamSetBufferPtr;
     
    100103    void allocateBuffer() override;
    101104
     105    llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
     106   
    102107protected:
    103108    llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     
    109114        return b->getBufferKind() == BufferKind::CircularBuffer;
    110115    }
    111  
     116   
    112117    CircularBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    113118
     
    116121};
    117122   
    118 // Linear buffers extending from the current ConsumerPos forward.   Within the buffer, the
    119 // offset of the block containing the current consumer position is always zero.
     123
    120124//
    121 class LinearCopybackBuffer : public StreamSetBuffer {
     125//  A CircularCopybackBuffer operates as a circular buffer buffer with an overflow area
     126//  for temporary use by the kernel that writes to it.   If the kernel uses the overflow
     127//  area, it must perform the doCopyBack action before releasing the buffer for use by
     128//  subsequent kernels.
     129//  Kernels that read from a CircularCopybackBuffer must not access the overflow area.
     130//
     131class CircularCopybackBuffer : public StreamSetBuffer {
    122132public:
    123     static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::LinearCopybackBuffer;}
     133    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::CircularCopybackBuffer;}
    124134   
    125     LinearCopybackBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
     135    CircularCopybackBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace = 0);
    126136
    127     // Reset the buffer to contain data starting at the base block of new_consumer_pos,
    128     // copying back any data beyond that position.
    129     //void setConsumerPos(llvm::Value * self, llvm::Value * newConsumerPos) const override;
     137    void allocateBuffer() override;
     138   
     139    // Generate copyback code for the given number of overflowItems.
     140    void createCopyBack(llvm::Value * self, llvm::Value * overflowItems);
     141   
     142   
     143protected:
     144    llvm::Value * getStreamSetPtr(llvm::Value * bufferBasePtr, llvm::Value * blockNo) const override;
     145private:
     146    size_t mOverflowBlocks;
    130147
    131 protected:
    132     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    133148};
    134149
     
    148163    llvm::Value * getStreamView(llvm::Type * type, llvm::Value * self, llvm::Value * blockNo, llvm::Value * index) const override;
    149164
     165    llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
     166   
    150167protected:
    151168
Note: See TracChangeset for help on using the changeset viewer.