Ignore:
Timestamp:
Sep 14, 2017, 11:30:53 AM (20 months ago)
Author:
cameron
Message:

Modifying multiblock kernel builder for non-fixed input stream sets - temp check-in

File:
1 edited

Legend:

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

    r5635 r5638  
    902902    Value * itemsToDo = kb->CreateSub(itemsAvail, processed);
    903903    Value * fullStridesToDo = kb->CreateUDiv(itemsToDo, strideSize);
    904     Value * excessItems = kb->CreateURem(itemsToDo, strideSize);
    905904
    906905    //  Now we iteratively process these blocks using the doMultiBlock method.
     
    938937        auto & rate = mStreamSetInputs[i].rate;
    939938        if (rate.isUnknownRate()) continue;  // No calculation possible for unknown rates.
    940         Value * maxReferenceItems = nullptr;
    941         if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
    942             maxReferenceItems = kb->CreateMul(kb->getLinearlyAccessibleBlocks(mStreamSetInputs[i].name, blkNo), blockSize);
    943 
    944         } else {
    945             Value * linearlyAvailItems = kb->getLinearlyAccessibleItems(mStreamSetInputs[i].name, p);
    946             maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), linearlyAvailItems);
    947         }
     939        Value * linearlyAvailItems = kb->CreateMul(kb->getLinearlyAccessibleBlocks(mStreamSetInputs[i].name, blkNo), blockSize);
     940        Value * maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), linearlyAvailItems);
    948941        Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
    949942        linearlyAvailStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyAvailStrides), maxStrides, linearlyAvailStrides);
     
    961954        auto & rate = mStreamSetOutputs[i].rate;
    962955        if (rate.isUnknownRate()) continue;  // No calculation possible for unknown rates.
    963         Value * maxReferenceItems = nullptr;
    964         if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
    965             maxReferenceItems = kb->CreateMul(kb->getLinearlyWritableBlocks(mStreamSetOutputs[i].name, blkNo), blockSize);
    966         } else {
    967             Value * writableItems = kb->getLinearlyWritableItems(mStreamSetOutputs[i].name, p);
    968             maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), writableItems);
    969         }
     956        Value * writableItems = kb->CreateMul(kb->getLinearlyWritableBlocks(mStreamSetOutputs[i].name, blkNo), blockSize);
     957        Value * maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), writableItems);
    970958        Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
    971959        linearlyWritableStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyWritableStrides), maxStrides, linearlyWritableStrides);
     
    10401028    }
    10411029
    1042     Value * reducedStridesToDo = kb->CreateSub(stridesRemaining, linearlyWritableStrides);
    1043     stridesRemaining->addIncoming(reducedStridesToDo, kb->GetInsertBlock());
    10441030    if (mIsDerived[0]) {
     1031        Value * reducedStridesToDo = kb->CreateSub(stridesRemaining, linearlyWritableStrides);
     1032        stridesRemaining->addIncoming(reducedStridesToDo, kb->GetInsertBlock());
    10451033        Value * nowProcessed = kb->CreateAdd(processedItemCount[0], linearlyAvailItems);
    10461034        kb->setProcessedItemCount(mStreamSetInputs[0].name, nowProcessed);
     
    10481036    }
    10491037    else {
     1038        // Processed item count updated by the kernel itself.
    10501039        Value * nowProcessed = kb->getProcessedItemCount(mStreamSetInputs[0].name);
    1051         Value * allAvailableItemsProcessed = kb->CreateICmpUGE(kb->CreateSub(nowProcessed, processedItemCount[0]), linearlyAvailItems);
    1052         kb->CreateCondBr(allAvailableItemsProcessed, doSegmentOuterLoop, segmentDone);
     1040        Value * remainingItemsToDo = kb->CreateSub(itemsAvail, nowProcessed);
     1041        Value * reducedStridesToDo = kb->CreateUDiv(remainingItemsToDo, nowProcessed);
     1042        stridesRemaining->addIncoming(reducedStridesToDo, kb->GetInsertBlock());
     1043        // If we didn't make progress, we have gone as far as we can in this segment.
     1044        kb->CreateCondBr(kb->CreateICmpUGT(nowProcessed, processedItemCount[0]), doSegmentOuterLoop, segmentDone);
    10531045    }
    10541046
     
    10671059
    10681060    kb->SetInsertPoint(doTempBufferBlock);
     1061    Value * excessItems = kb->CreateSub(itemsAvail, kb->getProcessedItemCount(mStreamSetInputs[0].name));
    10691062    Value * tempBlockItems = kb->CreateSelect(haveStrides, strideSize, excessItems);
    10701063    Value * doFinal = kb->CreateNot(haveStrides);
     
    12221215    else {
    12231216        Value * nowProcessed = kb->getProcessedItemCount(mStreamSetInputs[0].name);
    1224         Value * allAvailableItemsProcessed = kb->CreateICmpEQ(kb->CreateSub(nowProcessed, processedItemCount[0]), finalItemCountNeeded[0]);
    1225         BasicBlock * checkTermination = kb->CreateBasicBlock("checkTermination");
    1226         kb->CreateCondBr(allAvailableItemsProcessed, checkTermination, segmentDone);
    1227         kb->SetInsertPoint(checkTermination);
    1228         stridesRemaining->addIncoming(kb->CreateSub(stridesRemaining, kb->CreateZExt(haveStrides, kb->getSizeTy())), kb->GetInsertBlock());
     1217        Value * remainingItemsToDo = kb->CreateSub(itemsAvail, nowProcessed);
     1218        Value * reducedStridesToDo = kb->CreateUDiv(remainingItemsToDo, nowProcessed);
     1219        stridesRemaining->addIncoming(reducedStridesToDo, kb->GetInsertBlock());
     1220        Value * haveStrides = kb->CreateICmpUGT(reducedStridesToDo, kb->getSize(0));
    12291221        kb->CreateCondBr(haveStrides, doSegmentOuterLoop, setTermination);
    12301222    }   
Note: See TracChangeset for help on using the changeset viewer.