 Timestamp:
 May 9, 2017, 9:57:18 AM (2 years ago)
 Location:
 icGREP/icgrepdevel/icgrep/kernels
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

icGREP/icgrepdevel/icgrep/kernels/interface.cpp
r5436 r5438 40 40 } 41 41 42 unsigned ProcessingRate::calculateRatio(unsigned referenceItems, bool doFinal) const { 43 if (mKind == ProcessingRate::ProcessingRateKind::FixedRatio  mKind == ProcessingRate::ProcessingRateKind::MaxRatio) { 44 if (mRatioNumerator == mRatioDenominator) { 45 return referenceItems; 46 } 47 unsigned strmItems = referenceItems * mRatioNumerator; 48 return (strmItems + mRatioDenominator  1) / mRatioDenominator; 49 } 50 if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) { 51 return ((referenceItems + mRatioDenominator  1) / mRatioDenominator) * mRatioDenominator; 52 } 53 if (mKind == ProcessingRate::ProcessingRateKind::Add1) { 54 return doFinal ? referenceItems + 1 : referenceItems; 55 } 56 report_fatal_error("Processing rate calculation attempted for variable or unknown rate."); 57 } 58 42 59 Value * ProcessingRate::CreateRatioCalculation(IDISA::IDISA_Builder * const b, Value * referenceItems, Value * doFinal) const { 43 60 if (mKind == ProcessingRate::ProcessingRateKind::FixedRatio  mKind == ProcessingRate::ProcessingRateKind::MaxRatio) { … … 65 82 return referenceItems; 66 83 } 67 return nullptr; 84 report_fatal_error("Processing rate calculation attempted for variable or unknown rate."); 85 } 86 87 unsigned ProcessingRate::calculateMaxReferenceItems(unsigned outputItems, bool doFinal) const { 88 if (mKind == ProcessingRate::ProcessingRateKind::FixedRatio) { 89 if (mRatioNumerator == mRatioDenominator) { 90 return outputItems; 91 } 92 return (outputItems / mRatioNumerator) * mRatioDenominator; 93 } 94 if (mKind == ProcessingRate::ProcessingRateKind::RoundUp) { 95 return (outputItems / mRatioDenominator) * mRatioDenominator; 96 } 97 if (mKind == ProcessingRate::ProcessingRateKind::Add1) { 98 return doFinal ? outputItems  1 : outputItems; 99 } 100 report_fatal_error("Inverse processing rate calculation attempted for variable or unknown rate."); 68 101 } 69 102 … … 90 123 return b>CreateSub(outputItems, ConstantInt::get(T, 1)); 91 124 } 92 re turn nullptr;125 report_fatal_error("Inverse processing rate calculation attempted for variable or unknown rate."); 93 126 } 94 127 
icGREP/icgrepdevel/icgrep/kernels/interface.h
r5436 r5438 16 16 // Processing rate attributes are required for all stream set bindings for a kernel. 17 17 // These attributes describe the number of items that are processed or produced as 18 // a ratio in comparison to the principal input stream set (or the principal output19 // stream set if there is no input.18 // a ratio in comparison to a reference stream set, normally the principal input stream set 19 // by default (or the principal output stream set if there is no input). 20 20 // 21 21 // The default ratio is FixedRatio(1) which means that there is one item processed or 22 // produced for every item of the principal input or outputstream.23 // FixedRatio(m, n) means that for every group of n items of the principalstream,22 // produced for every item of the reference stream. 23 // FixedRatio(m, n) means that for every group of n items of the refrence stream, 24 24 // there are m items in the output stream (rounding up). 25 25 // 26 26 // Kernels which produce a variable number of items use MaxRatio(n), for a maximum 27 27 // of n items produced or consumed per principal input or output item. MaxRatio(m, n) 28 // means there are at most m items for every n items of the principalstream.28 // means there are at most m items for every n items of the reference stream. 29 29 // 30 30 // RoundUpToMultiple(n) means that number of items produced is the same as the 31 // number of inputitems, rounded up to an exact multiple of n.31 // number of reference items, rounded up to an exact multiple of n. 32 32 // 33 33 … … 39 39 bool isExact() const {return (mKind == ProcessingRateKind::FixedRatio)(mKind == ProcessingRateKind::RoundUp)(mKind == ProcessingRateKind::Add1) ;} 40 40 bool isUnknownRate() const { return mKind == ProcessingRateKind::Unknown; } 41 llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * const b, llvm::Value * principalInputItems, llvm::Value * doFinal = nullptr) const; 42 llvm::Value * CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * const b, llvm::Value * outputItems, llvm::Value * doFinal) const; 43 friend ProcessingRate FixedRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet); 44 friend ProcessingRate MaxRatio(unsigned strmItemsPer, unsigned perPrincipalInputItems, std::string && referenceStreamSet); 41 unsigned calculateRatio(unsigned referenceItems, bool doFinal = false) const; 42 unsigned calculateMaxReferenceItems(unsigned outputItems, bool doFinal = false) const; 43 llvm::Value * CreateRatioCalculation(IDISA::IDISA_Builder * const b, llvm::Value * referenceItems, llvm::Value * doFinal = nullptr) const; 44 llvm::Value * CreateMaxReferenceItemsCalculation(IDISA::IDISA_Builder * const b, llvm::Value * outputItems, llvm::Value * doFinal = nullptr) const; 45 friend ProcessingRate FixedRatio(unsigned strmItems, unsigned referenceItems, std::string && referenceStreamSet); 46 friend ProcessingRate MaxRatio(unsigned strmItems, unsigned referenceItems, std::string && referenceStreamSet); 45 47 friend ProcessingRate RoundUpToMultiple(unsigned itemMultiple, std::string && referenceStreamSet); 46 48 friend ProcessingRate Add1(std::string && referenceStreamSet); … … 59 61 }; 60 62 61 ProcessingRate FixedRatio(unsigned strmItems Per, unsigned perPrincipalInputItems = 1, std::string && referenceStreamSet = "");62 ProcessingRate MaxRatio(unsigned strmItems Per, unsigned perPrincipalInputItems = 1, std::string && referenceStreamSet = "");63 ProcessingRate FixedRatio(unsigned strmItems, unsigned referenceItems = 1, std::string && referenceStreamSet = ""); 64 ProcessingRate MaxRatio(unsigned strmItems, unsigned referenceItems = 1, std::string && referenceStreamSet = ""); 63 65 ProcessingRate RoundUpToMultiple(unsigned itemMultiple, std::string &&referenceStreamSet = ""); 64 66 ProcessingRate Add1(std::string && referenceStreamSet = "");
Note: See TracChangeset
for help on using the changeset viewer.