 Timestamp:
 May 3, 2017, 7:56:21 PM (2 years ago)
 Location:
 icGREP/icgrepdevel/icgrep/kernels
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/kernels/interface.cpp
r5431 r5433 20 20 using namespace llvm; 21 21 22 ProcessingRate FixedRatio(unsigned strmItems Per, unsigned perPrincipalInputItems, std::string && referenceStreamSet) {23 return ProcessingRate(ProcessingRate::ProcessingRateKind::Fixed , strmItemsPer, perPrincipalInputItems, std::move(referenceStreamSet));22 ProcessingRate FixedRatio(unsigned strmItems, unsigned referenceItems, std::string && referenceStreamSet) { 23 return ProcessingRate(ProcessingRate::ProcessingRateKind::FixedRatio, strmItems, referenceItems, std::move(referenceStreamSet)); 24 24 } 25 25 26 ProcessingRate MaxRatio(unsigned strmItems Per, unsigned perPrincipalInputItems, std::string && referenceStreamSet) {27 return ProcessingRate(ProcessingRate::ProcessingRateKind::Max , strmItemsPer, perPrincipalInputItems, std::move(referenceStreamSet));26 ProcessingRate MaxRatio(unsigned strmItems, unsigned referenceItems, std::string && referenceStreamSet) { 27 return ProcessingRate(ProcessingRate::ProcessingRateKind::MaxRatio, strmItems, referenceItems, std::move(referenceStreamSet)); 28 28 } 29 29 … … 40 40 } 41 41 42 Value * ProcessingRate::CreateRatioCalculation(IDISA::IDISA_Builder * b, Value * principalInputItems, Value * doFinal) const {43 if (mKind == ProcessingRate::ProcessingRateKind::Fixed  mKind == ProcessingRate::ProcessingRateKind::Max) {44 if (mRatioNumerator == 1) {45 return principalInputItems;42 Value * ProcessingRate::CreateRatioCalculation(IDISA::IDISA_Builder * b, Value * referenceItems, Value * doFinal) const { 43 if (mKind == ProcessingRate::ProcessingRateKind::FixedRatio  mKind == ProcessingRate::ProcessingRateKind::MaxRatio) { 44 if (mRatioNumerator == mRatioDenominator) { 45 return referenceItems; 46 46 } 47 Type * const T = principalInputItems>getType();47 Type * const T = referenceItems>getType(); 48 48 Constant * const numerator = ConstantInt::get(T, mRatioNumerator); 49 49 Constant * const denominator = ConstantInt::get(T, mRatioDenominator); 50 50 Constant * const denominatorLess1 = ConstantInt::get(T, mRatioDenominator  1); 51 Value * strmItems = b>CreateMul( principalInputItems, numerator);51 Value * strmItems = b>CreateMul(referenceItems, numerator); 52 52 return b>CreateUDiv(b>CreateAdd(denominatorLess1, strmItems), denominator); 53 53 } 54 54 if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) { 55 Type * const T = principalInputItems>getType();55 Type * const T = referenceItems>getType(); 56 56 Constant * const denominator = ConstantInt::get(T, mRatioDenominator); 57 57 Constant * const denominatorLess1 = ConstantInt::get(T, mRatioDenominator  1); 58 return b>CreateMul(b>CreateUDiv(b>CreateAdd( principalInputItems, denominatorLess1), denominator), denominator);58 return b>CreateMul(b>CreateUDiv(b>CreateAdd(referenceItems, denominatorLess1), denominator), denominator); 59 59 } 60 60 if (mKind == ProcessingRate::ProcessingRateKind::Add1) { 61 61 if (doFinal) { 62 Type * const T = principalInputItems>getType();63 principalInputItems = b>CreateAdd(principalInputItems, b>CreateZExt(doFinal, T));62 Type * const T = referenceItems>getType(); 63 referenceItems = b>CreateAdd(referenceItems, b>CreateZExt(doFinal, T)); 64 64 } 65 return principalInputItems; 65 return referenceItems; 66 } 67 return nullptr; 68 } 69 70 Value * ProcessingRate::CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * b, Value * outputItems, Value * doFinal) const { 71 if (mKind == ProcessingRate::ProcessingRateKind::FixedRatio) { 72 if (mRatioNumerator == mRatioDenominator) { 73 return outputItems; 74 } 75 Type * const T = outputItems>getType(); 76 Constant * const numerator = ConstantInt::get(T, mRatioNumerator); 77 Constant * const denominator = ConstantInt::get(T, mRatioDenominator); 78 return b>CreateMul(b>CreateUDiv(outputItems, numerator), denominator); 79 } 80 if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) { 81 Type * const T = outputItems>getType(); 82 Constant * const denominator = ConstantInt::get(T, mRatioDenominator); 83 return b>CreateMul(b>CreateUDiv(outputItems, denominator), denominator); 84 } 85 if (mKind == ProcessingRate::ProcessingRateKind::Add1) { 86 Type * const T = outputItems>getType(); 87 if (doFinal) { 88 return b>CreateSub(outputItems, b>CreateZExt(doFinal, T)); 89 } 90 return b>CreateSub(outputItems, ConstantInt::get(T, 1)); 66 91 } 67 92 return nullptr; 
icGREP/icgrepdevel/icgrep/kernels/interface.h
r5431 r5433 32 32 33 33 struct ProcessingRate { 34 enum class ProcessingRateKind : uint8_t { Fixed , RoundUp, Add1, Max, Unknown };34 enum class ProcessingRateKind : uint8_t { FixedRatio, RoundUp, Add1, MaxRatio, Unknown }; 35 35 ProcessingRateKind getKind() const {return mKind;} 36 bool isExact() const {return (mKind == ProcessingRateKind::Fixed )(mKind == ProcessingRateKind::RoundUp)(mKind == ProcessingRateKind::Add1) ;}36 bool isExact() const {return (mKind == ProcessingRateKind::FixedRatio)(mKind == ProcessingRateKind::RoundUp)(mKind == ProcessingRateKind::Add1) ;} 37 37 bool isUnknown() const { return !isExact(); } 38 38 llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * b, llvm::Value * principalInputItems, llvm::Value * doFinal = nullptr) const; 39 llvm::Value * CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * b, llvm::Value * outputItems, llvm::Value * doFinal) const; 39 40 friend ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet); 40 41 friend ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet);
Note: See TracChangeset
for help on using the changeset viewer.