first draft pseudo code
This commit is contained in:
parent
2f682920f7
commit
15d236299d
|
@ -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
|
||||||
|
}
|
|
@ -56,7 +56,7 @@ struct CacheAnalysisPass : PassInfoMixin<CacheAnalysisPass> {
|
||||||
bool PrintEdgesPost = false;
|
bool PrintEdgesPost = false;
|
||||||
bool DumpToDot = false;
|
bool DumpToDot = false;
|
||||||
bool DumpNodes = false;
|
bool DumpNodes = false;
|
||||||
bool LoopUnrolling = false;
|
bool LoopUnrolling = true;
|
||||||
|
|
||||||
// Assume a 4kB Cache
|
// Assume a 4kB Cache
|
||||||
// with 16 Sets, associativity of 4 and Cachelines fitting two times the instruction size
|
// with 16 Sets, associativity of 4 and Cachelines fitting two times the instruction size
|
||||||
|
|
|
@ -137,34 +137,60 @@ public: // everything is public, because IDGAF
|
||||||
// TODO: Due date 08.06.2022
|
// TODO: Due date 08.06.2022
|
||||||
|
|
||||||
// Loop through all 16 sets
|
// Loop through all 16 sets
|
||||||
for (int Index; Index < 16; Index++) {
|
for (int Index = 0; Index < 16; Index++) {
|
||||||
|
|
||||||
// create a temporary set of associativity
|
// create a temporary set of associativity
|
||||||
struct Set temp_set;
|
struct Set temp_set;
|
||||||
|
struct Set current_set = Sets[Index];
|
||||||
|
struct Set incoming_set = In.Sets[Index];
|
||||||
|
|
||||||
// loop through all 4 Ages
|
// loop through all 4 Ages
|
||||||
for (int Age; Age < 4; Age++) {
|
//for (int Age = 0; 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
|
std::cout << "Block list in current set"
|
||||||
for (auto age: current_set.Associativity) {
|
<< "[" << Index << "]" << std::endl;
|
||||||
std::cout << age.first
|
// loop through current set and build list of all contained blocks
|
||||||
<< ":";
|
for (auto associativity_map : current_set.Associativity) {
|
||||||
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) {
|
|
||||||
|
|
||||||
}
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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<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
|
* @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 << Addr << " {\n";
|
||||||
|
|
||||||
std::cout << "Set[" << Set << "]: \n";
|
std::cout << "Set[" << Set << "]: \n";
|
||||||
for (auto EntryPair : this->Sets[Set].Associativity) {
|
for (auto EntryPair : this->Sets[Set].Associativity) {
|
||||||
std::cout << " Age[" << EntryPair.first << "]: ";
|
std::cout << " Age[" << EntryPair.first << "]: ";
|
||||||
for (auto Block : EntryPair.second.Blocks) {
|
for (auto Block : EntryPair.second.Blocks) {
|
||||||
std::cout << Block << " ";
|
std::cout << Block << " ";
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
}
|
||||||
|
std::cout << "\n";
|
||||||
|
}
|
||||||
std::cout << "}\n";
|
std::cout << "}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue