Nikos Nikoleris has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/70057?usp=email )
Change subject: base: Use the MSB rather than the LSB in
AddrRange:removeIntlvBits
......................................................................
base: Use the MSB rather than the LSB in AddrRange:removeIntlvBits
In many cases, the LSB (as constrained by the masks) of an interleaved
address range falls within the virtual page offset. For typical
workloads, the page offset and the least significant bits have more
entropy than the most significant bits. Consequently, removing a
bit closer to the MSB preserves bits tends to provide a more uniform
utilization of resources.
M src/base/addr_range.hh
M src/base/addr_range.test.cc
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index 11fb1cd..40545ba 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -523,17 +523,17 @@
}
// Get the LSB set from each mask
int masks_lsb[masks.size()];
int masks_msb[masks.size()];
for (unsigned int i = 0; i < masks.size(); i++) {
masks_lsb[i] = ctz64(masks[i]);
masks_msb[i] = sizeof(Addr) * 8 - clz64(masks[i]) - 1;
}
// we need to sort the list of bits we will discard as we
// discard them one by one starting.
std::sort(masks_lsb, masks_lsb + masks.size());
std::sort(masks_msb, masks_msb + masks.size());
for (unsigned int i = 0; i < masks.size(); i++) {
const int intlv_bit = masks_lsb[i];
const int intlv_bit = masks_msb[i];
if (intlv_bit > 0) {
// on every iteration we remove one bit from the input
// address, and therefore the lowest invtl_bit has
@@ -562,15 +562,15 @@
}
// Get the LSB set from each mask
int masks_lsb[masks.size()];
int masks_msb[masks.size()];
for (unsigned int i = 0; i < masks.size(); i++) {
masks_lsb[i] = ctz64(masks[i]);
masks_msb[i] = sizeof(Addr) * CHAR_BIT - clz64(masks[i]) - 1;
}
// Add bits one-by-one from the LSB side.
std::sort(masks_lsb, masks_lsb + masks.size());
std::sort(masks_msb, masks_msb + masks.size());
for (unsigned int i = 0; i < masks.size(); i++) {
const int intlv_bit = masks_lsb[i];
const int intlv_bit = masks_msb[i];
if (intlv_bit > 0) {
// on every iteration we add one bit from the input
// address, but the lowest invtl_bit in the iteration is
@@ -583,7 +583,7 @@
}
for (unsigned int i = 0; i < masks.size(); i++) {
const int lsb = ctz64(masks[i]);
const int lsb = sizeof(Addr) * CHAR_BIT - clz64(masks[i]) - 1;
const Addr intlv_bit = bits(intlvMatch, i);
// Calculate the mask ignoring the LSB
const Addr masked = a & masks[i] & ~(1 << lsb);
diff --git a/src/base/addr_range.test.cc b/src/base/addr_range.test.cc
index 1e86154..bf7d2f7 100644
--- a/src/base/addr_range.test.cc
+++ b/src/base/addr_range.test.cc
@@ -743,16 +743,17 @@
uint8_t intlv_match = 1;
AddrRange r(start, end, masks, intlv_match);
Addr input = (1 << 10) | (1 << 9) | (1 << 3);
/*
/*
* The bit, formally at position 9, is now at 7.
* The bit, previously at position 10, is now at 9 and the bit
* previously at position 9, is now at 8 and bit 3 has been discarded.
*/
EXPECT_EQ((1 << 9) | (1 << 8), output);
/*
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/70057?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I361d8130d080a1be23f85de12afef0432efcd11e
Gerrit-Change-Number: 70057
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris nikos.nikoleris@arm.com