Changeset 5609


Ignore:
Timestamp:
Aug 11, 2017, 11:39:16 PM (9 days ago)
Author:
cameron
Message:

Ensure available/writable items for more buffer types

File:
1 edited

Legend:

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

    r5608 r5609  
    879879        processedItemCount.push_back(p);
    880880        inputBlockPtr.push_back(b);
    881         if (mIsDerived[i]) {
    882             auto & rate = mStreamSetInputs[i].rate;
    883             Value * maxReferenceItems = nullptr;
    884             if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
    885                 maxReferenceItems = kb->CreateMul(kb->getLinearlyAccessibleBlocks(mStreamSetInputs[i].name, blkNo), blockSize);
    886 
    887             } else {
    888                 Value * linearlyAvailItems = kb->getLinearlyAccessibleItems(mStreamSetInputs[i].name, p);
    889                 maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), linearlyAvailItems);
    890             }
    891             Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
    892             linearlyAvailStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyAvailStrides), maxStrides, linearlyAvailStrides);
    893         }
     881        auto & rate = mStreamSetInputs[i].rate;
     882        if (rate.isUnknownRate()) continue;  // No calculation possible for unknown rates.
     883        Value * maxReferenceItems = nullptr;
     884        if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
     885            maxReferenceItems = kb->CreateMul(kb->getLinearlyAccessibleBlocks(mStreamSetInputs[i].name, blkNo), blockSize);
     886
     887        } else {
     888            Value * linearlyAvailItems = kb->getLinearlyAccessibleItems(mStreamSetInputs[i].name, p);
     889            maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), linearlyAvailItems);
     890        }
     891        Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
     892        linearlyAvailStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyAvailStrides), maxStrides, linearlyAvailStrides);
    894893    }
    895894    //  Now determine the linearly writeable blocks, based on available blocks reduced
     
    902901        producedItemCount.push_back(p);
    903902        outputBlockPtr.push_back(b);
    904         if (mIsDerived[inputSetCount + i]) {
    905             auto & rate = mStreamSetOutputs[i].rate;
    906             Value * maxReferenceItems = nullptr;
    907             if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
    908                 maxReferenceItems = kb->CreateMul(kb->getLinearlyWritableBlocks(mStreamSetOutputs[i].name, blkNo), blockSize);
    909             } else {
    910                 Value * writableItems = kb->getLinearlyWritableItems(mStreamSetOutputs[i].name, p);
    911                 maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), writableItems);
    912             }
    913             Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
    914             linearlyWritableStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyWritableStrides), maxStrides, linearlyWritableStrides);
    915         }
     903        auto & rate = mStreamSetOutputs[i].rate;
     904        if (rate.isUnknownRate()) continue;  // No calculation possible for unknown rates.
     905        Value * maxReferenceItems = nullptr;
     906        if ((rate.isFixedRatio()) && (rate.getRatioNumerator() == rate.getRatioDenominator())) {
     907            maxReferenceItems = kb->CreateMul(kb->getLinearlyWritableBlocks(mStreamSetOutputs[i].name, blkNo), blockSize);
     908        } else {
     909            Value * writableItems = kb->getLinearlyWritableItems(mStreamSetOutputs[i].name, p);
     910            maxReferenceItems = rate.CreateMaxReferenceItemsCalculation(kb.get(), writableItems);
     911        }
     912        Value * maxStrides = kb->CreateUDiv(maxReferenceItems, strideSize);
     913        linearlyWritableStrides = kb->CreateSelect(kb->CreateICmpULT(maxStrides, linearlyWritableStrides), maxStrides, linearlyWritableStrides);
    916914    }
    917915    Value * haveStrides = kb->CreateICmpUGT(linearlyWritableStrides, kb->getSize(0));
Note: See TracChangeset for help on using the changeset viewer.