Ignore:
Timestamp:
Sep 22, 2017, 3:36:36 PM (2 years ago)
Author:
nmedfort
Message:

Minor bug fixes and removal of inadvertent check in for StreamSet?.cpp/h

Location:
icGREP/icgrep-devel/icgrep
Files:
7 edited

Legend:

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

    r5646 r5647  
    133133    std::tie(port, index) = mKernel->getStreamPort(name);
    134134    const StreamSetBuffer * buf = nullptr;
    135     if (port == Kernel::Port::Input) {
    136         buf = mKernel->getInputStreamSetBuffer(name);
     135    if (port == Kernel::Port::Input) {       
    137136        const auto lookAhead = mKernel->getLookAhead(index);
    138137        if (LLVM_UNLIKELY(lookAhead != 0)) {
    139138            fromPosition = CreateAdd(ConstantInt::get(fromPosition->getType(), lookAhead), fromPosition);
    140139        }
     140        buf = mKernel->getInputStreamSetBuffer(name);
    141141    } else {
    142142        buf = mKernel->getOutputStreamSetBuffer(name);
    143143    }
     144    assert (buf);
    144145    return buf->getLinearlyAccessibleItems(this, getStreamSetBufferPtr(name), fromPosition);
    145146}
     
    149150    std::tie(port, index) = mKernel->getStreamPort(name);
    150151    const StreamSetBuffer * buf = nullptr;
    151     if (port == Kernel::Port::Input) {
    152         buf = mKernel->getInputStreamSetBuffer(name);
     152    if (port == Kernel::Port::Input) {       
    153153        const auto lookAhead = mKernel->getLookAhead(index);
    154154        if (LLVM_UNLIKELY(lookAhead != 0)) {
     
    156156            fromBlock = CreateAdd(ConstantInt::get(fromBlock->getType(), blocksAhead), fromBlock);
    157157        }
     158        buf = mKernel->getInputStreamSetBuffer(name);
    158159    } else {
    159160        buf = mKernel->getOutputStreamSetBuffer(name);
    160161    }
     162    assert (buf);
    161163    return buf->getLinearlyAccessibleBlocks(this, getStreamSetBufferPtr(name), fromBlock);
    162164}
  • icGREP/icgrep-devel/icgrep/kernels/streamset.cpp

    r5646 r5647  
    140140}
    141141
    142 Value * StreamSetBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromPosition, bool reverse, const unsigned lookAhead) const {
     142Value * StreamSetBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromPosition, bool reverse) const {
    143143    Constant * bufSize = iBuilder->getSize(mBufferBlocks * iBuilder->getStride());
    144144    Value * bufRem = iBuilder->CreateURem(fromPosition, bufSize);
     
    149149}
    150150
    151 Value * StreamSetBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromBlock, bool reverse, const unsigned lookAhead) const {
     151Value * StreamSetBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromBlock, bool reverse) const {
    152152    Constant * bufBlocks = iBuilder->getSize(mBufferBlocks);
    153153    Value * bufRem = iBuilder->CreateURem(fromBlock, bufBlocks);
     
    264264}
    265265
    266 Value * SourceBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromPosition, bool reverse, const unsigned lookAhead) const {
     266Value * SourceBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromPosition, bool reverse) const {
    267267    if (reverse) report_fatal_error("SourceBuffer cannot be accessed in reverse");
    268268    return iBuilder->CreateSub(getCapacity(iBuilder, self), fromPosition);
    269269}
    270270
    271 Value * SourceBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromBlock, bool reverse, const unsigned lookAhead) const {
     271Value * SourceBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, Value * self, Value * fromBlock, bool reverse) const {
    272272    if (reverse) report_fatal_error("SourceBuffer cannot be accessed in reverse");
    273273    return iBuilder->CreateSub(iBuilder->CreateUDiv(getCapacity(iBuilder, self), iBuilder->getSize(iBuilder->getBitBlockWidth())), fromBlock);
     
    301301}
    302302
    303 Value * ExternalBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const, Value *, Value *, bool, const unsigned) const {
     303Value * ExternalBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const, Value *, Value *, bool) const {
    304304    report_fatal_error("External buffers: getLinearlyAccessibleItems is not supported.");
    305305}
     
    591591}
    592592
    593 Value * ExpandableBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const, Value *, Value *, bool, const unsigned) const {
     593Value * ExpandableBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const, Value *, Value *, bool) const {
    594594    report_fatal_error("Expandable buffers: getLinearlyAccessibleItems is not supported.");
    595595}
     
    682682
    683683
    684 Value * DynamicBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, Value * handle, Value * fromPosition, bool reverse, const unsigned lookAhead) const {
     684Value * DynamicBuffer::getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, Value * handle, Value * fromPosition, bool reverse) const {
    685685    Constant * blockSize = b->getSize(b->getBitBlockWidth());
    686686    Value * const bufBlocks = b->CreateLoad(b->CreateGEP(handle, {b->getInt32(0), b->getInt32(int(Field::WorkingBlocks))}));
     
    699699}
    700700
    701 Value * DynamicBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const b, Value * handle, Value * fromBlock, bool reverse, const unsigned lookAhead) const {
     701Value * DynamicBuffer::getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const b, Value * handle, Value * fromBlock, bool reverse) const {
    702702    Value * const bufBlocks = b->CreateLoad(b->CreateGEP(handle, {b->getInt32(0), b->getInt32(int(Field::WorkingBlocks))}));
    703703    Value * bufRem = b->CreateURem(fromBlock, bufBlocks);
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5646 r5647  
    8383   
    8484    // The number of items that cam be linearly accessed from a given logical stream position.
    85     virtual llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false, const unsigned lookAhead = 0) const;
    86    
    87     virtual llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false, const unsigned lookAhead = 0) const;
     85    virtual llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false) const;
     86   
     87    virtual llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false) const;
    8888   
    8989    void createBlockCopy(IDISA::IDISA_Builder * const iBuilder, llvm::Value * targetBlockPtr, llvm::Value * sourceBlockPtr, llvm::Value * blocksToCopy) const;
     
    163163    llvm::Value * getCapacity(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const override;
    164164   
    165     llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false, const unsigned lookAhead = 0) const override;
    166    
    167     llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false, const unsigned lookAhead = 0) const override;
     165    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false) const override;
     166   
     167    llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false) const override;
    168168
    169169    llvm::Type * getStreamSetBlockType() const override;
     
    191191    ExternalBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, llvm::Value * addr, unsigned AddressSpace = 0);
    192192
    193     llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false, const unsigned lookAhead = 0) const override;
     193    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false) const override;
    194194
    195195    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
     
    291291    llvm::Value * getStreamPackPtr(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, llvm::Value * packIndex, const bool readOnly) const override;
    292292
    293     llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false, const unsigned lookAhead = 0) const override;
     293    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false) const override;
    294294
    295295    llvm::Value * getStreamSetCount(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const override;
     
    322322    DynamicBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, llvm::Type * type, size_t initialCapacity, size_t overflowBlocks = 0, unsigned swizzleFactor = 1, unsigned addrSpace = 0);
    323323   
    324     llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, bool reverse = false, const unsigned lookAhead = 0) const override;
    325    
    326     llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false, const unsigned lookAhead = 0) const override;
     324    llvm::Value * getLinearlyAccessibleItems(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * fromPosition, bool reverse = false) const override;
     325   
     326    llvm::Value * getLinearlyAccessibleBlocks(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromBlock, bool reverse = false) const override;
    327327
    328328    llvm::Value * getLinearlyWritableItems(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * fromPosition, bool reverse = false) const override;
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/booleanreassociationpass.cpp

    r5486 r5647  
    13061306    using line_t = long long int;
    13071307
    1308     enum : line_t { MAX_INT = std::numeric_limits<line_t>::max() };
     1308    const auto MAX_INT = std::numeric_limits<line_t>::max();
    13091309
    13101310    // errs() << "---------------------------------------------------------\n";
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r5283 r5647  
    351351 * @brief contains
    352352 ** ------------------------------------------------------------------------------------------------------------- */
    353 bool StatementList::contains(Statement * const statement) {
    354     for (Statement * stmt : *this) {
     353bool StatementList::contains(const Statement * const statement) const {
     354    for (const Statement * stmt : *this) {
    355355        if (statement == stmt) {
    356356            return true;
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r5510 r5647  
    461461        iterator(Statement* base): mCurrent(base) {}
    462462
    463         iterator(const iterator& other): mCurrent(other.mCurrent) {}
    464 
    465         const iterator& operator=(const iterator& other) {
    466             mCurrent = other.mCurrent; return other;
     463        iterator(const iterator & other): mCurrent(other.mCurrent) {}
     464
     465        iterator & operator=(const iterator & other) {
     466            mCurrent = other.mCurrent;
     467            return *this;
    467468        }
    468469
     
    473474        }
    474475
    475         iterator  operator++(int) {
     476        iterator operator++(int) {
    476477            iterator tmp(*this);
    477478            ++(*this);
     
    479480        }
    480481
    481         bool operator==(const iterator& other) const {
     482        bool operator==(const iterator & other) const {
    482483            return  mCurrent == other.mCurrent;
    483484        }
    484485
    485         bool operator!=(const iterator& other) const {
     486        bool operator!=(const iterator & other) const {
    486487            return  mCurrent != other.mCurrent;
    487488        }
     
    500501        const_iterator(const Statement* base): mCurrent(base) {}
    501502        const_iterator(const const_iterator& other): mCurrent(other.mCurrent) {}
    502         const const_iterator& operator=(const const_iterator& other) {mCurrent = other.mCurrent; return other;}
     503        const_iterator& operator=(const const_iterator & other) {
     504            mCurrent = other.mCurrent;
     505            return *this;
     506        }
    503507
    504508        inline const_iterator& operator++() {
     
    537541        reverse_iterator(const reverse_iterator& other): mCurrent(other.mCurrent) {}
    538542
    539         const reverse_iterator& operator=(const reverse_iterator& other) {
    540             mCurrent = other.mCurrent; return other;
     543        reverse_iterator & operator=(const reverse_iterator & other) {
     544            mCurrent = other.mCurrent;
     545            return *this;
    541546        }
    542547
     
    573578        const_reverse_iterator(): mCurrent(nullptr) {}
    574579        const_reverse_iterator(const Statement* base): mCurrent(base) {}
    575         const_reverse_iterator(const const_reverse_iterator& other): mCurrent(other.mCurrent) {}
    576         const const_reverse_iterator& operator=(const const_reverse_iterator& other) {mCurrent = other.mCurrent; return other;}
     580        const_reverse_iterator(const const_reverse_iterator & other): mCurrent(other.mCurrent) {}
     581
     582        const_reverse_iterator& operator=(const const_reverse_iterator & other) {
     583            mCurrent = other.mCurrent;
     584            return *this;
     585        }
    577586
    578587        inline const_reverse_iterator& operator++() {
     
    686695    }
    687696
    688     bool contains(Statement * const statement);
     697    bool contains(const Statement * const statement) const;
    689698
    690699protected:
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5646 r5647  
    556556            iBuilder->CreateAlignedStore(value, ptr, alignment);
    557557        } else if (const Lookahead * l = dyn_cast<Lookahead>(stmt)) {
    558             Var * var = nullptr;
    559558            PabloAST * stream = l->getExpression();
    560             Value * index = iBuilder->getInt32(0);
     559            Value * index = nullptr;
    561560            if (LLVM_UNLIKELY(isa<Extract>(stream))) {
    562                 var = cast<Var>(cast<Extract>(stream)->getArray());
     561                stream = cast<Extract>(stream)->getArray();
     562                index = compileExpression(iBuilder, cast<Extract>(stream)->getIndex());
     563            } else {
     564                index = iBuilder->getInt32(0);
    563565            }
    564566            const auto bit_shift = (l->getAmount() % iBuilder->getBitBlockWidth());
    565567            const auto block_shift = (l->getAmount() / iBuilder->getBitBlockWidth());
    566 
    567             Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift), var->getName(), index);
     568            Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift), cast<Var>(stream)->getName(), index);
    568569            Value * lookAhead = iBuilder->CreateBlockAlignedLoad(ptr);
    569570            if (bit_shift == 0) {  // Simple case with no intra-block shifting.
    570571                value = lookAhead;
    571572            } else { // Need to form shift result from two adjacent blocks.
    572                 Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift + 1), var->getName(), index);
     573                Value * ptr = iBuilder->getAdjustedInputStreamBlockPtr(iBuilder->getSize(block_shift + 1), cast<Var>(stream)->getName(), index);
    573574                Value * lookAhead1 = iBuilder->CreateBlockAlignedLoad(ptr);
    574575                if (LLVM_UNLIKELY((bit_shift % 8) == 0)) { // Use a single whole-byte shift, if possible.
Note: See TracChangeset for help on using the changeset viewer.