Compare commits

...

5 Commits

Author SHA1 Message Date
Mukendi Mputu e1b1f13797 I did it!!! 😃 2022-06-02 21:08:36 +02:00
Mukendi Mputu c46403d456 first successful join 2022-05-25 14:20:06 +02:00
Mukendi Mputu 15d236299d first draft pseudo code 2022-05-24 23:30:04 +02:00
Mukendi Mputu 2f682920f7 Merge commit '2ab71cf95df2fa3615909d24187b38715c20181d' 2022-05-24 21:56:35 +02:00
Mukendi Mputu 42b533434b first intent 2022-05-24 21:53:15 +02:00
5 changed files with 82 additions and 17 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ build/
*.solution *.solution
compile_commands.json compile_commands.json
llvm/ llvm/
.idea

17
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -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
}

View File

@ -59,7 +59,7 @@ struct CacheAnalysisPass : PassInfoMixin<CacheAnalysisPass> {
bool LoopUnrolling = true; bool LoopUnrolling = true;
// Assume a 4kB Cache // 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); CacheType Cache = CacheType(16, 4, 128);
StringRef EntryPoint = "main"; StringRef EntryPoint = "main";
unsigned int EntryAddress; unsigned int EntryAddress;

View File

@ -7,7 +7,7 @@ clean () {
} }
config () { config () {
echo "==== Crating build folder ====" echo "==== Creating build folder ===="
mkdir build mkdir build
cd build cd build
echo "==== Configuring cmake ====" echo "==== Configuring cmake ===="

View File

@ -5,6 +5,7 @@
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <iomanip>
#include <iostream> #include <iostream>
#include <list> #include <list>
#include <map> #include <map>
@ -98,10 +99,6 @@ public: // everything is public, because IDGAF
Unrolled = UnrolledIn; Unrolled = UnrolledIn;
} }
// AbstractState(Address Addr) {
// Sets[Addr.Index].Associativity[0] = {{Addr.Tag}};
// }
void setUnrolled(unsigned int In) { Unrolled = In; } void setUnrolled(unsigned int In) { Unrolled = In; }
bool operator==(AbstractState In) { bool operator==(AbstractState In) {
@ -135,9 +132,60 @@ public: // everything is public, because IDGAF
*/ */
void mustJoin(AbstractState In) { 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. * 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"; std::cout << "}\n";
} }
}; // namespace }; // namespace
#endif // STATE_H #endif // STATE_H