mem-cache: Define a PartitionManager to handle partitioning
This is a first step towards offloading some of the partitioning logic to the partitioning manager. We start with this patch by replacing the static readPacketPartitionId into a virtual method owned by the manager. The issue with readPacketPartitionId as of now is that it relies on the fixed PartitionFieldExtention. We want user to be able to extract the partitionId more flexibly and this requires using a SimObject Change-Id: I3bd2e81e2a97c55fc83548956fc59f422c8049a6 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
3
src/mem/cache/Cache.py
vendored
3
src/mem/cache/Cache.py
vendored
@@ -117,6 +117,9 @@ class BaseCache(ClockedObject):
|
||||
"Setting multiple policies will enforce all of them individually "
|
||||
"in order",
|
||||
)
|
||||
partitioning_manager = Param.PartitionManager(
|
||||
NULL, "Cache partitioning manager"
|
||||
)
|
||||
|
||||
compressor = Param.BaseCacheCompressor(NULL, "Cache compressor.")
|
||||
replace_expansions = Param.Bool(
|
||||
|
||||
6
src/mem/cache/base.cc
vendored
6
src/mem/cache/base.cc
vendored
@@ -58,7 +58,7 @@
|
||||
#include "mem/cache/prefetch/base.hh"
|
||||
#include "mem/cache/queue_entry.hh"
|
||||
#include "mem/cache/tags/compressed_tags.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
|
||||
#include "mem/cache/tags/super_blk.hh"
|
||||
#include "params/BaseCache.hh"
|
||||
#include "params/WriteAllocator.hh"
|
||||
@@ -87,6 +87,7 @@ BaseCache::BaseCache(const BaseCacheParams &p, unsigned blk_size)
|
||||
writeBuffer("write buffer", p.write_buffers, p.mshrs, p.name),
|
||||
tags(p.tags),
|
||||
compressor(p.compressor),
|
||||
partitionManager(p.partitioning_manager),
|
||||
prefetcher(p.prefetcher),
|
||||
writeAllocator(p.write_allocator),
|
||||
writebackClean(p.writeback_clean),
|
||||
@@ -1642,7 +1643,8 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
|
||||
}
|
||||
|
||||
// get partitionId from Packet
|
||||
const auto partition_id = partitioning_policy::readPacketPartitionID(pkt);
|
||||
const auto partition_id = partitionManager ?
|
||||
partitionManager->readPacketPartitionID(pkt) : 0;
|
||||
// Find replacement victim
|
||||
std::vector<CacheBlk*> evict_blks;
|
||||
CacheBlk *victim = tags->findVictim(addr, is_secure, blk_size_bits,
|
||||
|
||||
9
src/mem/cache/base.hh
vendored
9
src/mem/cache/base.hh
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2013, 2015-2016, 2018-2019, 2023 ARM Limited
|
||||
* Copyright (c) 2012-2013, 2015-2016, 2018-2019, 2023-2024 Arm Limited
|
||||
* All rights reserved.
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
@@ -84,6 +84,10 @@ namespace prefetch
|
||||
{
|
||||
class Base;
|
||||
}
|
||||
namespace partitioning_policy
|
||||
{
|
||||
class PartitionManager;
|
||||
}
|
||||
class MSHR;
|
||||
class RequestPort;
|
||||
class QueueEntry;
|
||||
@@ -351,6 +355,9 @@ class BaseCache : public ClockedObject
|
||||
/** Compression method being used. */
|
||||
compression::Base* compressor;
|
||||
|
||||
/** Partitioning manager */
|
||||
partitioning_policy::PartitionManager* partitionManager;
|
||||
|
||||
/** Prefetcher */
|
||||
prefetch::Base *prefetcher;
|
||||
|
||||
|
||||
4
src/mem/cache/tags/Tags.py
vendored
4
src/mem/cache/tags/Tags.py
vendored
@@ -79,6 +79,10 @@ class BaseTags(ClockedObject):
|
||||
Parent.partitioning_policies, "Partitioning policies"
|
||||
)
|
||||
|
||||
partitioning_manager = Param.PartitionManager(
|
||||
Parent.partitioning_manager, "Cache partitioning manager"
|
||||
)
|
||||
|
||||
# Set the indexing entry size as the block size
|
||||
entry_size = Param.Int(
|
||||
Parent.cache_line_size, "Indexing entry size in bytes"
|
||||
|
||||
6
src/mem/cache/tags/base.cc
vendored
6
src/mem/cache/tags/base.cc
vendored
@@ -50,7 +50,7 @@
|
||||
#include "base/types.hh"
|
||||
#include "mem/cache/replacement_policies/replaceable_entry.hh"
|
||||
#include "mem/cache/tags/indexing_policies/base.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
|
||||
#include "mem/request.hh"
|
||||
#include "sim/core.hh"
|
||||
#include "sim/sim_exit.hh"
|
||||
@@ -64,6 +64,7 @@ BaseTags::BaseTags(const Params &p)
|
||||
size(p.size), lookupLatency(p.tag_latency),
|
||||
system(p.system), indexingPolicy(p.indexing_policy),
|
||||
partitioningPolicies(p.partitioning_policies),
|
||||
partitionManager(p.partitioning_manager),
|
||||
warmupBound((p.warmup_percentage/100.0) * (p.size / p.block_size)),
|
||||
warmedUp(false), numBlocks(p.size / p.block_size),
|
||||
dataBlks(new uint8_t[p.size]), // Allocate data storage in one big chunk
|
||||
@@ -114,7 +115,8 @@ BaseTags::insertBlock(const PacketPtr pkt, CacheBlk *blk)
|
||||
stats.occupancies[requestor_id]++;
|
||||
|
||||
// Insert block with tag, src requestor id, task id and PartitionId
|
||||
const auto partition_id = partitioning_policy::readPacketPartitionID(pkt);
|
||||
const auto partition_id = partitionManager ?
|
||||
partitionManager->readPacketPartitionID(pkt) : 0;
|
||||
blk->insert(extractTag(pkt->getAddr()), pkt->isSecure(), requestor_id,
|
||||
pkt->req->taskId(), partition_id);
|
||||
|
||||
|
||||
3
src/mem/cache/tags/base.hh
vendored
3
src/mem/cache/tags/base.hh
vendored
@@ -93,6 +93,9 @@ class BaseTags : public ClockedObject
|
||||
std::vector<partitioning_policy::BasePartitioningPolicy *>
|
||||
partitioningPolicies;
|
||||
|
||||
/** Partitioning manager */
|
||||
partitioning_policy::PartitionManager *partitionManager;
|
||||
|
||||
/**
|
||||
* The number of tags that need to be touched to meet the warmup
|
||||
* percentage.
|
||||
|
||||
5
src/mem/cache/tags/base_set_assoc.hh
vendored
5
src/mem/cache/tags/base_set_assoc.hh
vendored
@@ -59,7 +59,7 @@
|
||||
#include "mem/cache/replacement_policies/replaceable_entry.hh"
|
||||
#include "mem/cache/tags/base.hh"
|
||||
#include "mem/cache/tags/indexing_policies/base.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_fields_extension.hh"
|
||||
#include "mem/cache/tags/partitioning_policies/partition_manager.hh"
|
||||
#include "mem/packet.hh"
|
||||
#include "params/BaseSetAssoc.hh"
|
||||
|
||||
@@ -207,8 +207,9 @@ class BaseSetAssoc : public BaseTags
|
||||
// Notify partitioning policies of acquisition of ownership
|
||||
for (auto & partitioning_policy : partitioningPolicies) {
|
||||
// get partitionId from Packet
|
||||
assert(partitionManager);
|
||||
const auto partitionId =
|
||||
partitioning_policy::readPacketPartitionID(pkt);
|
||||
partitionManager->readPacketPartitionID(pkt);
|
||||
partitioning_policy->notifyAcquire(partitionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# Copyright (c) 2024 ARM Limited
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2024 Arm Limited
|
||||
# All rights reserved
|
||||
#
|
||||
# The license below extends only to copyright in the software and shall
|
||||
# not be construed as granting a license to any other intellectual
|
||||
# property including but not limited to intellectual property relating
|
||||
# to a hardware implementation of the functionality of the software
|
||||
# licensed hereunder. You may use the software subject to the license
|
||||
# terms below provided that you ensure that this notice is replicated
|
||||
# unmodified and in its entirety in all distributions of the software,
|
||||
# modified or unmodified, in source code or in binary form.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
@@ -32,6 +41,12 @@ from m5.proxy import Parent
|
||||
from m5.SimObject import SimObject
|
||||
|
||||
|
||||
class PartitionManager(SimObject):
|
||||
type = "PartitionManager"
|
||||
cxx_header = "mem/cache/tags/partitioning_policies/partition_manager.hh"
|
||||
cxx_class = "gem5::partitioning_policy::PartitionManager"
|
||||
|
||||
|
||||
class BasePartitioningPolicy(SimObject):
|
||||
type = "BasePartitioningPolicy"
|
||||
cxx_header = "mem/cache/tags/partitioning_policies/base_pp.hh"
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
Import('*')
|
||||
|
||||
SimObject('PartitioningPolicies.py', sim_objects=[
|
||||
'PartitionManager',
|
||||
'BasePartitioningPolicy',
|
||||
'MaxCapacityPartitioningPolicy',
|
||||
'WayPolicyAllocation',
|
||||
|
||||
77
src/mem/cache/tags/partitioning_policies/partition_manager.hh
vendored
Normal file
77
src/mem/cache/tags/partitioning_policies/partition_manager.hh
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Arm Limited
|
||||
* All rights reserved
|
||||
*
|
||||
* The license below extends only to copyright in the software and shall
|
||||
* not be construed as granting a license to any other intellectual
|
||||
* property including but not limited to intellectual property relating
|
||||
* to a hardware implementation of the functionality of the software
|
||||
* licensed hereunder. You may use the software subject to the license
|
||||
* terms below provided that you ensure that this notice is replicated
|
||||
* unmodified and in its entirety in all distributions of the software,
|
||||
* modified or unmodified, in source code or in binary form.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__
|
||||
#define __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__
|
||||
|
||||
#include "mem/packet.hh"
|
||||
#include "params/PartitionManager.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
namespace partitioning_policy
|
||||
{
|
||||
|
||||
class PartitionManager : public SimObject
|
||||
{
|
||||
public:
|
||||
PARAMS(PartitionManager);
|
||||
PartitionManager(const Params &p)
|
||||
: SimObject(p)
|
||||
{}
|
||||
|
||||
/**
|
||||
* PartitionManager interface to retrieve PartitionID from a packet;
|
||||
* This base implementation returns zero by default.
|
||||
*
|
||||
* @param pkt pointer to packet (PacketPtr)
|
||||
* @return packet PartitionID.
|
||||
*/
|
||||
virtual uint64_t
|
||||
readPacketPartitionID(PacketPtr pkt) const
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace partitioning_policy
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
#endif // __MEM_CACHE_TAGS_PARTITIONING_MANAGER_HH__
|
||||
Reference in New Issue
Block a user