Compare commits
5 Commits
master
...
correction
Author | SHA1 | Date |
---|---|---|
Mukendi Mputu | e1b1f13797 | |
Mukendi Mputu | c46403d456 | |
Mukendi Mputu | 15d236299d | |
Mukendi Mputu | 2f682920f7 | |
Mukendi Mputu | 42b533434b |
|
@ -10,3 +10,4 @@ build/
|
|||
*.solution
|
||||
compile_commands.json
|
||||
llvm/
|
||||
.idea
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++14",
|
||||
"intelliSenseMode": "linux-clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
|
@ -59,7 +59,7 @@ struct CacheAnalysisPass : PassInfoMixin<CacheAnalysisPass> {
|
|||
bool LoopUnrolling = true;
|
||||
|
||||
// Assume a 4kB Cache
|
||||
// with 16 Sets, associativity of 4 and Cachelines fitting two
|
||||
// with 16 Sets, associativity of 4 and Cachelines fitting two times the instruction size
|
||||
CacheType Cache = CacheType(16, 4, 128);
|
||||
StringRef EntryPoint = "main";
|
||||
unsigned int EntryAddress;
|
||||
|
|
|
@ -7,7 +7,7 @@ clean () {
|
|||
}
|
||||
|
||||
config () {
|
||||
echo "==== Crating build folder ===="
|
||||
echo "==== Creating build folder ===="
|
||||
mkdir build
|
||||
cd build
|
||||
echo "==== Configuring cmake ===="
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -98,10 +99,6 @@ public: // everything is public, because IDGAF
|
|||
Unrolled = UnrolledIn;
|
||||
}
|
||||
|
||||
// AbstractState(Address Addr) {
|
||||
// Sets[Addr.Index].Associativity[0] = {{Addr.Tag}};
|
||||
// }
|
||||
|
||||
void setUnrolled(unsigned int In) { Unrolled = In; }
|
||||
|
||||
bool operator==(AbstractState In) {
|
||||
|
@ -135,9 +132,60 @@ public: // everything is public, because IDGAF
|
|||
*/
|
||||
void mustJoin(AbstractState In) {
|
||||
/**
|
||||
* The exercise is to Fill this function with an LRU must Join.
|
||||
* TODO: Fill this function with an LRU must Join.
|
||||
* For this you need to use Sets. Associativity and Blocks.
|
||||
*/
|
||||
|
||||
// Loop through all 16 sets
|
||||
for (int Index = 0; Index < 16; Index++) {
|
||||
|
||||
struct Set current_set = Sets[Index];
|
||||
struct Set incoming_set = In.Sets[Index];
|
||||
|
||||
// create a temporary set of associativity
|
||||
struct Set temp_set;
|
||||
temp_set.Associativity = {{(unsigned int)0, {{}}},
|
||||
{(unsigned int)1, {{}}},
|
||||
{(unsigned int)2, {{}}},
|
||||
{(unsigned int)3, {{}}}};
|
||||
|
||||
int new_age = 0;
|
||||
|
||||
// loop through all Ages
|
||||
for (int current_age = 0; current_age < 4; current_age++) {
|
||||
|
||||
std::list<unsigned int> new_block_list;
|
||||
|
||||
auto current_age_entry = current_set.Associativity[current_age];
|
||||
std::list<unsigned int> current_age_blocklist =
|
||||
current_age_entry.Blocks;
|
||||
|
||||
// for every element of associativity_block_list
|
||||
for (auto block : current_age_blocklist) {
|
||||
// look through ALL incoming_set.Blocklists for occurrences
|
||||
for (auto incoming_associativity : incoming_set.Associativity) {
|
||||
int age = incoming_associativity.first;
|
||||
struct Entry entry = incoming_associativity.second;
|
||||
|
||||
auto ret =
|
||||
std::find(entry.Blocks.begin(), entry.Blocks.end(), block);
|
||||
if (ret !=
|
||||
entry.Blocks.end()) { // if current block found amongst incoming
|
||||
|
||||
// compare the ages and take the maximum age
|
||||
new_age = std::max(current_age, age);
|
||||
|
||||
new_block_list.push_front((unsigned int)*ret);
|
||||
}
|
||||
}
|
||||
// update the temporary
|
||||
temp_set.Associativity[new_age].Blocks.merge(new_block_list);
|
||||
|
||||
Sets[Index] = temp_set;
|
||||
}
|
||||
}
|
||||
// Here should be Sets[Index] = temp_set;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,6 +304,5 @@ public: // everything is public, because IDGAF
|
|||
}
|
||||
std::cout << "}\n";
|
||||
}
|
||||
|
||||
}; // namespace
|
||||
#endif // STATE_H
|
Loading…
Reference in New Issue