const unsigned offsetBits;
/** The filter itself. */
- std::vector<SatCounter> filter;
+ std::vector<SatCounter8> filter;
/** Number of bits needed to represent the size of the filter. */
const int sizeBits;
*/
Base(const BloomFilterBaseParams &p)
: SimObject(p), offsetBits(p.offset_bits),
- filter(p.size, SatCounter(p.num_bits)),
+ filter(p.size, SatCounter8(p.num_bits)),
sizeBits(floorLog2(p.size)), setThreshold(p.threshold)
{
clear();
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019, 2020 Inria
* All rights reserved
*
* Redistribution and use in source and binary forms, with or without
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter(bits);
+ SatCounter8 counter(bits);
for (int i = 0; i < 2*max_value; i++) {
counter++;
TEST(SatCounterTest, MinimumValue)
{
const unsigned bits = 3;
- SatCounter counter(bits);
+ SatCounter8 counter(bits);
for (int i = 0; i < 2; i++) {
counter--;
{
const unsigned bits = 3;
const unsigned initial_value = 4;
- SatCounter counter(bits, initial_value);
+ SatCounter8 counter(bits, initial_value);
ASSERT_EQ(counter, initial_value);
counter++;
counter.reset();
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter(bits);
+ SatCounter8 counter(bits);
ASSERT_FALSE(counter.isSaturated());
for (double value = 0.0; value <= max_value; value++, counter++) {
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter(bits);
+ SatCounter8 counter(bits);
counter++;
ASSERT_FALSE(counter.isSaturated());
TEST(SatCounterTest, IntComparison)
{
const unsigned bits = 3;
- SatCounter counter(bits);
+ SatCounter8 counter(bits);
int value = 0;
ASSERT_EQ(counter++, value++);
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
const unsigned initial_value = 1;
- SatCounter counter(bits, initial_value);
- SatCounter other(bits, initial_value);
+ SatCounter8 counter(bits, initial_value);
+ SatCounter8 other(bits, initial_value);
// The saturated shift value is just enough to saturate, since greater
// values could generate undefined behavior
- SatCounter saturated_counter(bits, bits);
+ SatCounter8 saturated_counter(bits, bits);
int value = initial_value;
// Test random shifts
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter_pre(bits);
- SatCounter counter_post(bits);
+ SatCounter8 counter_pre(bits);
+ SatCounter8 counter_post(bits);
for (int i = 0; i < 2*max_value; i++) {
counter_post++;
- SatCounter value_pre = ++counter_pre;
+ SatCounter8 value_pre = ++counter_pre;
ASSERT_EQ(counter_post, value_pre);
}
for (int i = 0; i < 2*max_value; i++) {
counter_post--;
- SatCounter value_pre = --counter_pre;
+ SatCounter8 value_pre = --counter_pre;
ASSERT_EQ(counter_post, value_pre);
}
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
const unsigned initial_value = 1;
- SatCounter counter(bits, initial_value);
- SatCounter deep_copy(1);
- SatCounter counter_copy(2);
+ SatCounter8 counter(bits, initial_value);
+ SatCounter8 deep_copy(1);
+ SatCounter8 counter_copy(2);
// Increase counter value so that we can check if the inner counter is
// being copied
counter++;
// Copy counter using both the copy constructor and the copy assignment
- SatCounter counter_copy_constructor(counter);
+ SatCounter8 counter_copy_constructor(counter);
deep_copy = counter_copy = counter;
ASSERT_EQ(counter_copy_constructor, initial_value + 1);
ASSERT_EQ(counter_copy, initial_value + 1);
ASSERT_EQ(deep_copy, initial_value);
// Now check move
- SatCounter counter_move_constructor(std::move(counter));
+ SatCounter8 counter_move_constructor(std::move(counter));
ASSERT_EQ(counter, 0);
ASSERT_EQ(counter_move_constructor, initial_value + 1);
- SatCounter counter_move(bits);
+ SatCounter8 counter_move(bits);
counter_move = std::move(counter_move_constructor);
ASSERT_EQ(counter_move_constructor, 0);
ASSERT_EQ(counter_move, initial_value + 1);
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter(bits);
- SatCounter other(bits, 2);
- SatCounter saturated_counter(bits, max_value);
+ SatCounter8 counter(bits);
+ SatCounter8 other(bits, 2);
+ SatCounter8 saturated_counter(bits, max_value);
int value = 0;
// Test add-assignment for a few random values and then saturate
{
const unsigned bits = 3;
const unsigned max_value = (1 << bits) - 1;
- SatCounter counter(bits, max_value);
+ SatCounter8 counter(bits, max_value);
int value = max_value;
// Test add-assignment for a few negative values until zero is reached
localPredictorSize(params.localPredictorSize),
localCtrBits(params.localCtrBits),
localPredictorSets(localPredictorSize / localCtrBits),
- localCtrs(localPredictorSets, SatCounter(localCtrBits)),
+ localCtrs(localPredictorSets, SatCounter8(localCtrBits)),
indexMask(localPredictorSets - 1)
{
if (!isPowerOf2(localPredictorSize)) {
const unsigned localPredictorSets;
/** Array of counters that make up the local predictor. */
- std::vector<SatCounter> localCtrs;
+ std::vector<SatCounter8> localCtrs;
/** Mask to get index bits. */
const unsigned indexMask;
choiceCtrBits(params.choiceCtrBits),
globalPredictorSize(params.globalPredictorSize),
globalCtrBits(params.globalCtrBits),
- choiceCounters(choicePredictorSize, SatCounter(choiceCtrBits)),
- takenCounters(globalPredictorSize, SatCounter(globalCtrBits)),
- notTakenCounters(globalPredictorSize, SatCounter(globalCtrBits))
+ choiceCounters(choicePredictorSize, SatCounter8(choiceCtrBits)),
+ takenCounters(globalPredictorSize, SatCounter8(globalCtrBits)),
+ notTakenCounters(globalPredictorSize, SatCounter8(globalCtrBits))
{
if (!isPowerOf2(choicePredictorSize))
fatal("Invalid choice predictor size.\n");
unsigned globalHistoryMask;
// choice predictors
- std::vector<SatCounter> choiceCounters;
+ std::vector<SatCounter8> choiceCounters;
// taken direction predictors
- std::vector<SatCounter> takenCounters;
+ std::vector<SatCounter8> takenCounters;
// not-taken direction predictors
- std::vector<SatCounter> notTakenCounters;
+ std::vector<SatCounter8> notTakenCounters;
unsigned choiceThreshold;
unsigned takenThreshold;
: BPredUnit(params),
localPredictorSize(params.localPredictorSize),
localCtrBits(params.localCtrBits),
- localCtrs(localPredictorSize, SatCounter(localCtrBits)),
+ localCtrs(localPredictorSize, SatCounter8(localCtrBits)),
localHistoryTableSize(params.localHistoryTableSize),
localHistoryBits(ceilLog2(params.localPredictorSize)),
globalPredictorSize(params.globalPredictorSize),
globalCtrBits(params.globalCtrBits),
- globalCtrs(globalPredictorSize, SatCounter(globalCtrBits)),
+ globalCtrs(globalPredictorSize, SatCounter8(globalCtrBits)),
globalHistory(params.numThreads, 0),
globalHistoryBits(
ceilLog2(params.globalPredictorSize) >
ceilLog2(params.choicePredictorSize)),
choicePredictorSize(params.choicePredictorSize),
choiceCtrBits(params.choiceCtrBits),
- choiceCtrs(choicePredictorSize, SatCounter(choiceCtrBits))
+ choiceCtrs(choicePredictorSize, SatCounter8(choiceCtrBits))
{
if (!isPowerOf2(localPredictorSize)) {
fatal("Invalid local predictor size!\n");
unsigned localCtrBits;
/** Local counters. */
- std::vector<SatCounter> localCtrs;
+ std::vector<SatCounter8> localCtrs;
/** Array of local history table entries. */
std::vector<unsigned> localHistoryTable;
unsigned globalCtrBits;
/** Array of counters that make up the global predictor. */
- std::vector<SatCounter> globalCtrs;
+ std::vector<SatCounter8> globalCtrs;
/** Global history register. Contains as much history as specified by
* globalHistoryBits. Actual number of bits used is determined by
unsigned choiceCtrBits;
/** Array of counters that make up the choice predictor. */
- std::vector<SatCounter> choiceCtrs;
+ std::vector<SatCounter8> choiceCtrs;
/** Thresholds for the counter value; above the threshold is taken,
* equal to or below the threshold is not taken.
/** Shift detected */
int shift;
/** Confidence counter of the indirect fields */
- SatCounter indirectCounter;
+ SatCounter8 indirectCounter;
/**
* This variable is set to indicate that there has been at least one
* match with the current index value. This information is later used
/** Address Mapping entry, holds an address and a confidence counter */
struct AddressMapping {
Addr address;
- SatCounter counter;
+ SatCounter8 counter;
AddressMapping(unsigned bits) : address(0), counter(bits)
{}
};
/** stride in a page in blkSize increments */
stride_t stride;
/** Saturating counter */
- SatCounter counter;
+ SatCounter8 counter;
PatternStrideEntry(unsigned bits) : stride(0), counter(bits)
{}
};
/** group of stides */
std::vector<PatternStrideEntry> strideEntries;
/** use counter, used by SPPv2 */
- SatCounter counter;
+ SatCounter8 counter;
PatternEntry(size_t num_strides, unsigned counter_bits)
: TaggedEntry(), strideEntries(num_strides, counter_bits),
counter(counter_bits)
/** Sequence entry data type */
struct SequenceEntry {
/** 2-bit confidence counter */
- SatCounter counter;
+ SatCounter8 counter;
/** Offset, in cache lines, within the spatial region */
unsigned int offset;
/** Intearleaving position on the global access sequence */
namespace Prefetcher {
-Stride::StrideEntry::StrideEntry(const SatCounter& init_confidence)
+Stride::StrideEntry::StrideEntry(const SatCounter8& init_confidence)
: TaggedEntry(), confidence(init_confidence)
{
invalidate();
{
protected:
/** Initial confidence counter value for the pc tables. */
- const SatCounter initConfidence;
+ const SatCounter8 initConfidence;
/** Confidence threshold for prefetch generation. */
const double threshConf;
/** Tagged by hashed PCs. */
struct StrideEntry : public TaggedEntry
{
- StrideEntry(const SatCounter& init_confidence);
+ StrideEntry(const SatCounter8& init_confidence);
void invalidate() override;
Addr lastAddr;
int stride;
- SatCounter confidence;
+ SatCounter8 confidence;
};
typedef AssociativeSet<StrideEntry> PCTable;
std::unordered_map<int, PCTable> pcTables;
* max_RRPV-1 -> long re-rereference interval
* max_RRPV -> distant re-rereference interval
*/
- SatCounter rrpv;
+ SatCounter8 rrpv;
/** Whether the entry is valid. */
bool valid;