mem-cache: Fix non-bijective function in Skewed caches
The hash() function must be bijective for the skewed caches to work, however when the hashing is done on top of a one-bit address, the MSB and LSB refer to the same bit, and therefore their xor will always be zero. This patch adds a fatal error to not allow the user to set an invalid value for the number of sets that would generate that bug. As a side note, the missing header for the bitfields functions has been added. Change-Id: I35a03ac5fdc4debb091f7f2db5db33568d0b0021 Reviewed-on: https://gem5-review.googlesource.com/12724 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
b3ef93166f
commit
b53dd6d12e
5
src/mem/cache/tags/skewed_assoc.cc
vendored
5
src/mem/cache/tags/skewed_assoc.cc
vendored
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/bitfield.hh"
|
||||
#include "base/logging.hh"
|
||||
|
||||
SkewedAssoc::SkewedAssoc(const Params *p)
|
||||
@@ -51,6 +52,10 @@ SkewedAssoc::SkewedAssoc(const Params *p)
|
||||
// skewing functions accordingly to make good use of the hashing function
|
||||
panic_if(setShift + 2 * (msbShift + 1) > 64, "Unsuported number of bits " \
|
||||
"for the skewing functions.");
|
||||
|
||||
// We must have more than two sets, otherwise the MSB and LSB are the same
|
||||
// bit, and the xor of them will always be 0
|
||||
fatal_if(numSets <= 2, "The number of sets must be greater than 2");
|
||||
}
|
||||
|
||||
Addr
|
||||
|
||||
3
src/mem/cache/tags/skewed_assoc.hh
vendored
3
src/mem/cache/tags/skewed_assoc.hh
vendored
@@ -73,6 +73,9 @@ class SkewedAssoc : public BaseSetAssoc
|
||||
* applies an XOR to the MSB and LSB, shifts all bits one bit to the right,
|
||||
* and set the result of the XOR as the new MSB.
|
||||
*
|
||||
* This function is not bijective if the address has only 1 bit, as the MSB
|
||||
* and LSB will be the same, and therefore the xor will always be 0.
|
||||
*
|
||||
* @param addr The address to be hashed.
|
||||
* @param The hashed address.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user