gem5 v24.0.0.0
Loading...
Searching...
No Matches
way_pp.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 ARM Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
39
40#include <algorithm>
41
42#include "base/logging.hh"
43#include "base/trace.hh"
44#include "params/WayPartitioningPolicy.hh"
45#include "way_allocation.hh"
46
47namespace gem5
48{
49
50namespace partitioning_policy
51{
52
54 (const WayPartitioningPolicyParams &params): BasePartitioningPolicy(params)
55{
56 // get cache associativity and check it is usable for this policy
57 const auto cache_assoc = params.cache_associativity;
58 assert(cache_assoc > 0);
59
60 // iterate over all provided allocations
61 for (const auto allocation: params.allocations) {
62 const auto alloc_id = allocation->getPartitionId();
63
64 // save way allocations in policy
65 for (const auto way: allocation->getWays()) {
66
67 // check if allocations are valid
68 fatal_if(way >= cache_assoc, "Way Partitioning Policy allocation "
69 "for PartitionID: %d, Way: %d cannot be fullfiled as cache "
70 "associativity is %d", alloc_id, way, cache_assoc);
71
72 if (this->partitionIdWays[alloc_id].count(way) == 0) {
73 this->partitionIdWays[alloc_id].emplace(way);
74 } else {
75 // do not add duplicate allocation to policy and warn
76 warn("Duplicate Way Partitioning Policy allocation for "
77 "PartitionID: %d, Way: %d",
78 alloc_id, way);
79 }
80 }
81
82 // report allocation of policies
83 DPRINTF(PartitionPolicy, "Allocated %d ways in WayPartitioningPolicy "
84 "for PartitionID: %d \n", allocation->getWays().size(),
85 alloc_id);
86 }
87}
88
89void
92 const uint64_t partition_id) const
93{
94 if (// No entries to filter
95 entries.empty() ||
96 // This partition_id is not policed
97 partitionIdWays.find(partition_id) == partitionIdWays.end()) {
98 return;
99 } else {
100 const auto entries_to_remove = std::remove_if(
101 entries.begin(),
102 entries.end(),
103 [this, partition_id]
104 (ReplaceableEntry *entry)
105 {
106 return partitionIdWays.at(partition_id).find(entry->getWay())
107 == partitionIdWays.at(partition_id).end();
108 }
109 );
110
111 entries.erase(entries_to_remove, entries.end());
112 }
113}
114
115} // namespace partitioning_policy
116
117} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
A Partitioning Policy is a cache partitioning mechanism that limits the cache block allocations in a ...
Definition base_pp.hh:68
WayPartitioningPolicy(const WayPartitioningPolicyParams &params)
Definition way_pp.cc:54
std::unordered_map< uint64_t, std::unordered_set< unsigned > > partitionIdWays
Map of policied PartitionIDs and their associated cache ways.
Definition way_pp.hh:93
void filterByPartition(std::vector< ReplaceableEntry * > &entries, const uint64_t partition_id) const override
Filters the allocatable cache blocks for a memory request based on its PartitionID and policy allocat...
Definition way_pp.cc:90
STL vector class.
Definition stl.hh:37
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
const Params & params() const
#define warn(...)
Definition logging.hh:256
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0