Ignore:
Timestamp:
Nov 18, 2016, 1:46:55 PM (2 years ago)
Author:
nmedfort
Message:

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

File:
1 edited

Legend:

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

    r5202 r5217  
    1616enum FieldType {i1 = 1, i2 = 2, i4 = 4, i8 = 8, i16 = 16, i32 = 32, i64 = 64, i128 = 128, i256 = 256};
    1717
    18 inline llvm::Type * StreamSetType(IDISA::IDISA_Builder * iBuilder, const unsigned count, const unsigned width) {
    19     llvm::Type * streamType = ((width == 1) ? iBuilder->getBitBlockType() : ArrayType::get(iBuilder->getBitBlockType(), width));
    20     return ArrayType::get(streamType, count);
    21 }
    22 
    23 // Stream Set Structs hold information about the current state
    24 // of a stream set buffer.
     18// Stream Set Structs hold information about the current state of a stream set buffer.
    2519
    2620llvm::Value * getProducerPosPtr(IDISA::IDISA_Builder * b, Value * bufferStructPtr);
    2721llvm::Value * getConsumerPosPtr(IDISA::IDISA_Builder * b, Value * bufferStructPtr);
    28 llvm::Value * hasEndOfInputPtr(IDISA::IDISA_Builder * b, Value * bufferStructPtr);
     22llvm::Value * getEndOfInputPtr(IDISA::IDISA_Builder * b, Value * bufferStructPtr);
    2923llvm::Value * getStreamSetBufferPtr(IDISA::IDISA_Builder * b, Value * bufferStructPtr);
    3024
     
    3428    enum class BufferKind : unsigned {BlockBuffer, ExternalFileBuffer, CircularBuffer, LinearCopybackBuffer};
    3529
    36     inline BufferKind getBufferKind() const {return mBufferKind;}
     30    inline BufferKind getBufferKind() const {
     31        return mBufferKind;
     32    }
    3733
    38     inline llvm::Type * getBufferStreamSetType() {return mStreamSetType;}
     34    inline llvm::Type * getBufferStreamSetType() const {
     35        return mStreamSetType;
     36    }
    3937
    40     llvm::PointerType * getStreamBufferPointerType();
     38    llvm::PointerType * getStreamBufferPointerType() const {
     39        return mStreamSetType->getPointerTo(mAddrSpace);
     40    }
    4141
    42     size_t getBufferSize() { return mBufferBlocks;}
     42    llvm::PointerType * getStreamSetStructPointerType() const {
     43        return mStreamSetStructType->getPointerTo();
     44    }
     45
     46    size_t getBufferSize() const { return mBufferBlocks; }
     47       
     48    llvm::Value * getStreamSetBasePtr() const { return mStreamSetBufferPtr; }
    4349   
    44     virtual llvm::Value * allocateBuffer();
    45    
    46     llvm::Value * getStreamSetBasePtr() {return mStreamSetBufferPtr;}
    47    
     50    llvm::Value * getStreamSetStructPtr() const { return mStreamSetStructPtr; }
     51
     52    virtual void allocateBuffer();
     53
    4854    // Get the buffer pointer for a given block of the stream.
    4955    virtual llvm::Value * getStreamSetBlockPointer(llvm::Value * bufferStructPtr, llvm::Value * blockNo) = 0;
     
    5763    virtual void setConsumerPos(Value * bufferStructPtr, Value * pos);
    5864
    59     llvm::Value * hasEndOfInputPtr(Value * bufferStructPtr);
     65    llvm::Value * getEndOfInputPtr(Value * bufferStructPtr);
    6066
    6167    void setEndOfInput(Value * bufferStructPtr);
    6268   
    63     llvm::Value * getStreamSetBufferPtrPtr(Value * bufferStructPtr);
     69protected:
     70    StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * type, unsigned blocks, unsigned AddressSpace = 0)
     71    : mBufferKind(k)
     72    , iBuilder(b)
     73    , mStreamSetType(isa<IDISA::StreamType>(type) ? cast<IDISA::StreamType>(type)->resolveType(b) : type)
     74    , mBufferBlocks(blocks)
     75    , mAddrSpace(AddressSpace)
     76    , mStreamSetBufferPtr(nullptr)
     77    , mStreamSetStructPtr(nullptr)
     78    , mStreamSetStructType(StructType::get(b->getContext(),
     79                            {{b->getSizeTy(),
     80                              b->getSizeTy(),
     81                              b->getInt1Ty(),
     82                              PointerType::get(mStreamSetType, AddressSpace)}})) {
    6483
    65     virtual llvm::PointerType * getStreamSetStructPointerType();
    66 
    67     virtual llvm::Value * getStreamSetStructPtr();
    68    
    69 protected:
    70     StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * type, unsigned blocks, unsigned AddressSpace = 0) :
    71         mBufferKind(k), iBuilder(b), mStreamSetType(type), mBufferBlocks(blocks), mAddrSpace(AddressSpace), mStreamSetBufferPtr(nullptr) {
    72             mStreamSetStructType =
    73                 StructType::get(iBuilder->getContext(),
    74                                 std::vector<Type *>({iBuilder->getSizeTy(),
    75                                                     iBuilder->getSizeTy(),
    76                                                     iBuilder->getInt1Ty(),
    77                                                     PointerType::get(type, AddressSpace)}));
    7884    }
    7985protected:
    8086    const BufferKind        mBufferKind;
    8187    IDISA::IDISA_Builder *  iBuilder;
    82     llvm::Type *            mStreamSetType;
     88    llvm::Type * const      mStreamSetType;
    8389    size_t                  mBufferBlocks;
    8490    int                     mAddrSpace;
    8591    llvm::Value *           mStreamSetBufferPtr;
    8692    llvm::Value *           mStreamSetStructPtr;
    87     llvm::Type *            mStreamSetStructType;
     93    llvm::Type * const      mStreamSetStructType;
    8894};   
    8995
     
    115121
    116122    // Can't allocate - raise an error. */
    117     llvm::Value * allocateBuffer() override;
     123    void allocateBuffer() override;
     124
    118125    llvm::Value * getStreamSetBlockPointer(llvm::Value * bufferStructPtr, llvm::Value * blockNo) override;
    119 
    120126};
    121127   
     
    128134    CircularBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0)
    129135    : StreamSetBuffer(BufferKind::CircularBuffer, b, type, bufferBlocks, AddressSpace) {
    130         if (((bufferBlocks - 1) & bufferBlocks) != 0) {
    131             throw std::runtime_error("CircularStreamSetBuffer: number of blocks must be a power of 2!");
    132         }
     136
    133137    }
    134138
Note: See TracChangeset for help on using the changeset viewer.