first draft pseudo code

This commit is contained in:
Mukendi Mputu 2022-05-24 23:30:04 +02:00
parent 2f682920f7
commit 15d236299d
3 changed files with 68 additions and 25 deletions

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

@ -56,7 +56,7 @@ struct CacheAnalysisPass : PassInfoMixin<CacheAnalysisPass> {
bool PrintEdgesPost = false;
bool DumpToDot = false;
bool DumpNodes = false;
bool LoopUnrolling = false;
bool LoopUnrolling = true;
// Assume a 4kB Cache
// with 16 Sets, associativity of 4 and Cachelines fitting two times the instruction size

View File

@ -137,34 +137,60 @@ public: // everything is public, because IDGAF
// TODO: Due date 08.06.2022
// Loop through all 16 sets
for (int Index; Index < 16; Index++) {
for (int Index = 0; Index < 16; Index++) {
// create a temporary set of associativity
struct Set temp_set;
// loop through all 4 Ages
for (int Age; Age < 4; Age++) {
struct Set current_set = Sets[Index];
struct Set incoming_set = In.Sets[Index];
// loop through current set and build list of all contained blocks
for (auto age: current_set.Associativity) {
std::cout << age.first
<< ":";
for (auto block : age.second.Blocks)
std::cout << block << std::endl;
}
// loop through incoming set and build list of all contained blocks
for (auto E2 : In.Sets[Index].Associativity[Age].Blocks) {
// loop through all 4 Ages
//for (int Age = 0; Age < 4; Age++) {
std::cout << "Block list in current set"
<< "[" << Index << "]" << std::endl;
// loop through current set and build list of all contained blocks
for (auto associativity_map : current_set.Associativity) {
int associativity_age = associativity_map.first;
std::list<unsigned int> associativity_block_list =
associativity_map.second.Blocks;
// for every element of associativity_block_list
// if find equivalent in incoming_set.Associativity.block_list
// set new_age = max(associativity_age, age);
// temp_set.Associativity.insert(std::pair<unsigned int, struct Entry>(new_age, new_entry) )
print_block_list(associativity_age, associativity_block_list);
}
std::cout << "Block list in incoming set"
<< "[" << Index << "]" << std::endl;
// loop through incoming set and build list of all contained blocks
for (auto associativity : incoming_set.Associativity) {
int age = associativity.first;
std::list<unsigned int> block_list =
associativity.second.Blocks;
print_block_list(age, block_list);
}
// for (auto E2 : In.Sets[Index].Associativity[Age].Blocks) {
// }
//}
Sets[Index] = temp_set;
}
}
void print_block_list(int age, std::list<unsigned int> list) {
std::cout << "\t" << age << " -> {";
for (auto block : list)
std::cout << block << " ";
std::cout << "}" << std::endl;
}
/**
* @brief Checks if Address Addr is in Cache
*