gem5
v20.1.0.0
|
Copyright (c) 2018 Inria All rights reserved. More...
#include <cstdint>
#include <memory>
#include <vector>
#include "mem/cache/replacement_policies/base.hh"
Go to the source code of this file.
Classes | |
class | TreePLRURP |
struct | TreePLRURP::TreePLRUReplData |
Tree-PLRU-specific implementation of replacement data. More... | |
Copyright (c) 2018 Inria All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer; redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution; neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Declaration of a Pseudo-Least Recently Used replacement policy. The victim is chosen using a tree of bit timestamps.
A tree contains consists of leafs that represent the direction to take when searching for the LRU entry.
Let's assume each tree contains 8 replacement data entries. For example, if these entries are named from A to H, and the tree's bits are: ____1____ 0 1 0 1 1 0 A B C D E F G H
Then the current PLRU entry is given by the sequence: 1 (get right child) -> 1 (get right child) -> 0 (get left child) -> G
When an entry is touched the bits of the parent nodes are iteratively updated to point away from it. Therefore, if entry B is touched, its parent, grandparents, etc would be updated, and we'd end up with the following tree: ____1____ 1 1 0 1 1 0 A B C D E F G H
Explanation: The parent of B must point away from it, that is, to the left child, but it is already doing so, so it is left unmodified (0). Then the grandparent must point to the right subtree, as B belongs to its left subtree (0 becomes 1). Lastly, the root must point away from the grandparent, so it is left unmodified (0).
For invalidations the process is similar to touches, but instead of pointing away, the bits point toward the entry.
Consecutive calls to instantiateEntry() use the same tree up to numLeaves. When numLeaves replacement datas have been created, a new tree is generated, and the counter is reset.
Definition in file tree_plru_rp.hh.