From 3100418fb124a9fbcf0874ad7026a9cbec0e2f54 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Fri, 5 Apr 2024 10:35:41 +0100 Subject: [PATCH] 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 --- .../tags/partitioning_policies/max_capacity_pp.cc | 12 +++++------- .../tags/partitioning_policies/max_capacity_pp.hh | 9 ++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/mem/cache/tags/partitioning_policies/max_capacity_pp.cc b/src/mem/cache/tags/partitioning_policies/max_capacity_pp.cc index 35ceb13a3b..47cd085869 100644 --- a/src/mem/cache/tags/partitioning_policies/max_capacity_pp.cc +++ b/src/mem/cache/tags/partitioning_policies/max_capacity_pp.cc @@ -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); } } diff --git a/src/mem/cache/tags/partitioning_policies/max_capacity_pp.hh b/src/mem/cache/tags/partitioning_policies/max_capacity_pp.hh index ba4dadebe5..b8fe12bcdc 100644 --- a/src/mem/cache/tags/partitioning_policies/max_capacity_pp.hh +++ b/src/mem/cache/tags/partitioning_policies/max_capacity_pp.hh @@ -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