mem-cache: Store totalBlockCount directly in MaxCapacity pp
In this way we actually need to store one unsigned integer instead of two. We also won't need to recompute the total number of cache blocks whenever we will adapt this policy to be dynamically modified Change-Id: Ia8cf906539d1891b6cdb821f2a74628127dc68c6 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
@@ -52,8 +52,9 @@ namespace partitioning_policy
|
||||
|
||||
MaxCapacityPartitioningPolicy::MaxCapacityPartitioningPolicy
|
||||
(const MaxCapacityPartitioningPolicyParams ¶ms):
|
||||
BasePartitioningPolicy(params), cacheSize(params.cache_size),
|
||||
blkSize(params.blk_size), partitionIDs(params.partition_ids),
|
||||
BasePartitioningPolicy(params),
|
||||
totalBlockCount(params.cache_size / params.blk_size),
|
||||
partitionIDs(params.partition_ids),
|
||||
capacities(params.capacities)
|
||||
{
|
||||
// check if ids and capacities vectors are the same length
|
||||
@@ -62,9 +63,6 @@ MaxCapacityPartitioningPolicy::MaxCapacityPartitioningPolicy
|
||||
"capacities arrays are not equal lengths");
|
||||
}
|
||||
|
||||
// calculate total cache block count to use when creating allocation maps
|
||||
const uint64_t total_block_cnt = this->cacheSize / this->blkSize;
|
||||
|
||||
// check allocations and create map
|
||||
for (auto i = 0; i < this->partitionIDs.size(); i++) {
|
||||
const uint64_t partition_id = this->partitionIDs[i];
|
||||
@@ -77,13 +75,13 @@ MaxCapacityPartitioningPolicy::MaxCapacityPartitioningPolicy
|
||||
cap_frac);
|
||||
}
|
||||
|
||||
const uint64_t allocated_block_cnt = cap_frac * total_block_cnt;
|
||||
const uint64_t allocated_block_cnt = cap_frac * totalBlockCount;
|
||||
partitionIdMaxCapacity.emplace(partition_id, allocated_block_cnt);
|
||||
|
||||
DPRINTF(PartitionPolicy, "Configured MaxCapacity Partitioning Policy "
|
||||
"for PartitionID: %d to use portion of size %f (%d cache blocks "
|
||||
"of %d total)\n", partition_id, cap_frac, allocated_block_cnt,
|
||||
total_block_cnt);
|
||||
totalBlockCount);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,14 +81,9 @@ class MaxCapacityPartitioningPolicy : public BasePartitioningPolicy
|
||||
|
||||
private:
|
||||
/**
|
||||
* Cache size in number of bytes
|
||||
* Total number of cache blocks
|
||||
*/
|
||||
const uint64_t cacheSize;
|
||||
|
||||
/**
|
||||
* Cache block size in number of bytes
|
||||
*/
|
||||
const uint64_t blkSize;
|
||||
const uint64_t totalBlockCount;
|
||||
|
||||
/**
|
||||
* Vector of partitionIDs the policy operates on
|
||||
|
||||
Reference in New Issue
Block a user