Ignore:
Timestamp:
Jul 1, 2017, 2:08:30 PM (23 months ago)
Author:
cameron
Message:

Dynamic Buffers - initial check-in

File:
1 edited

Legend:

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

    r5506 r5541  
    2727        , SwizzledCopybackBuffer
    2828        , ExpandableBuffer
     29        , DynamicBuffer
    2930    };
    3031
     
    296297
    297298};
     299   
     300// Dynamically allocated circular buffers: TODO: add copyback, swizzle support, dynamic allocation, producer, consumer, length
     301class DynamicBuffer: public StreamSetBuffer {
     302public:
     303    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::DynamicBuffer;}
     304   
     305    DynamicBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t initialCapacity, size_t overflowBlocks = 0, unsigned swizzleFactor = 1, unsigned addrSpace = 0);
     306   
     307    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition) const override;
     308   
     309    llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock) const override;
     310
     311    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
     312
     313    void releaseBuffer(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
     314
     315    llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * streamIndex, llvm::Value * absolutePosition) const override;
     316
     317    llvm::Type * getStreamSetBlockType() const override;
     318   
     319protected:
     320    llvm::Value * getBaseAddress(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
     321   
     322    llvm::Value * getStreamSetBlockPtr(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * blockIndex) const override;
     323   
     324private:
     325    /* Static data */
     326    unsigned   mSwizzleFactor;     /* Number of streams swizzled together per block.  Must be a small power of 2. Default: 1. */
     327    size_t     mOverflowBlocks;    /* Number of data blocks of additional space at the end of the buffer for writing only. */
     328   
     329    /* Dynamic data fields stored in the buffer struct */
     330   
     331    enum class Field {BaseAddress, AllocatedCapacity, WorkingBlocks, Length, ProducedPosition, ConsumedPosition, FieldCount};
     332   
     333    /* BaseAddress - the physical base address of the memory area for stream set data.
     334     WorkingBlocks - the physical size of the buffer for use in reading and writing data.
     335     AllocatedCapacity - physical size available for expansion in place
     336     Length - actual final length of stream set or -1 for unknown
     337     ProducedPosition - the total number of items ever generated and stored in the buffer
     338     ConsumedPosition - the number of buffer items that are known to have been fully processed by all users
     339     */
     340   
     341};
     342
    298343
    299344}
Note: See TracChangeset for help on using the changeset viewer.