Ignore:
Timestamp:
Mar 29, 2017, 2:29:52 PM (2 years ago)
Author:
nmedfort
Message:

Support for stdin. Needs more testing.

File:
1 edited

Legend:

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

    r5355 r5377  
    1919public:
    2020
    21     enum class BufferKind : unsigned {BlockBuffer, ExternalFileBuffer, CircularBuffer, CircularCopybackBuffer, SwizzledCopybackBuffer, ExpandableBuffer};
     21    enum class BufferKind : unsigned {BlockBuffer, ExternalFileBuffer, CircularBuffer, CircularCopybackBuffer, SwizzledCopybackBuffer, ExpandableBuffer, ExtensibleBuffer};
    2222
    2323    BufferKind getBufferKind() const {
     
    4444        return mStreamSetBufferPtr;
    4545    }
    46    
     46
    4747    virtual void allocateBuffer();
    4848
     
    5656
    5757    // The number of items that cam be linearly accessed from a given logical stream position.
    58     virtual llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const;
    59     virtual llvm::Value * getLinearlyAccessibleBlocks(llvm::Value * fromBlock) const;
     58    virtual llvm::Value * getLinearlyAccessibleItems(llvm::Value * self, llvm::Value * fromPosition) const;
     59    virtual llvm::Value * getLinearlyAccessibleBlocks(llvm::Value * self, llvm::Value * fromBlock) const;
     60
     61    virtual llvm::Value * reserveItemCount(llvm::Value * self, llvm::Value * position, llvm::Value * requested) const;
     62
     63    virtual ~StreamSetBuffer() = 0;
     64
    6065protected:
    6166
     
    6873
    6974    llvm::Value * modByBufferBlocks(llvm::Value * const offset) const;
     75
     76    virtual llvm::Value * getBaseAddress(llvm::Value * self) const;
    7077
    7178protected:
     
    7986};   
    8087
    81 class SingleBlockBuffer : public StreamSetBuffer {
     88class SingleBlockBuffer final : public StreamSetBuffer {
    8289public:
    8390    static inline bool classof(const StreamSetBuffer * b) {
     
    9198};
    9299
    93 class ExternalFileBuffer : public StreamSetBuffer {
     100class ExternalFileBuffer final : public StreamSetBuffer {
    94101public:
    95102    static inline bool classof(const StreamSetBuffer * b) {
     
    99106    ExternalFileBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace = 0);
    100107
    101     void setStreamSetBuffer(llvm::Value * ptr, llvm::Value * fileSize);
    102 
    103     void setEmptyBuffer(llvm::Value * buffer_ptr);
     108    void setStreamSetBuffer(llvm::Value * ptr);
    104109
    105110    // Can't allocate - raise an error. */
    106111    void allocateBuffer() override;
    107112
    108     llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
     113    llvm::Value * getLinearlyAccessibleItems(llvm::Value * self, llvm::Value * fromPosition) const override;
    109114   
    110115protected:
    111116    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    112117};
    113    
    114 class CircularBuffer : public StreamSetBuffer {
     118
     119class ExtensibleBuffer final : public StreamSetBuffer {
     120public:
     121    static inline bool classof(const StreamSetBuffer * b) {
     122        return b->getBufferKind() == BufferKind::ExtensibleBuffer;
     123    }
     124
     125    ExtensibleBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
     126
     127    llvm::Value * getLinearlyAccessibleItems(llvm::Value * self,llvm::Value * fromPosition) const override;
     128
     129    void allocateBuffer() override;
     130
     131    llvm::Value * reserveItemCount(llvm::Value * self, llvm::Value * position, llvm::Value * requested) const override;
     132
     133protected:
     134
     135    llvm::Value * getBaseAddress(llvm::Value * self) const override;
     136
     137    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     138
     139};
     140   
     141class CircularBuffer final : public StreamSetBuffer {
    115142public:
    116143    static inline bool classof(const StreamSetBuffer * b) {
     
    132159//  Kernels that read from a CircularCopybackBuffer must not access the overflow area.
    133160//
    134 class CircularCopybackBuffer : public StreamSetBuffer {
     161class CircularCopybackBuffer final : public StreamSetBuffer {
    135162public:
    136163    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::CircularCopybackBuffer;}
     
    142169    // Generate copyback code for the given number of overflowItems.
    143170    void createCopyBack(llvm::Value * self, llvm::Value * overflowItems) const;
    144    
    145 
    146171       
    147        
    148172protected:
    149173    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
     
    153177};
    154178   
    155 class SwizzledCopybackBuffer : public StreamSetBuffer {
     179class SwizzledCopybackBuffer final : public StreamSetBuffer {
    156180public:
    157181    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::SwizzledCopybackBuffer;}
     
    174198// within their set whenever the index exceeds its capacity
    175199//
    176 // ExpandableBuffers do not allow access to the base stream set but will automatically increase the number of streams
    177 // within their set whenever the index exceeds its capacity
    178 //
    179 class ExpandableBuffer : public StreamSetBuffer {
     200class ExpandableBuffer final : public StreamSetBuffer {
    180201public:
    181202    static inline bool classof(const StreamSetBuffer * b) {return b->getBufferKind() == BufferKind::ExpandableBuffer;}
     
    187208    llvm::Value * getStreamPackPtr(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex, const bool readOnly) const override;
    188209
    189     llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
     210    llvm::Value * getLinearlyAccessibleItems(llvm::Value * self, llvm::Value * fromPosition) const override;
    190211
    191212    void allocateBuffer() override;
     
    194215
    195216protected:
     217
     218    llvm::Value * getBaseAddress(llvm::Value * self) const override;
    196219
    197220    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
Note: See TracChangeset for help on using the changeset viewer.