src/mem/cache/tags/dueling.test.cc
/**
 * Test whether dueler provides correct sampling functionality and assigns
 * teams correctly.
 */
Test whether dueler provides correct sampling functionality and assigns
teams correctly.
Test whether dueler provides correct sampling functionality and assigns teams correctly .
TEST(DuelerTest, SetSample)
{
    const int num_sampled_ids = 3;
    bool team;
    Dueler dueler;
    for (int id = 0; id < 64; id++) {
        ASSERT_FALSE(dueler.isSample(1ULL << id, team));
    }
    team = false;
    for (int id = 0; id < num_sampled_ids; id++) {
        team = !team;
        dueler.setSample(1ULL << id, team);
    }
    bool expected_team = false;
    for (int id = 0; id < 64; id++) {
        expected_team = !expected_team;
        const bool is_sample = dueler.isSample(1ULL << id, team);
        if (id < num_sampled_ids) {
            ASSERT_TRUE(is_sample);
            ASSERT_EQ(team, expected_team);
        } else {
            ASSERT_FALSE(is_sample);
        }
    }
}
TEST ( DuelerTest , SetSample ) { const int num_sampled_ids = 3 ; bool team ; Dueler dueler ; for ( int id = 0 ; id < 64 ; id ++ ) { ASSERT_FALSE ( dueler . isSample ( 1ULL << id , team ) ) ; } team = false ; for ( int id = 0 ; id < num_sampled_ids ; id ++ ) { team = ! team ; dueler . setSample ( 1ULL << id , team ) ; } bool expected_team = false ; for ( int id = 0 ; id < 64 ; id ++ ) { expected_team = ! expected_team ; const bool is_sample = dueler . isSample ( 1ULL << id , team ) ; if ( id < num_sampled_ids ) { ASSERT_TRUE ( is_sample ) ; ASSERT_EQ ( team , expected_team ) ; } else { ASSERT_FALSE ( is_sample ) ; } } }
Test whether dueler provides correct sampling functionality and assigns
 teams correctly.
Test whether dueler provides correct sampling functionality and assigns teams correctly .
// Initially nobody is sampled // Mark the first num_sampled_ids as samples and assign alternating teams // Make sure that only the entries marked as samples previously are samples