[apps/shared] Add static assert for cache steps

Change-Id: I77498775b4caf3d97522219d2a7c979601b985e8
This commit is contained in:
Hugo Saint-Vignes
2020-10-15 16:25:11 +02:00
committed by Émilie Feral
parent 4acbf3346b
commit 5339d9e7b4

View File

@@ -64,6 +64,8 @@ void ContinuousFunctionCache::ComputeNonCartesianSteps(float * tStep, float * tC
const int numberOfCacheablePoints = k_sizeOfCache / 2;
const int numberOfWholeSteps = static_cast<int>(Graph::GraphView::k_graphStepDenominator);
static_assert(numberOfCacheablePoints % numberOfWholeSteps == 0, "numberOfCacheablePoints should be a multiple of numberOfWholeSteps for optimal caching");
const int multiple = numberOfCacheablePoints / numberOfWholeSteps;
static_assert(multiple && !(multiple & (multiple - 1)), "multiple should be a power of 2 for optimal caching");
/* Define cacheStep such that every whole graph steps are equally divided
* For instance, with :
* graphStepDenominator = 10.1
@@ -72,7 +74,7 @@ void ContinuousFunctionCache::ComputeNonCartesianSteps(float * tStep, float * tC
* step1 step2 step10 step11
* There are 11 steps, the first 10 are whole and have an equal size (tStep).
* There are 16 cache points in the first 10 steps, 160 total cache points. */
*tCacheStep = *tStep * numberOfWholeSteps / numberOfCacheablePoints;
*tCacheStep = *tStep / multiple;
}
// private