Ignore:
Timestamp:
Feb 18, 2017, 10:07:09 AM (2 years ago)
Author:
cameron
Message:

Refining the ProcessingRate? attribute

File:
1 edited

Legend:

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

    r5320 r5328  
    2121
    2222using namespace llvm;
     23
     24ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems) {
     25    return ProcessingRate(ProcessingRate::ProcessingRateKind::Fixed, strmItemsPer, perPrincipalInputItems);
     26}
     27
     28ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems) {
     29    return ProcessingRate(ProcessingRate::ProcessingRateKind::Max, strmItemsPer, perPrincipalInputItems);
     30}
     31
     32ProcessingRate RoundUpToMultiple(unsigned itemMultiple) {
     33    return ProcessingRate(ProcessingRate::ProcessingRateKind::RoundUp, itemMultiple, itemMultiple);
     34}
     35
     36ProcessingRate UnknownRate() {
     37    return ProcessingRate(ProcessingRate::ProcessingRateKind::Unknown, 0, 0);
     38}
     39
     40Value * ProcessingRate::CreateRatioCalculation(IDISA::IDISA_Builder * b, Value * principalInputItems) const {
     41    Type * T = principalInputItems->getType();
     42    if (mKind == ProcessingRate::ProcessingRateKind::Fixed || mKind == ProcessingRate::ProcessingRateKind::Max) {
     43        Value * strmItems = (ratio_numerator == 1) ? principalInputItems : b->CreateMul(principalInputItems, ConstantInt::get(T, ratio_numerator));
     44        if (ratio_denominator == 1) return strmItems;
     45        return b->CreateUDiv(b->CreateAdd(ConstantInt::get(T, ratio_denominator - 1), strmItems), ConstantInt::get(T, ratio_denominator));
     46    }
     47    if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) {
     48        Constant * multiple = ConstantInt::get(T, ratio_denominator);
     49        Constant * multipleLess1 = ConstantInt::get(T, ratio_denominator - 1);
     50        return b->CreateMul(b->CreateUDiv(b->CreateAdd(principalInputItems, multipleLess1), multiple), multiple);
     51    }
     52    return nullptr;
     53}
     54
    2355
    2456void KernelInterface::addKernelDeclarations(Module * client) {
Note: See TracChangeset for help on using the changeset viewer.