Ignore:
Timestamp:
Dec 21, 2016, 3:53:58 PM (3 years ago)
Author:
nmedfort
Message:

Bug fixes for Carry Manager and issues reported by Fahad

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r5228 r5233  
    1818namespace pablo {
    1919
    20 inline static unsigned nearest_pow2(const unsigned v) {
     20inline static unsigned nearest_pow2(const uint32_t v) {
    2121    assert(v > 0 && v < (UINT32_MAX / 2));
    2222    return (v < 2) ? 1 : (1 << (32 - __builtin_clz(v - 1)));
     
    107107    if (LLVM_UNLIKELY(mCarryInfo->variableLength)) {
    108108        // Check whether we need to resize the carry state
    109         PHINode * index = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
     109        PHINode * index = iBuilder->CreatePHI(iBuilder->getInt32Ty(), 2);
    110110        mLoopIndicies.push_back(index);
    111         index->addIncoming(iBuilder->getSize(0), entryBlock);
     111        index->addIncoming(iBuilder->getInt32(0), entryBlock);
    112112        Value * capacityPtr = iBuilder->CreateGEP(mCurrentFrame, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    113113        Value * capacity = iBuilder->CreateLoad(capacityPtr, false, "carryCapacity");
     
    122122
    123123        Type * const carryStateType = arrayPtr->getType()->getPointerElementType()->getPointerElementType();
    124         Value * newCapacity = iBuilder->CreateMul(iBuilder->CreateAdd(index, iBuilder->getSize(1)), iBuilder->getSize(2));
     124        Value * newCapacity = iBuilder->CreateMul(iBuilder->CreateAdd(index, iBuilder->getInt32(1)), iBuilder->getInt32(2));
    125125        Value * newArrayPtr = iBuilder->CreateAlignedMalloc(carryStateType, newCapacity, iBuilder->getCacheAlignment());
    126126        iBuilder->CreateMemCpy(newArrayPtr, arrayPtr, capacity, iBuilder->getCacheAlignment());
     
    151151        assert (mLoopIndicies.size() > 0);
    152152        PHINode * index = mLoopIndicies.back();
    153         index->addIncoming(iBuilder->CreateAdd(index, iBuilder->getSize(1)), exitBlock);
     153        index->addIncoming(iBuilder->CreateAdd(index, iBuilder->getInt32(1)), exitBlock);
    154154        mLoopIndicies.pop_back();
    155155    }
     
    183183        ConstantInt * zero = iBuilder->getInt32(0);
    184184        std::vector<Value *> indicies;
    185         // enter the (potentially nested) struct and extract the summary element (0)
     185        // enter the (potentially nested) struct and extract the summary element (always element 0)
    186186        unsigned count = 2;
    187187        if (LLVM_UNLIKELY(mCarryInfo->hasBorrowedSummary())) {
     
    301301 ** ------------------------------------------------------------------------------------------------------------- */
    302302Value * CarryManager::addCarryInCarryOut(const Statement * operation, Value * const e1, Value * const e2) {
     303    assert (dyn_cast_or_null<ScanThru>(operation) || dyn_cast_or_null<MatchStar>(operation));
    303304    Value * const carryIn = getNextCarryIn();
    304305    Value * carryOut, * result;
     
    404405    }
    405406    assert (carryInPtr->getType()->getPointerElementType() == mCarryPackType);
    406     return iBuilder->CreateBlockAlignedLoad(carryInPtr);
     407    Value * const carryIn = iBuilder->CreateBlockAlignedLoad(carryInPtr);
     408    if (mLoopDepth > 0) {
     409        iBuilder->CreateBlockAlignedStore(Constant::getNullValue(mCarryPackType), carryInPtr);
     410    }
     411    return carryIn;
    407412}
    408413
Note: See TracChangeset for help on using the changeset viewer.