Changeset 5375 for icGREP


Ignore:
Timestamp:
Mar 27, 2017, 9:20:48 PM (2 years ago)
Author:
cameron
Message:

Processing rates can be defined with respect to named stream sets.

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
4 edited

Legend:

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

    r5362 r5375  
    272272        assert((fieldWidth > 0) && ((fieldWidth & (fieldWidth - 1)) == 0) && "fieldWidth must be a power of 2");
    273273        assert(mSwizzleFactor > 1 && "fieldWidth must be less than the block width");
    274         for (unsigned i = 0; i < mSwizzleSetCount; i++) {
     274        mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(mSwizzleFactor, 1), "inputSwizzle0"});
     275        mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(mSwizzleFactor, 1), "outputSwizzle0", MaxRatio(1)});
     276        addScalar(iBuilder->getBitBlockType(), "pendingSwizzleData0");
     277        for (unsigned i = 1; i < mSwizzleSetCount; i++) {
    275278            mStreamSetInputs.push_back(Binding{iBuilder->getStreamSetTy(mSwizzleFactor, 1), "inputSwizzle" + std::to_string(i)});
    276             mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(mSwizzleFactor, 1), "outputSwizzle" + std::to_string(i), MaxRatio(1)});
     279            mStreamSetOutputs.push_back(Binding{iBuilder->getStreamSetTy(mSwizzleFactor, 1), "outputSwizzle" + std::to_string(i), FixedRatio(1, 1, "outputSwizzle0")});
    277280            addScalar(iBuilder->getBitBlockType(), "pendingSwizzleData" + std::to_string(i));
    278281        }
     
    334337    for (unsigned j = 0; j < mSwizzleSetCount; j++) {
    335338        setScalarField("pendingSwizzleData" + std::to_string(j), pendingData[j]);
    336         setProducedItemCount("outputSwizzle" + std::to_string(j), produced);
    337     }
     339    }
     340    setProducedItemCount("outputSwizzle0", produced);
    338341}
    339342
     
    343346    Value * pendingOffset = getScalarField("pendingOffset");
    344347    Value * produced = iBuilder->CreateAdd(pendingOffset, getProducedItemCount("outputSwizzle0"));
    345     for (unsigned j = 0; j < mSwizzleSetCount; j++) {
    346         setProducedItemCount("outputSwizzle" + std::to_string(j), produced);
    347     }
    348 }
    349 }
     348    setProducedItemCount("outputSwizzle0", produced);
     349}
     350}
  • icGREP/icgrep-devel/icgrep/kernels/interface.cpp

    r5370 r5375  
    2222using namespace llvm;
    2323
    24 ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems) {
    25     return ProcessingRate(ProcessingRate::ProcessingRateKind::Fixed, strmItemsPer, perPrincipalInputItems);
     24ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string referenceStreamSet) {
     25    return ProcessingRate(ProcessingRate::ProcessingRateKind::Fixed, strmItemsPer, perPrincipalInputItems, referenceStreamSet);
    2626}
    2727
    28 ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems) {
    29     return ProcessingRate(ProcessingRate::ProcessingRateKind::Max, strmItemsPer, perPrincipalInputItems);
     28ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string referenceStreamSet) {
     29    return ProcessingRate(ProcessingRate::ProcessingRateKind::Max, strmItemsPer, perPrincipalInputItems, referenceStreamSet);
    3030}
    3131
    32 ProcessingRate RoundUpToMultiple(unsigned itemMultiple) {
    33     return ProcessingRate(ProcessingRate::ProcessingRateKind::RoundUp, itemMultiple, itemMultiple);
     32ProcessingRate RoundUpToMultiple(unsigned itemMultiple, std::string referenceStreamSet) {
     33    return ProcessingRate(ProcessingRate::ProcessingRateKind::RoundUp, itemMultiple, itemMultiple, referenceStreamSet);
    3434}
    3535
    36 ProcessingRate Add1() {
    37     return ProcessingRate(ProcessingRate::ProcessingRateKind::Add1, 0, 0);
     36ProcessingRate Add1(std::string referenceStreamSet) {
     37    return ProcessingRate(ProcessingRate::ProcessingRateKind::Add1, 0, 0, referenceStreamSet);
    3838}
    3939
    4040ProcessingRate UnknownRate() {
    41     return ProcessingRate(ProcessingRate::ProcessingRateKind::Unknown, 0, 0);
     41    return ProcessingRate(ProcessingRate::ProcessingRateKind::Unknown, 0, 0, "");
    4242}
    4343
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5370 r5375  
    4545    llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * b, llvm::Value * principalInputItems, llvm::Value * doFinal) const;
    4646    llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * b, llvm::Value * principalInputItems) const;
    47     friend ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems);
    48     friend ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems);
    49     friend ProcessingRate RoundUpToMultiple(unsigned itemMultiple);   
    50     friend ProcessingRate Add1();
     47    friend ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string referenceStreamSet);
     48    friend ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string referenceStreamSet);
     49    friend ProcessingRate RoundUpToMultiple(unsigned itemMultiple, std::string referenceStreamSet);   
     50    friend ProcessingRate Add1(std::string referenceStreamSet);
    5151    friend ProcessingRate UnknownRate();
     52    std::string referenceStreamSet() const { return mReferenceStreamSet;}
    5253   
    5354protected:
    54     ProcessingRate(ProcessingRateKind k, unsigned numerator, unsigned denominator)
    55     : mKind(k), ratio_numerator(numerator), ratio_denominator(denominator) {}
     55    ProcessingRate(ProcessingRateKind k, unsigned numerator, unsigned denominator, std::string referenceStreamSet)
     56    : mKind(k), ratio_numerator(numerator), ratio_denominator(denominator), mReferenceStreamSet(referenceStreamSet) {}
    5657    ProcessingRateKind mKind;
    5758    uint16_t ratio_numerator;
    5859    uint16_t ratio_denominator;
     60    std::string mReferenceStreamSet;
    5961    bool isVariableRate();
    6062};
    6163
    62 ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems = 1);
    63 ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems = 1);
    64 ProcessingRate RoundUpToMultiple(unsigned itemMultiple);
    65 ProcessingRate Add1();
     64ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems = 1, std::string referenceStreamSet = "");
     65ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems = 1, std::string referenceStreamSet = "");
     66ProcessingRate RoundUpToMultiple(unsigned itemMultiple, std::string referenceStreamSet = "");
     67ProcessingRate Add1(std::string referenceStreamSet = "");
    6668ProcessingRate UnknownRate();
    6769
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5370 r5375  
    243243    unsigned ssIdx = getStreamSetIndex(name);
    244244    if (mStreamSetInputs[ssIdx].rate.isExact()) {
    245         Value * principalItemsProcessed = getScalarField(instance, mStreamSetInputs[0].name + PROCESSED_ITEM_COUNT_SUFFIX);
     245        std::string refSet = mStreamSetInputs[ssIdx].rate.referenceStreamSet();
     246        if (refSet == "") refSet = mStreamSetInputs[0].name;
     247        Value * principalItemsProcessed = getScalarField(instance, refSet + PROCESSED_ITEM_COUNT_SUFFIX);
    246248        return mStreamSetInputs[ssIdx].rate.CreateRatioCalculation(iBuilder, principalItemsProcessed);
    247249    }
     
    252254    unsigned ssIdx = getStreamSetIndex(name);
    253255    if (mStreamSetOutputs[ssIdx].rate.isExact()) {
    254         std::string principalField = mStreamSetInputs.empty() ? mStreamSetOutputs[0].name + PRODUCED_ITEM_COUNT_SUFFIX : mStreamSetInputs[0].name + PROCESSED_ITEM_COUNT_SUFFIX;
     256        std::string refSet = mStreamSetOutputs[ssIdx].rate.referenceStreamSet();
     257        std::string principalField;
     258        if (refSet == "") {
     259            principalField = mStreamSetInputs.empty() ? mStreamSetOutputs[0].name + PRODUCED_ITEM_COUNT_SUFFIX : mStreamSetInputs[0].name + PROCESSED_ITEM_COUNT_SUFFIX;
     260        }
     261        else {
     262            unsigned pfIndex = getStreamSetIndex(refSet);
     263            if (mStreamSetInputs.size() > pfIndex && mStreamSetInputs[pfIndex].name == refSet) {
     264               principalField = refSet + PROCESSED_ITEM_COUNT_SUFFIX;
     265            }
     266            else {
     267               principalField = refSet + PRODUCED_ITEM_COUNT_SUFFIX;
     268            }
     269        }
    255270        Value * principalItemsProcessed = getScalarField(instance, principalField);
    256271        return mStreamSetOutputs[ssIdx].rate.CreateRatioCalculation(iBuilder, principalItemsProcessed, doFinal);
     
    261276Value * KernelBuilder::getProducedItemCount(Value * instance, const std::string & name) const {
    262277    unsigned ssIdx = getStreamSetIndex(name);
     278    std::string refSet = mStreamSetOutputs[ssIdx].rate.referenceStreamSet();
    263279    if (mStreamSetOutputs[ssIdx].rate.isExact()) {
    264         std::string principalField = mStreamSetInputs.empty() ? mStreamSetOutputs[0].name + PRODUCED_ITEM_COUNT_SUFFIX : mStreamSetInputs[0].name + PROCESSED_ITEM_COUNT_SUFFIX;
     280        std::string refSet = mStreamSetOutputs[ssIdx].rate.referenceStreamSet();
     281        std::string principalField;
     282        if (refSet == "") {
     283            principalField = mStreamSetInputs.empty() ? mStreamSetOutputs[0].name + PRODUCED_ITEM_COUNT_SUFFIX : mStreamSetInputs[0].name + PROCESSED_ITEM_COUNT_SUFFIX;
     284        }
     285        else {
     286            unsigned pfIndex = getStreamSetIndex(refSet);
     287            if (mStreamSetInputs.size() > pfIndex && mStreamSetInputs[pfIndex].name == refSet) {
     288               principalField = refSet + PROCESSED_ITEM_COUNT_SUFFIX;
     289            }
     290            else {
     291               principalField = refSet + PRODUCED_ITEM_COUNT_SUFFIX;
     292            }
     293        }
    265294        Value * principalItemsProcessed = getScalarField(instance, principalField);
    266295        return mStreamSetOutputs[ssIdx].rate.CreateRatioCalculation(iBuilder, principalItemsProcessed);
Note: See TracChangeset for help on using the changeset viewer.