diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..1b7b0dd --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -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 +} \ No newline at end of file diff --git a/CacheAnalysisPass/CacheAnalysisPass.cpp b/CacheAnalysisPass/CacheAnalysisPass.cpp index 86184b4..c8de1d9 100644 --- a/CacheAnalysisPass/CacheAnalysisPass.cpp +++ b/CacheAnalysisPass/CacheAnalysisPass.cpp @@ -56,7 +56,7 @@ struct CacheAnalysisPass : PassInfoMixin { 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 diff --git a/include/AbstractState.h b/include/AbstractState.h index de001b8..f755152 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -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; + struct Set current_set = Sets[Index]; + struct Set incoming_set = In.Sets[Index]; // loop through all 4 Ages - for (int Age; Age < 4; Age++) { - struct Set current_set = Sets[Index]; - struct Set incoming_set = In.Sets[Index]; + //for (int Age = 0; Age < 4; Age++) { - // 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) { + 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 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(new_age, new_entry) ) + print_block_list(associativity_age, associativity_block_list); } - - Sets[Index] = temp_set; + + + 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 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 list) { + + std::cout << "\t" << age << " -> {"; + for (auto block : list) + std::cout << block << " "; + std::cout << "}" << std::endl; + } + /** * @brief Checks if Address Addr is in Cache * @@ -239,17 +265,17 @@ public: // everything is public, because IDGAF } } - void dumpSet(unsigned int Set) { + void dumpSet(unsigned int Set) { std::cout << Addr << " {\n"; - std::cout << "Set[" << Set << "]: \n"; - for (auto EntryPair : this->Sets[Set].Associativity) { - std::cout << " Age[" << EntryPair.first << "]: "; - for (auto Block : EntryPair.second.Blocks) { - std::cout << Block << " "; - } - std::cout << "\n"; + std::cout << "Set[" << Set << "]: \n"; + for (auto EntryPair : this->Sets[Set].Associativity) { + std::cout << " Age[" << EntryPair.first << "]: "; + for (auto Block : EntryPair.second.Blocks) { + std::cout << Block << " "; } + std::cout << "\n"; + } std::cout << "}\n"; }