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:
Giacomo Travaglini
2024-04-05 10:35:41 +01:00
parent e17875b7c7
commit 3100418fb1
2 changed files with 7 additions and 14 deletions

View File

@@ -52,8 +52,9 @@ namespace partitioning_policy
MaxCapacityPartitioningPolicy::MaxCapacityPartitioningPolicy
(const MaxCapacityPartitioningPolicyParams &params):
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);
}
}

View File

@@ -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