Ignore:
Timestamp:
Apr 28, 2017, 2:50:59 PM (2 years ago)
Author:
nmedfort
Message:

Refactored source kernels. icgrep from stdin should now be able to handle any file size.

File:
1 edited

Legend:

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

    r5411 r5429  
    2121    enum class BufferKind : unsigned {
    2222        BlockBuffer
    23         , ExternalFileBuffer
    24         , SourceFileBuffer
     23        , SourceBuffer
     24        , ExternalBuffer
    2525        , CircularBuffer
    2626        , CircularCopybackBuffer
    2727        , SwizzledCopybackBuffer
    2828        , ExpandableBuffer
    29         , ExtensibleBuffer
    3029    };
    3130
     
    143142};
    144143
    145 class ExternalFileBuffer final : public StreamSetBuffer {
    146 public:
    147     static inline bool classof(const StreamSetBuffer * b) {
    148         return b->getBufferKind() == BufferKind::ExternalFileBuffer;
    149     }
    150 
    151     ExternalFileBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace = 0);
    152 
    153     void setStreamSetBuffer(llvm::Value * ptr);
     144class SourceBuffer final : public StreamSetBuffer {
     145public:
     146    static inline bool classof(const StreamSetBuffer * b) {
     147        return b->getBufferKind() == BufferKind::SourceBuffer;
     148    }
     149
     150    SourceBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace = 0);
     151
     152    void setBaseAddress(llvm::Value * self, llvm::Value * addr) const override;
     153
     154    void setBufferedSize(llvm::Value * self, llvm::Value * size) const override;
     155
     156    llvm::Value * getBufferedSize(llvm::Value * self) const override;
     157
     158    llvm::Value * getLinearlyAccessibleItems(llvm::Value * self, llvm::Value * fromPosition) const override;
     159
     160protected:
     161
     162    llvm::Value * getBaseAddress(llvm::Value * self) const override;
     163
     164    llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     165
     166};
     167
     168class ExternalBuffer final : public StreamSetBuffer {
     169public:
     170    static inline bool classof(const StreamSetBuffer * b) {
     171        return b->getBufferKind() == BufferKind::ExternalBuffer;
     172    }
     173
     174    ExternalBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, llvm::Value * addr, unsigned AddressSpace = 0);
    154175
    155176    // Can't allocate - raise an error. */
     
    162183};
    163184
    164 class SourceFileBuffer final : public StreamSetBuffer {
    165 public:
    166     static inline bool classof(const StreamSetBuffer * b) {
    167         return b->getBufferKind() == BufferKind::SourceFileBuffer;
    168     }
    169 
    170     SourceFileBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, unsigned AddressSpace = 0);
    171 
    172     void setBaseAddress(llvm::Value * self, llvm::Value * addr) const override;
    173 
    174     void setBufferedSize(llvm::Value * self, llvm::Value * size) const override;
    175 
    176     llvm::Value * getBufferedSize(llvm::Value * self) const override;
    177 
    178     llvm::Value * getLinearlyAccessibleItems(llvm::Value * self, llvm::Value * fromPosition) const override;
    179 
    180 protected:
    181 
    182     llvm::Value * getBaseAddress(llvm::Value * self) const override;
    183 
    184     llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    185 };
    186 
    187 class ExtensibleBuffer final : public StreamSetBuffer {
    188 public:
    189     static inline bool classof(const StreamSetBuffer * b) {
    190         return b->getBufferKind() == BufferKind::ExtensibleBuffer;
    191     }
    192 
    193     ExtensibleBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    194 
    195     llvm::Value * getLinearlyAccessibleItems(llvm::Value * self,llvm::Value * fromPosition) const override;
    196 
    197     void allocateBuffer() override;
    198 
    199     void reserveBytes(llvm::Value * self, llvm::Value * required) const override;
    200 
    201     void setBufferedSize(llvm::Value * self, llvm::Value * size) const override;
    202 
    203     llvm::Value * getBufferedSize(llvm::Value * self) const override;
    204 
    205     void releaseBuffer(llvm::Value * self) const override;
    206 
    207 protected:
    208 
    209     llvm::Value * roundUpToPageSize(llvm::Value * const value) const;
    210 
    211     llvm::Value * getBaseAddress(llvm::Value * self) const override;
    212 
    213     llvm::Value * getStreamSetBlockPtr(llvm::Value * self, llvm::Value * blockNo) const override;
    214 
    215 };
    216    
    217185class CircularBuffer final : public StreamSetBuffer {
    218186public:
Note: See TracChangeset for help on using the changeset viewer.