Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into map_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
klingaard committed Apr 24, 2024
2 parents 966dcce + 000826f commit 867559c
Show file tree
Hide file tree
Showing 16 changed files with 439 additions and 105 deletions.
3 changes: 2 additions & 1 deletion scripts/render_recipe_for_platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ echo "Rendering recipe in $PWD/conda.recipe"
# from 'conda render'
export SYSTEM_DEFAULTWORKINGDIRECTORY="$PWD"


# Make sure to have conda-forge channel to resolve dependencies
conda config --add channels conda-forge
# Render the recipe into a fully-resolved yaml file
(set -x; conda render -m "$variant_file" --file "$rendered_output" conda.recipe)

Expand Down
83 changes: 83 additions & 0 deletions sparta/cache/LRUReplacement.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// <LRUReplacement.hpp> -*- C++ -*-

//!
//! \file LRUReplacement.hpp
//! \brief Provides a simple true LRU implementation
//!

#pragma once

#include <vector>
#include <list>

#include "ReplacementIF.hpp"

namespace sparta::cache
{
// This class models true LRU with an std::list of way indices. The head of the list is LRU, and
// the tail is MRU. An std::vector of iterators to the list is used to provide constant-time
// index -> iterator lookup. A way is placed at LRU or MRU by moving its respective iterator to
// the beginning or end of the list.
class LRUReplacement : public ReplacementIF
{
public:
explicit LRUReplacement(const uint32_t num_ways) : ReplacementIF(num_ways)
{
for (uint32_t i = 0; i < num_ways; ++i)
{
way_map_.emplace_back(lru_stack_.emplace(lru_stack_.end(), i));
}
}

ReplacementIF* clone() const override
{
return new LRUReplacement(num_ways_);
}

void touchLRU(uint32_t way) override
{
auto lru_it = way_map_[way];
lru_stack_.splice(lru_stack_.begin(), lru_stack_, lru_it);
}

void touchLRU(uint32_t way, const std::vector<uint32_t> & way_order) override
{
sparta_assert(false, "Not implemented");
}

void touchMRU(uint32_t way) override
{
auto lru_it = way_map_[way];
lru_stack_.splice(lru_stack_.end(), lru_stack_, lru_it);
}

void touchMRU(uint32_t way, const std::vector<uint32_t> & way_order) override
{
sparta_assert(false, "Not implemented");
}

uint32_t getLRUWay() const override { return lru_stack_.front(); }

uint32_t getLRUWay(const std::vector<uint32_t> & way_order) override
{
sparta_assert(false, "Not implemented");
}

uint32_t getMRUWay() const override { return lru_stack_.back(); }

uint32_t getMRUWay(const std::vector<uint32_t> & way_order) override
{
sparta_assert(false, "Not implemented");
}

void lockWay(uint32_t way) override
{
sparta_assert(way < num_ways_);
sparta_assert(false, "Not implemented");
}

private:
std::list<uint32_t> lru_stack_;
std::vector<std::list<uint32_t>::const_iterator> way_map_;
};
} // namespace shinro
Loading

0 comments on commit 867559c

Please sign in to comment.