Ignore:
Timestamp:
Sep 13, 2017, 11:50:27 AM (20 months ago)
Author:
cameron
Message:

PDEP kernel: only process blocks if sufficient source stream data available

File:
1 edited

Legend:

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

    r5630 r5635  
    10401040    }
    10411041
    1042     Value * nowProcessed = kb->CreateAdd(processedItemCount[0], linearlyAvailItems);
    1043     kb->setProcessedItemCount(mStreamSetInputs[0].name, nowProcessed);
    10441042    Value * reducedStridesToDo = kb->CreateSub(stridesRemaining, linearlyWritableStrides);
    10451043    stridesRemaining->addIncoming(reducedStridesToDo, kb->GetInsertBlock());
    1046     kb->CreateBr(doSegmentOuterLoop);
    1047 
     1044    if (mIsDerived[0]) {
     1045        Value * nowProcessed = kb->CreateAdd(processedItemCount[0], linearlyAvailItems);
     1046        kb->setProcessedItemCount(mStreamSetInputs[0].name, nowProcessed);
     1047        kb->CreateBr(doSegmentOuterLoop);
     1048    }
     1049    else {
     1050        Value * nowProcessed = kb->getProcessedItemCount(mStreamSetInputs[0].name);
     1051        Value * allAvailableItemsProcessed = kb->CreateICmpUGE(kb->CreateSub(nowProcessed, processedItemCount[0]), linearlyAvailItems);
     1052        kb->CreateCondBr(allAvailableItemsProcessed, doSegmentOuterLoop, segmentDone);
     1053    }
    10481054
    10491055    //
     
    11721178    //  Update the processed item count (and hence all the counts derived automatically
    11731179    //  therefrom).
    1174     kb->setProcessedItemCount(mStreamSetInputs[0].name, finalItemCountNeeded[0]);
     1180    if (mIsDerived[0]) {
     1181        kb->setProcessedItemCount(mStreamSetInputs[0].name, finalItemCountNeeded[0]);
     1182    }
    11751183   
    11761184    // Copy back data to the actual output buffers.
     
    12071215    //  actual buffers.  If this isn't the final block, loop back for more multiblock processing.
    12081216    //
    1209     stridesRemaining->addIncoming(kb->CreateSub(stridesRemaining, kb->CreateZExt(haveStrides, kb->getSizeTy())), kb->GetInsertBlock());
    12101217    BasicBlock * setTermination = kb->CreateBasicBlock("mBsetTermination");
    1211     kb->CreateCondBr(haveStrides, doSegmentOuterLoop, setTermination);
     1218    if (mIsDerived[0]) {
     1219        stridesRemaining->addIncoming(kb->CreateSub(stridesRemaining, kb->CreateZExt(haveStrides, kb->getSizeTy())), kb->GetInsertBlock());
     1220        kb->CreateCondBr(haveStrides, doSegmentOuterLoop, setTermination);
     1221    }
     1222    else {
     1223        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());
     1229        kb->CreateCondBr(haveStrides, doSegmentOuterLoop, setTermination);
     1230    }   
    12121231    kb->SetInsertPoint(setTermination);
    12131232    kb->setTerminationSignal();
Note: See TracChangeset for help on using the changeset viewer.