Ignore:
Timestamp:
Feb 10, 2017, 3:55:14 PM (2 years ago)
Author:
nmedfort
Message:

Removed BlockNo? + updated LookAhead? to use getInputStream.

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5310 r5311  
    1313#include <llvm/Support/raw_ostream.h>
    1414
    15 static const auto BLOCK_NO_SCALAR = "blockNo";
    16 
    1715static const auto DO_BLOCK_SUFFIX = "_DoBlock";
    1816
     
    108106        addScalar(binding.type, binding.name);
    109107    }
    110     addScalar(iBuilder->getSizeTy(), BLOCK_NO_SCALAR);
    111108    addScalar(iBuilder->getSizeTy(), LOGICAL_SEGMENT_NO_SCALAR);
    112109    addScalar(iBuilder->getInt1Ty(), TERMINATION_SIGNAL);
     
    245242}
    246243
    247 Value * KernelBuilder::getBlockNo() const {
    248     return getScalarField(mSelf, BLOCK_NO_SCALAR);
    249 }
    250 
    251 void KernelBuilder::setBlockNo(Value * value) const {
    252     setScalarField(mSelf, BLOCK_NO_SCALAR, value);
    253 }
    254 
    255244inline Value * KernelBuilder::computeBlockIndex(const std::vector<Binding> & bindings, const std::string & name, Value * itemCount) const {
    256245    for (const Binding & b : bindings) {
     
    279268}
    280269
     270llvm::Value * KernelBuilder::getInputStream(Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const {
     271    Value * blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
     272    blockIndex = iBuilder->CreateAdd(blockIndex, blockAdjustment);
     273    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
     274    return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
     275}
     276
    281277Value * KernelBuilder::getOutputStream(const std::string & name, Value * streamIndex) const {
    282278    Value * const blockIndex = computeBlockIndex(mStreamSetOutputs, name, getProducedItemCount(name));
     
    326322Value * KernelBuilder::createGetAccumulatorCall(Value * self, const std::string & accumName) const {
    327323    return iBuilder->CreateCall(getAccumulatorFunction(accumName), {self});
    328 }
    329 
    330 Value * KernelBuilder::getInputStreamSetPtr(const std::string & name, Value * blockNo) const {
    331     return getInputStreamSetBuffer(name)->getStreamSetPtr(getStreamSetBufferPtr(name), blockNo);
    332324}
    333325
     
    385377
    386378    ConstantInt * stride = iBuilder->getSize(iBuilder->getStride());
    387     ConstantInt * strideBlocks = iBuilder->getSize(iBuilder->getStride() / iBuilder->getBitBlockWidth());
    388379
    389380    Value * availablePos = producerPos[0];
     
    405396
    406397    iBuilder->SetInsertPoint(strideLoopBody);
    407     Value * blockNo = getBlockNo();
    408398
    409399    CreateDoBlockMethodCall();
    410400
    411     setBlockNo(iBuilder->CreateAdd(blockNo, strideBlocks));
    412 
    413401    // Update counts
    414 
    415402    for (unsigned i = 0; i < mStreamSetInputs.size(); i++) {
    416403        Value * processed = getProcessedItemCount(mStreamSetInputs[i].name);
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5310 r5311  
    153153    llvm::ConstantInt * getScalarIndex(const std::string & name) const;
    154154
    155     llvm::Value * getBlockNo() const;
    156 
    157     void setBlockNo(llvm::Value * value) const;
    158    
    159155    // Get the value of a scalar field for a given instance.
    160156    llvm::Value * getScalarField(const std::string & fieldName) const {
     
    183179    llvm::Value * getOutputStream(const std::string & name, llvm::Value * streamIndex, llvm::Value * packIndex) const;
    184180
     181    llvm::Value * getInputStream(llvm::Value * blockAdjustment, const std::string & name, llvm::Value * streamIndex) const;
     182
    185183    llvm::Value * getRawInputPointer(const std::string & name, llvm::Value * streamIndex, llvm::Value * absolutePosition) const;
    186184
     
    195193    }
    196194
    197     llvm::Value * getInputStreamSetPtr(const std::string & name, llvm::Value * blockNo) const;
    198 
    199195    inline llvm::Value * getProcessedItemCount(const std::string & name) const {
    200196        return getProcessedItemCount(getSelf(), name);
     
    229225
    230226    // Stream set helpers.
    231 //    llvm::Value * getStream(const std::string & name, llvm::Value * blockNo, llvm::Value * index) const;
    232 
    233 //    llvm::Value * getStream(const std::string & name, llvm::Value * blockNo, llvm::Value * index1, llvm::Value * index2) const;
    234227
    235228    llvm::Value * getStreamSetBufferPtr(const std::string & name) const;
    236 
    237 //    llvm::Value * getStreamSetBufferPtr(llvm::Value * index) const;
    238229
    239230    llvm::Value * getScalarFieldPtr(llvm::Value * instance, const std::string & name) const;
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5307 r5311  
    8181    Constant * Const4 = iBuilder->getSize(4);
    8282    Constant * tripleBlockSize = iBuilder->getSize(3 * iBuilder->getStride());
    83     Constant * stride = iBuilder->getSize(iBuilder->getStride());
    8483    Constant * packSize = iBuilder->getSize(PACK_SIZE);
    8584    Constant * triplePackSize = iBuilder->getSize(3 * PACK_SIZE); // 3 packs per loop.
     
    161160    setProcessedItemCount("sourceStream", processed);
    162161   
    163     setBlockNo(iBuilder->CreateUDiv(processed, stride));
    164162    // We have produced 4 output bytes for every 3 input bytes.
    165163    Value * totalProduced = iBuilder->CreateMul(iBuilder->CreateUDiv(processed, Const3), Const4);
     
    235233    setProcessedItemCount("sourceStream", processed);
    236234
    237     setBlockNo(iBuilder->CreateUDiv(processed, stride));
    238235    // We have produced 4 output bytes for every 3 input bytes.  If the number of input
    239236    // bytes is not a multiple of 3, then we have one more output byte for each excess
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5297 r5311  
    4747    const unsigned fieldCount = iBuilder->getBitBlockWidth() / T->getBitWidth();
    4848    Type * scanwordVectorType =  VectorType::get(T, fieldCount);
    49     Value * blockNo = getBlockNo();
     49    Value * blockNo = getScalarField("BlockNo");
    5050    Value * scanwordPos = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), iBuilder->getBitBlockWidth()));   
    5151    Value * recordStart = getScalarField("LineStart");
     
    6565    setScalarField("LineStart", recordStart);
    6666    setScalarField("LineNum", recordNum);
     67    setScalarField("BlockNo", iBuilder->CreateAdd(blockNo, iBuilder->getSize(1)));
    6768}
    6869
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5307 r5311  
    9595}
    9696
    97 Value * ExternalFileBuffer::getLinearlyAccessibleItems(llvm::Value * fromPosition) const {
    98     throw std::runtime_error("External buffers: getLinearlyAccessibleItems not supported.");
     97Value * ExternalFileBuffer::getLinearlyAccessibleItems(llvm::Value *) const {
     98    report_fatal_error("External buffers: getLinearlyAccessibleItems not supported.");
    9999}
    100100
    101101// Circular Buffer
    102102
    103 Value * CircularBuffer::getStreamSetPtr(Value * self, Value * blockNo) const {
    104     assert (blockNo->getType()->isIntegerTy());
     103Value * CircularBuffer::getStreamSetPtr(Value * self, Value * blockIndex) const {
     104    assert (blockIndex->getType()->isIntegerTy());
    105105    Value * offset = nullptr;
    106106    if (mBufferBlocks == 1) {
    107107        offset = ConstantInt::getNullValue(iBuilder->getSizeTy());
    108108    } else if ((mBufferBlocks & (mBufferBlocks - 1)) == 0) { // is power of 2
    109         offset = iBuilder->CreateAnd(blockNo, ConstantInt::get(blockNo->getType(), mBufferBlocks - 1));
     109        offset = iBuilder->CreateAnd(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks - 1));
    110110    } else {
    111         offset = iBuilder->CreateURem(blockNo, ConstantInt::get(blockNo->getType(), mBufferBlocks));
     111        offset = iBuilder->CreateURem(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks));
    112112    }
    113113    return iBuilder->CreateGEP(self, offset);
     
    155155}
    156156
    157 Value * CircularCopybackBuffer::getStreamSetPtr(Value * self, Value * blockNo) const {
    158     assert (blockNo->getType()->isIntegerTy());
     157Value * CircularCopybackBuffer::getStreamSetPtr(Value * self, Value * blockIndex) const {
     158    assert (blockIndex->getType()->isIntegerTy());
    159159   
    160160    Value * offset = nullptr;
     
    162162        offset = ConstantInt::getNullValue(iBuilder->getSizeTy());
    163163    } else if ((mBufferBlocks & (mBufferBlocks - 1)) == 0) { // is power of 2
    164         offset = iBuilder->CreateAnd(blockNo, ConstantInt::get(blockNo->getType(), mBufferBlocks - 1));
     164        offset = iBuilder->CreateAnd(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks - 1));
    165165    } else {
    166         offset = iBuilder->CreateURem(blockNo, ConstantInt::get(blockNo->getType(), mBufferBlocks));
     166        offset = iBuilder->CreateURem(blockIndex, ConstantInt::get(blockIndex->getType(), mBufferBlocks));
    167167    }
    168168    return iBuilder->CreateGEP(self, offset);
     
    173173// Expandable Buffer
    174174
    175 Value * ExpandableBuffer::getStreamSetPtr(Value * self, Value * blockNo) const {
     175void ExpandableBuffer::ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const {
     176
     177}
     178
     179llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, Value * streamIndex, Value * blockIndex) const {
     180    ensureStreamCapacity(self, streamIndex);
     181
     182
     183
    176184    return nullptr;
    177185}
    178186
    179 llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, llvm::Value * blockNo, llvm::Value * index) const {
     187llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, llvm::Value * streamIndex, Value *blockIndex, Value *packIndex) const {
     188    ensureStreamCapacity(self, streamIndex);
     189
     190
    180191    return nullptr;
    181192}
    182193
    183 llvm::Value * ExpandableBuffer::getStream(llvm::Value * self, llvm::Value * blockNo, Value *index1, Value *index2) const {
    184     return nullptr;
     194Value * ExpandableBuffer::getStreamSetPtr(Value *, Value *) const {
     195    report_fatal_error("Expandable buffers: getStreamSetPtr not supported.");
     196}
     197
     198Value * ExpandableBuffer::getLinearlyAccessibleItems(llvm::Value *) const {
     199    report_fatal_error("Expandable buffers: getLinearlyAccessibleItems not supported.");
    185200}
    186201
     
    210225: StreamSetBuffer(BufferKind::ExpandableBuffer, b, type, bufferBlocks, AddressSpace) {
    211226
    212 }
    213 
    214 Value * ExpandableBuffer::getLinearlyAccessibleItems(llvm::Value * fromPosition) const {
    215     throw std::runtime_error("Expandable buffers: getLinearlyAccessibleItems not supported.");
    216227}
    217228
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5307 r5311  
    115115
    116116protected:
    117     llvm::Value * getStreamSetPtr(llvm::Value * bufferBasePtr, llvm::Value * blockNo) const override;
     117    llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    118118};
    119119   
     
    139139   
    140140protected:
    141     llvm::Value * getStreamSetPtr(llvm::Value * bufferBasePtr, llvm::Value * blockNo) const override;
     141    llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    142142private:
    143143    size_t mOverflowBlocks;
     
    154154    ExpandableBuffer(IDISA::IDISA_Builder * b, llvm::Type * type, size_t bufferBlocks, unsigned AddressSpace = 0);
    155155
    156     llvm::Value * getStream(llvm::Value * self, llvm::Value * blockNo, llvm::Value * index) const override;
     156    llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex) const override;
    157157
    158     llvm::Value * getStream(llvm::Value * self, llvm::Value * blockNo, llvm::Value * index1, llvm::Value * index2) const override;
     158    llvm::Value * getStream(llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex) const override;
    159159
    160160    llvm::Value * getLinearlyAccessibleItems(llvm::Value * fromPosition) const override;
     
    162162protected:
    163163
    164     llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockNo) const override;
     164    void ensureStreamCapacity(llvm::Value * self, llvm::Value * streamIndex) const;
     165
     166    llvm::Value * getStreamSetPtr(llvm::Value * self, llvm::Value * blockIndex) const override;
    165167};
    166168
Note: See TracChangeset for help on using the changeset viewer.