Ignore:
Timestamp:
Mar 21, 2017, 11:55:00 AM (2 years ago)
Author:
xuedongx
Message:

Add1 processing rate; pablo Count only up to EOFbit

File:
1 edited

Legend:

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

    r5351 r5370  
    3434}
    3535
     36ProcessingRate Add1() {
     37    return ProcessingRate(ProcessingRate::ProcessingRateKind::Add1, 0, 0);
     38}
     39
    3640ProcessingRate UnknownRate() {
    3741    return ProcessingRate(ProcessingRate::ProcessingRateKind::Unknown, 0, 0);
     42}
     43
     44Value * ProcessingRate::CreateRatioCalculation(IDISA::IDISA_Builder * b, Value * principalInputItems, Value * doFinal) const {
     45    Type * T = principalInputItems->getType();
     46    if (mKind == ProcessingRate::ProcessingRateKind::Fixed || mKind == ProcessingRate::ProcessingRateKind::Max) {
     47        Value * strmItems = (ratio_numerator == 1) ? principalInputItems : b->CreateMul(principalInputItems, ConstantInt::get(T, ratio_numerator));
     48        if (ratio_denominator == 1) return strmItems;
     49        return b->CreateUDiv(b->CreateAdd(ConstantInt::get(T, ratio_denominator - 1), strmItems), ConstantInt::get(T, ratio_denominator));
     50    }
     51    if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) {
     52        Constant * multiple = ConstantInt::get(T, ratio_denominator);
     53        Constant * multipleLess1 = ConstantInt::get(T, ratio_denominator - 1);
     54        return b->CreateMul(b->CreateUDiv(b->CreateAdd(principalInputItems, multipleLess1), multiple), multiple);
     55    }
     56    if (mKind == ProcessingRate::ProcessingRateKind::Add1) {
     57        return b->CreateAdd(principalInputItems, b->CreateZExt(doFinal, principalInputItems->getType()));
     58    }
     59    return nullptr;
    3860}
    3961
     
    4971        Constant * multipleLess1 = ConstantInt::get(T, ratio_denominator - 1);
    5072        return b->CreateMul(b->CreateUDiv(b->CreateAdd(principalInputItems, multipleLess1), multiple), multiple);
     73    }
     74    if (mKind == ProcessingRate::ProcessingRateKind::Add1) {
     75        return principalInputItems;
    5176    }
    5277    return nullptr;
Note: See TracChangeset for help on using the changeset viewer.