From 3b7586e47d3b6cd06ab05c610a43028908a2ce5b Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Wed, 17 Apr 2024 15:50:00 -0400 Subject: [PATCH 1/9] scripts updated --- .../cca_chip_active_status_animation.py | 4 +-- Analytics/Post_Processing/post_processing.py | 18 +++++++++- .../Post_Processing/post_processing_simple.py | 26 +++++++++++--- Include/CCASimulator.hpp | 2 +- Source/ComputeCell.cpp | 17 ++++++++-- Tests/Run_All_Apps/run_all_apps.zsh | 34 ++++++++++++++++++- 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/Analytics/Animations/cca_chip_active_status_animation.py b/Analytics/Animations/cca_chip_active_status_animation.py index 12c9dbd..a1d8732 100644 --- a/Analytics/Animations/cca_chip_active_status_animation.py +++ b/Analytics/Animations/cca_chip_active_status_animation.py @@ -1,7 +1,7 @@ """ BSD 3-Clause License -Copyright (c) 2023, Bibrak Qamar +Copyright (c) 2023-2024, Bibrak Qamar Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -236,7 +236,7 @@ def update(frame): output_filename = ( - "SSSP_TH_OFF_" + str(dim_x) + "x" + str(dim_y) + "_" + routing_algorithm + "SSSP_" + str(dim_x) + "x" + str(dim_y) # + "_" + routing_algorithm ) # Save the animation as an MP4 file """ ani.save(output_filename+'.mp4', writer='ffmpeg', dpi=520) """ diff --git a/Analytics/Post_Processing/post_processing.py b/Analytics/Post_Processing/post_processing.py index ee852fc..acf0c7d 100644 --- a/Analytics/Post_Processing/post_processing.py +++ b/Analytics/Post_Processing/post_processing.py @@ -1,7 +1,7 @@ """ BSD 3-Clause License -Copyright (c) 2023, Bibrak Qamar +Copyright (c) 2023-2024, Bibrak Qamar Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -121,6 +121,10 @@ header = file.readline() queues_configuration = file.readline().strip().split() + # read the header line for the table and discard it + header = file.readline() + ghost_children_max = file.readline().strip().split() + # read the header line for the table and discard it header = file.readline() @@ -131,6 +135,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, operons_moved, ) = ( file.readline().strip().split() @@ -143,6 +150,9 @@ actions_created, actions_performed, actions_false_pred, + diffusions_created, + diffusions_performed, + diffusions_false_pred, operons_moved, ) = map( int, @@ -152,6 +162,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, operons_moved, ], ) @@ -191,6 +204,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, ) print("congestion_policy: ", congestion_policy, ", value: ", congestion_threshold_value) print("avg_objects_per_cc: ", avg_objects_per_cc) diff --git a/Analytics/Post_Processing/post_processing_simple.py b/Analytics/Post_Processing/post_processing_simple.py index 9fb556f..ee57059 100644 --- a/Analytics/Post_Processing/post_processing_simple.py +++ b/Analytics/Post_Processing/post_processing_simple.py @@ -1,7 +1,7 @@ """ BSD 3-Clause License -Copyright (c) 2023, Bibrak Qamar +Copyright (c) 2023-2024, Bibrak Qamar Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -123,6 +123,10 @@ header = file.readline() queues_configuration = file.readline().strip().split() + # read the header line for the table and discard it + header = file.readline() + ghost_children_max = file.readline().strip().split() + # read the header line for the table and discard it header = file.readline() @@ -133,6 +137,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, operons_moved, ) = ( file.readline().strip().split() @@ -145,6 +152,9 @@ actions_created, actions_performed, actions_false_pred, + diffusions_created, + diffusions_performed, + diffusions_false_pred, operons_moved, ) = map( int, @@ -154,6 +164,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, operons_moved, ], ) @@ -171,7 +184,7 @@ # read the per cycle active status data active_status_per_cycle = [] # stores the active status - for i in range(0, 3): # cycles all cycles + for i in range(0, cycles): # cycles all cycles line = file.readline() line = line.strip().split("\t") cycle = int(line[0]) @@ -193,6 +206,9 @@ total_actions_created, total_actions_performed, total_actions_false_pred, + total_diffusions_created, + total_diffusions_performed, + total_diffusions_false_pred, ) print("congestion_policy: ", congestion_policy, ", value: ", congestion_threshold_value) print("avg_objects_per_cc: ", avg_objects_per_cc) @@ -228,7 +244,7 @@ def congestion_charts(): # Flatten the axes array to easily iterate over subplots axes = axes.flatten() - bins = 30 + bins = 15 # blue: '#2F5597' # red: '#B00002' @@ -276,8 +292,8 @@ def congestion_charts(): for ax in axes: ax.xaxis.set_major_formatter(FuncFormatter(thousands_formatter)) ax.yaxis.set_major_formatter(FuncFormatter(thousands_formatter)) - ax.set_xlim(0, 400000) # Set the x-axis limit - ax.set_ylim(0, 5900) # Set the y-axis limit + #ax.set_xlim(0, 400000) # Set the x-axis limit + #ax.set_ylim(0, 5900) # Set the y-axis limit # Adjust spacing between subplots plt.tight_layout() diff --git a/Include/CCASimulator.hpp b/Include/CCASimulator.hpp index c374b1e..05c6127 100644 --- a/Include/CCASimulator.hpp +++ b/Include/CCASimulator.hpp @@ -1,7 +1,7 @@ /* BSD 3-Clause License -Copyright (c) 2023, Bibrak Qamar +Copyright (c) 2023-2024, Bibrak Qamar Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/Source/ComputeCell.cpp b/Source/ComputeCell.cpp index 0afff57..31452ee 100644 --- a/Source/ComputeCell.cpp +++ b/Source/ComputeCell.cpp @@ -290,7 +290,8 @@ ComputeCell::execute_action(void* function_events) // the diffuse closure into the diffuse_queue otherwise just run the diffusion here. if constexpr (split_queues) { - if (function_events_manager->is_null_event(diffuse_predicate.first)) { + if (function_events_manager->is_null_event(diffuse_predicate.first) || + function_events_manager->is_null_event(action.diffuse_predicate)) { // do nothing } else if (function_events_manager->is_true_event(diffuse_predicate.first) && diffuse_predicate.second == nullptr) { @@ -408,7 +409,12 @@ ComputeCell::execute_diffusion_phase(void* function_events) } else { // This diffusion is discarded/subsumed. - this->statistics.diffusions_false_on_predicate++; + + // If the action's diffuse itself is false then don't count it as being subsumed + // because it wasn't there to begin with. + if (action.diffuse_predicate != this->null_false_event) { + this->statistics.diffusions_false_on_predicate++; + } } // Finally this object becomes inactive. if constexpr (termination_switch) { @@ -475,7 +481,12 @@ ComputeCell::filter_diffusion(void* function_events) } else { // This diffusion is discarded/subsumed. - this->statistics.diffusions_false_on_predicate++; + + // If the action's diffuse itself is hardcoded to be false then don't count it as + // being subsumed because it wasn't there to begin with. + if (action.diffuse_predicate != this->null_false_event) { + this->statistics.diffusions_false_on_predicate++; + } } // Finally this object becomes inactive. if constexpr (termination_switch) { diff --git a/Tests/Run_All_Apps/run_all_apps.zsh b/Tests/Run_All_Apps/run_all_apps.zsh index 9a4f6bc..094912b 100755 --- a/Tests/Run_All_Apps/run_all_apps.zsh +++ b/Tests/Run_All_Apps/run_all_apps.zsh @@ -1,5 +1,37 @@ #!/bin/zsh +: <<'COMMENT_BLOCK' +BSD 3-Clause License + +Copyright (c) 2024, Bibrak Qamar + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +COMMENT_BLOCK + + CCA_SIMULATOR=../.. BUILD_DIR=build @@ -14,7 +46,7 @@ CMAKE_INPUT_OPTIONS=( -D GHOST_CHILDREN=3 -D THROTTLE_CONGESTION_THRESHOLD=22 -D RECVBUFFSIZE=4 - -D ACTIONQUEUESIZE=256 + -D ACTIONQUEUESIZE=2048 -D RHIZOME_INDEGREE_CUTOFF=10 -D SPLIT_QUEUES=true ) From a041dfff3e2a7d1ced9788b60dadcb0e750f6e60 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Wed, 17 Apr 2024 20:57:49 -0400 Subject: [PATCH 2/9] added queue sizes info to the output file --- Analytics/Post_Processing/post_processing.py | 25 +++++++++++++++--- .../Post_Processing/post_processing_simple.py | 26 +++++++++++++++---- Include/CCASimulator.hpp | 5 +++- Source/CCASimulator.cpp | 3 ++- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Analytics/Post_Processing/post_processing.py b/Analytics/Post_Processing/post_processing.py index acf0c7d..5f46d00 100644 --- a/Analytics/Post_Processing/post_processing.py +++ b/Analytics/Post_Processing/post_processing.py @@ -119,7 +119,9 @@ # read the header line for the table and discard it header = file.readline() - queues_configuration = file.readline().strip().split() + queues_configuration, action_queue_size, diffuse_queue_size = ( + file.readline().strip().split() + ) # read the header line for the table and discard it header = file.readline() @@ -208,9 +210,24 @@ total_diffusions_performed, total_diffusions_false_pred, ) -print("congestion_policy: ", congestion_policy, ", value: ", congestion_threshold_value) -print("avg_objects_per_cc: ", avg_objects_per_cc) -print("queues_configuration: ", queues_configuration) +print( + "congestion_policy: ", + congestion_policy, + ", value: ", + congestion_threshold_value, +) +print( + "avg_objects_per_cc: ", + avg_objects_per_cc, +) +print( + "queues_configuration: ", + queues_configuration, + "action_queue_size: ", + action_queue_size, + ", diffuse_queue_size: ", + diffuse_queue_size, +) # print(cc_id, cc_x, cc_y, created, pushed, invoked, performed, false_pred, # stall_logic, stall_recv, stall_send, res_usage, inactive) diff --git a/Analytics/Post_Processing/post_processing_simple.py b/Analytics/Post_Processing/post_processing_simple.py index ee57059..30aaa84 100644 --- a/Analytics/Post_Processing/post_processing_simple.py +++ b/Analytics/Post_Processing/post_processing_simple.py @@ -121,7 +121,9 @@ # read the header line for the table and discard it header = file.readline() - queues_configuration = file.readline().strip().split() + queues_configuration, action_queue_size, diffuse_queue_size = ( + file.readline().strip().split() + ) # read the header line for the table and discard it header = file.readline() @@ -210,8 +212,22 @@ total_diffusions_performed, total_diffusions_false_pred, ) -print("congestion_policy: ", congestion_policy, ", value: ", congestion_threshold_value) -print("avg_objects_per_cc: ", avg_objects_per_cc) +print( + "congestion_policy: ", + congestion_policy, + ", value: ", + congestion_threshold_value, +) +print( + "avg_objects_per_cc: ", + avg_objects_per_cc, +) +print( + "action_queue_size: ", + action_queue_size, + ", diffuse_queue_size: ", + diffuse_queue_size, +) # print(cc_id, cc_x, cc_y, created, pushed, invoked, performed, false_pred, # stall_logic, stall_recv, stall_send, res_usage, inactive) @@ -292,8 +308,8 @@ def congestion_charts(): for ax in axes: ax.xaxis.set_major_formatter(FuncFormatter(thousands_formatter)) ax.yaxis.set_major_formatter(FuncFormatter(thousands_formatter)) - #ax.set_xlim(0, 400000) # Set the x-axis limit - #ax.set_ylim(0, 5900) # Set the y-axis limit + # ax.set_xlim(0, 400000) # Set the x-axis limit + # ax.set_ylim(0, 5900) # Set the y-axis limit # Adjust spacing between subplots plt.tight_layout() diff --git a/Include/CCASimulator.hpp b/Include/CCASimulator.hpp index 05c6127..99d775e 100644 --- a/Include/CCASimulator.hpp +++ b/Include/CCASimulator.hpp @@ -269,11 +269,14 @@ class CCASimulator << "\t" << curently_congested_threshold << "\n"; std::string queues_text = "single"; + u_int32_t size_of_diffuse_queue = 0; if (split_queues) { queues_text = "split"; + size_of_diffuse_queue = diffuse_queue_size; } - os << "queues_configuration\n" << queues_text << "\n"; + os << "queues_configuration\n" + << queues_text << "\t" << action_queue_size << "\t" << size_of_diffuse_queue << "\n"; os << "ghost_children_max\n" << ghost_children_max << "\n"; } diff --git a/Source/CCASimulator.cpp b/Source/CCASimulator.cpp index bc3569f..463ef6c 100644 --- a/Source/CCASimulator.cpp +++ b/Source/CCASimulator.cpp @@ -350,7 +350,8 @@ CCASimulator::print_statistics(std::ofstream& output_file) this->write_cca_info(output_file); // Output total cycles, total actions, total actions performed work, total actions false on - // predicate. TODO: Somehow put the resource usage as a percentage...? + // predicate, diffusions_created diffusions_performed_work diffusions_false_on_predicate. + // TODO: Somehow put the resource usage as a percentage...? output_file << "total_cycles\ttotal_objects_created\ttotal_actions_created\ttotal_actions_" "performed_work\ttotal_actions_false_on_predicate\tdiffusions_created\tdiffusions_" From 8977bea40c80592c9f589cc9e8a799af7f148807 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Thu, 18 Apr 2024 03:36:30 -0400 Subject: [PATCH 3/9] added converter from edgelist to weighted adjency format used in Liagra --- .../edgelist_to_weightedAdj.cpp | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp diff --git a/Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp b/Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp new file mode 100644 index 0000000..f1af47d --- /dev/null +++ b/Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp @@ -0,0 +1,136 @@ +/* +BSD 3-Clause License + +Copyright (c) 2024, Bibrak Qamar + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +#include +#include +#include + +// Structure to represent an edge +struct Edge +{ + int target; // End vertex of the edge + int weight; // Weight of the edge + + // Constructor + Edge(int target, int weight) + : target(target) + , weight(weight) + { + } +}; + +int +main(int argc, char* argv[]) +{ + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " " << std::endl; + return 1; + } + + const std::string inputFileName = argv[1]; + const std::string outputFileName = inputFileName + "_weightedAdj"; + + std::ifstream inputFile(inputFileName); + if (!inputFile.is_open()) { + std::cerr << "Failed to open input file: " << inputFileName << std::endl; + return 1; + } + + std::string line; + bool dataStarted = false; + + std::vector> adj_graph; + int num_vertices, num_verticesx, num_edges; + + { + inputFile >> num_vertices >> num_verticesx; + { + std::cout << "num_vertices: " << num_vertices << ", num_verticesx: " << num_verticesx + << "\n"; + // Resize the adj_graph vector to the number of vertices. + adj_graph.resize(num_vertices); + } + inputFile >> num_edges; + { + std::cout << "num_edges: " << num_edges << "\n"; + } + } + + for (int i = 0; i < num_edges; ++i) { + int vertex_from, vertex_to, weight; + inputFile >> vertex_from >> vertex_to >> weight; + adj_graph[vertex_from].emplace_back(Edge(vertex_to, weight)); + } + + inputFile.close(); + + std::ofstream outputFile(outputFileName); + if (!outputFile.is_open()) { + std::cerr << "Failed to create output file: " << outputFileName << std::endl; + inputFile.close(); + return 1; + } + + // Write number of vertices and the number of edges of the graph to the adj output file. + outputFile << adj_graph.size() << "\n" << num_edges << "\n"; + + int offset = 0; + // Write the first offset. + outputFile << offset << "\n"; + + for (int i = 0; i < adj_graph.size() - 1; i++) { + std::cout << "size: " << adj_graph[i].size() << "\n"; + offset += adj_graph[i].size(); + outputFile << offset << "\n"; + } + + for (const auto& vertex : adj_graph) { + for (const auto& edge : vertex) { + outputFile << edge.target << "\n"; + } + } + + for (const auto& vertex : adj_graph) { + for (const auto& edge : vertex) { + outputFile << edge.weight << "\n"; + } + } + + outputFile.close(); + + std::cout << "Graph data processed and saved to " << outputFileName << std::endl; + + return 0; +} From 14b052760d15ea0e3a3d1f3f626ed5678e23fd92 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Thu, 18 Apr 2024 04:03:10 -0400 Subject: [PATCH 4/9] fixed bugs in the adj converter --- ...to_weightedAdj.cpp => edgelist_to_Adj.cpp} | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) rename Utilities/Refine_Input_Data/{edgelist_to_weightedAdj.cpp => edgelist_to_Adj.cpp} (81%) diff --git a/Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp b/Utilities/Refine_Input_Data/edgelist_to_Adj.cpp similarity index 81% rename from Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp rename to Utilities/Refine_Input_Data/edgelist_to_Adj.cpp index f1af47d..59054fe 100644 --- a/Utilities/Refine_Input_Data/edgelist_to_weightedAdj.cpp +++ b/Utilities/Refine_Input_Data/edgelist_to_Adj.cpp @@ -54,13 +54,23 @@ struct Edge int main(int argc, char* argv[]) { - if (argc != 2) { - std::cerr << "Usage: " << argv[0] << " " << std::endl; + + if (argc != 3) { + std::cerr << "Usage: " << argv[0] << " " << std::endl; return 1; } + std::cout << "Remember the input file is assumed to be weighted. If it is not then the " + "converted output file will not be correct!\n"; + const std::string inputFileName = argv[1]; - const std::string outputFileName = inputFileName + "_weightedAdj"; + const bool weighted = (std::stoi(argv[2]) != 0); + std::string outputfile_extension = "Adj"; + if (weighted) { + outputfile_extension = "_weightedAdj"; + } + + const std::string outputFileName = inputFileName + outputfile_extension; std::ifstream inputFile(inputFileName); if (!inputFile.is_open()) { @@ -103,7 +113,14 @@ main(int argc, char* argv[]) return 1; } + std::cout << "Writing to the output file: " << outputFileName << std::endl; + // Write number of vertices and the number of edges of the graph to the adj output file. + if (weighted) { + outputFile << "WeightedAdjacencyGraph\n"; + } else { + outputFile << "AdjacencyGraph\n"; + } outputFile << adj_graph.size() << "\n" << num_edges << "\n"; int offset = 0; @@ -111,7 +128,6 @@ main(int argc, char* argv[]) outputFile << offset << "\n"; for (int i = 0; i < adj_graph.size() - 1; i++) { - std::cout << "size: " << adj_graph[i].size() << "\n"; offset += adj_graph[i].size(); outputFile << offset << "\n"; } @@ -122,9 +138,11 @@ main(int argc, char* argv[]) } } - for (const auto& vertex : adj_graph) { - for (const auto& edge : vertex) { - outputFile << edge.weight << "\n"; + if (weighted) { + for (const auto& vertex : adj_graph) { + for (const auto& edge : vertex) { + outputFile << edge.weight << "\n"; + } } } From 2c4f6d584ab588c89eaccf3569a50a7b7a0ae816 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Fri, 19 Apr 2024 18:37:00 -0400 Subject: [PATCH 5/9] added work pruning in the name of the output file --- Source/CCASimulator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/CCASimulator.cpp b/Source/CCASimulator.cpp index 463ef6c..e1c94ea 100644 --- a/Source/CCASimulator.cpp +++ b/Source/CCASimulator.cpp @@ -425,13 +425,18 @@ CCASimulator::key_configurations_string() -> std::string network_text = "TORUS"; } + std::string work_pruning_text = "ON"; + if (split_queues == false) { + work_pruning_text = "OFF"; + } + std::string configs = "_x_" + std::to_string(this->dim_x) + "_y_" + std::to_string(this->dim_y) + "_hb_" + std::to_string(this->hbandwidth_max) + "_th_" + throttle_text + "_recvbuff_" + std::to_string(RECVBUFFSIZE) + "_vicinity_" + std::to_string(vicinity_radius) + "_ghosts_children_" + std::to_string(ghost_children_max) + "_edges_min_" + std::to_string(edges_min) + "_edges_max_" + std::to_string(edges_max) + "_termimation_" + - termination_text + "_network_" + network_text; + termination_text + "_network_" + network_text + "_work_pruning_" + work_pruning_text; return configs; } From a933ce2c6948f1ac5452d1c26053391312ae503e Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Sat, 20 Apr 2024 00:27:14 -0400 Subject: [PATCH 6/9] added new couters for diffusion filter and action overlap with the split queues model and also fixed a bug in queue selection --- Include/Cell.hpp | 45 ++++++++++++++++++++++++++++------------- Source/CCASimulator.cpp | 10 ++++++++- Source/Cell.cpp | 14 +++++++++---- Source/ComputeCell.cpp | 22 +++++++++++++------- 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/Include/Cell.hpp b/Include/Cell.hpp index c8b5797..05b90c7 100644 --- a/Include/Cell.hpp +++ b/Include/Cell.hpp @@ -91,6 +91,11 @@ struct ComputeCellStatistics u_int32_t diffusions_performed_work{}; // # of diffusions subsumed. Meaning flase on predicate. u_int32_t diffusions_false_on_predicate{}; + // u_int32_t diffusions_pruned{}; // == diffusions_false_on_predicate + diffusions_filtered + + // Actions overlaped and Diffuse filtering, while the network is congested. + u_int32_t actions_overlaped{}; + u_int32_t diffusions_filtered{}; std::vector send_channel_per_neighbor_contention_count_record; MaxCounter staging_logic_contention_count_record; @@ -113,11 +118,13 @@ struct ComputeCellStatistics { os << "cc_id\tcc_type\tcc_coordinate_x\tcc_coordinate_y\tobjects_allocated" - "\tactions_created\tactions_acknowledgement_created" - "\tactions_pushed\tactions_invoked\tactions_performed_work" - "\tactions_acknoledgement_invoked\tactions_false_on_predicate" + "\tactions_created\tactions_invoked\tactions_performed_work\tactions_false_on_" + "predicate\tactions_overlaped" + + "\tdiffusions_created\tdiffusions_performed_work\tdiffusions_false_on_" + "predicate\tdiffusions_filtered" - "\tdiffusions_created\tdiffusions_performed_work\tdiffusions_false_on_predicate" + "\tactions_acknowledgement_created\tactions_acknoledgement_invoked" "\toperons_moved" @@ -137,14 +144,17 @@ struct ComputeCellStatistics friend auto operator<<(std::ostream& os, const ComputeCellStatistics& stat) -> std::ostream& { - double actions_prune_percent = 100.0 * - static_cast(stat.actions_false_on_predicate) / - static_cast(stat.actions_created); + double actions_false_predicate_percent = + 100.0 * static_cast(stat.actions_false_on_predicate) / + static_cast(stat.actions_created); - double diffuse_prune_percent = 100.0 * - static_cast(stat.diffusions_false_on_predicate) / + u_int32_t diffusions_pruned = stat.diffusions_false_on_predicate + stat.diffusions_filtered; + double diffuse_prune_percent = 100.0 * static_cast(diffusions_pruned) / static_cast(stat.diffusions_created); + double action_overlap_percent = 100.0 * static_cast(stat.actions_overlaped) / + static_cast(stat.actions_created); + assert(stat.actions_pushed == stat.actions_invoked); /* << "\n\tactions_pushed: " << stat.actions_pushed << "\n\tactions_invoked: " << stat.actions_invoked */ @@ -157,13 +167,17 @@ struct ComputeCellStatistics << "\n\tactions_created: " << stat.actions_created << "\n\tactions_performed_work: " << stat.actions_performed_work << "\n\tactions_false_on_predicate: " << stat.actions_false_on_predicate - << "\n\tactions_prune_percent: " << actions_prune_percent + << "\n\tactions_false_predicate_percent: " << actions_false_predicate_percent + << "\n\tactions_overlaped: " << stat.actions_overlaped + << "\n\taction_overlap_percent: " << action_overlap_percent << "\n" << "\n\tdiffusions_created: " << stat.diffusions_created << "\n\tdiffusions_performed_work: " << stat.diffusions_performed_work << "\n\tdiffusions_false_on_predicate: " << stat.diffusions_false_on_predicate + << "\n\tdiffusions_filtered: " << stat.diffusions_filtered + << "\n\tTotal diffusions_pruned: " << diffusions_pruned << "\n\tdiffuse_prune_percent: " << diffuse_prune_percent << "\n" @@ -180,21 +194,24 @@ struct ComputeCellStatistics auto operator+=(const ComputeCellStatistics& rhs) -> ComputeCellStatistics& { + this->objects_allocated += rhs.objects_allocated; + this->actions_created += rhs.actions_created; this->actions_pushed += rhs.actions_pushed; this->actions_invoked += rhs.actions_invoked; this->actions_performed_work += rhs.actions_performed_work; this->actions_false_on_predicate += rhs.actions_false_on_predicate; - - this->actions_acknowledgement_created += rhs.actions_acknowledgement_created; - this->actions_acknowledgement_invoked += rhs.actions_acknowledgement_invoked; + this->actions_overlaped += rhs.actions_overlaped; this->diffusions_created += rhs.diffusions_created; this->diffusions_performed_work += rhs.diffusions_performed_work; this->diffusions_false_on_predicate += rhs.diffusions_false_on_predicate; + this->diffusions_filtered += rhs.diffusions_filtered; + + this->actions_acknowledgement_created += rhs.actions_acknowledgement_created; + this->actions_acknowledgement_invoked += rhs.actions_acknowledgement_invoked; this->operons_moved += rhs.operons_moved; - this->objects_allocated += rhs.objects_allocated; return *this; } diff --git a/Source/CCASimulator.cpp b/Source/CCASimulator.cpp index e1c94ea..dfad05c 100644 --- a/Source/CCASimulator.cpp +++ b/Source/CCASimulator.cpp @@ -355,7 +355,9 @@ CCASimulator::print_statistics(std::ofstream& output_file) output_file << "total_cycles\ttotal_objects_created\ttotal_actions_created\ttotal_actions_" "performed_work\ttotal_actions_false_on_predicate\tdiffusions_created\tdiffusions_" - "performed_work\tdiffusions_false_on_predicate\toperons_moved\n" + "performed_work\tdiffusions_false_on_predicate\tdiffusions_filtered\tactions_" + "overlaped\tdiffusions_pruned\toperons_moved\n" + << this->total_cycles << "\t" << simulation_statistics.objects_allocated << "\t" << simulation_statistics.actions_created << "\t" @@ -365,6 +367,12 @@ CCASimulator::print_statistics(std::ofstream& output_file) << simulation_statistics.diffusions_created << "\t" << simulation_statistics.diffusions_performed_work << "\t" << simulation_statistics.diffusions_false_on_predicate << "\t" + << simulation_statistics.diffusions_filtered << "\t" + + << simulation_statistics.actions_overlaped << "\t" + << simulation_statistics.diffusions_false_on_predicate + + simulation_statistics.diffusions_filtered + << "\t" << simulation_statistics.operons_moved << "\n"; diff --git a/Source/Cell.cpp b/Source/Cell.cpp index 0bf00ff..674cc4f 100644 --- a/Source/Cell.cpp +++ b/Source/Cell.cpp @@ -242,10 +242,16 @@ ComputeCellStatistics::output_results_in_a_single_line(std::ostream& os, { os << cc_id << "\t" << Cell::get_cell_type_name(this->type) << "\t" << cc_cooridinates.first << "\t" << cc_cooridinates.second << "\t" << this->objects_allocated << "\t" - << this->actions_created << "\t" << this->actions_acknowledgement_created << "\t" - << this->actions_pushed << "\t" << this->actions_invoked << "\t" - << this->actions_performed_work << "\t" << this->actions_acknowledgement_invoked << "\t" - << this->actions_false_on_predicate + + << this->actions_created << "\t" << this->actions_invoked << "\t" + << this->actions_performed_work << "\t" << this->actions_false_on_predicate << "\t" + << this->actions_overlaped + + << "\t" << this->diffusions_created << "\t" << this->diffusions_performed_work << "\t" + << this->diffusions_false_on_predicate << "\t" << this->diffusions_filtered + + << "\t" << this->actions_acknowledgement_created << "\t" + << this->actions_acknowledgement_invoked << "\t" << this->operons_moved diff --git a/Source/ComputeCell.cpp b/Source/ComputeCell.cpp index 31452ee..c02bb06 100644 --- a/Source/ComputeCell.cpp +++ b/Source/ComputeCell.cpp @@ -281,18 +281,19 @@ ComputeCell::execute_action(void* function_events) this->statistics.actions_performed_work++; // if (predicate_resolution == 1) { - // work + // Perform the work contained in the action and then return its diffuse closure. Closure const diffuse_predicate = function_events_manager->get_function_event_handler(action.work)( *this, action.obj_addr, action.action_type, action.args); // If there are two queues in the system (configured at compile time) then we put - // the diffuse closure into the diffuse_queue otherwise just run the diffusion here. + // the diffuse closure (lazy evaluated) into the diffuse_queue otherwise just run + // the diffusion here. if constexpr (split_queues) { if (function_events_manager->is_null_event(diffuse_predicate.first) || function_events_manager->is_null_event(action.diffuse_predicate)) { - // do nothing + // do nothing since the diffuse wan't created runtime. } else if (function_events_manager->is_true_event(diffuse_predicate.first) && diffuse_predicate.second == nullptr) { if (!this->diffuse_queue.push(action)) { // diffuse body is lazy evaluated. @@ -314,8 +315,9 @@ ComputeCell::execute_action(void* function_events) } else { // Only single queue i.e. action_queue - if (function_events_manager->is_null_event(diffuse_predicate.first)) { - // do nothing + if (function_events_manager->is_null_event(diffuse_predicate.first) || + function_events_manager->is_null_event(action.diffuse_predicate)) { + // do nothing since the diffuse wan't created runtime. } else { if (diffuse_predicate.second != nullptr) { @@ -485,10 +487,13 @@ ComputeCell::filter_diffusion(void* function_events) // If the action's diffuse itself is hardcoded to be false then don't count it as // being subsumed because it wasn't there to begin with. if (action.diffuse_predicate != this->null_false_event) { - this->statistics.diffusions_false_on_predicate++; + // this->statistics.diffusions_false_on_predicate++; + this->statistics.diffusions_filtered++; } } // Finally this object becomes inactive. + // TODO: this whole termination logic is buggy right now and therfore should not be + // used. if constexpr (termination_switch) { auto* obj = static_cast(this->get_object(action.obj_addr)); obj->terminator.unsignal(*this); @@ -716,16 +721,18 @@ ComputeCell::run_a_computation_cycle(std::vector>& CCA_chi bool const diffuse_queue_is_getting_full = this->diffuse_queue.is_percent_full(90.0); - bool const action_queue_near_full = this->diffuse_queue.is_percent_full(95.0); + bool const action_queue_near_full = this->action_queue.is_percent_full(95.0); if (both_queues_non_empty) { if (action_queue_near_full && this->diffuse_queue.has_room()) { this->execute_action(function_events); + this->statistics.actions_overlaped++; } else if (diffuse_queue_is_getting_full) { //&& this->prefer_diffuse_queue) { this->filter_diffusion(function_events); // this->prefer_diffuse_queue = false; } else { this->execute_action(function_events); + this->statistics.actions_overlaped++; // this->prefer_diffuse_queue = true; } } else { @@ -734,6 +741,7 @@ ComputeCell::run_a_computation_cycle(std::vector>& CCA_chi this->filter_diffusion(function_events); } else if (!this->action_queue.empty()) { this->execute_action(function_events); + this->statistics.actions_overlaped++; } } } From dbf8aaebec05ef675b4b75123bf6cebffdea50a7 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Sat, 20 Apr 2024 03:06:26 -0400 Subject: [PATCH 7/9] now outputing the active status to the output file every 100th cycle --- Include/CCASimulator.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Include/CCASimulator.hpp b/Include/CCASimulator.hpp index 99d775e..fedf251 100644 --- a/Include/CCASimulator.hpp +++ b/Include/CCASimulator.hpp @@ -298,8 +298,11 @@ class CCASimulator os << "Cycle#\tCells_Active_Percent\tHtree_Active_Percent\n"; if constexpr (active_percent_switch) { for (size_t i = 0; i < this->cca_statistics.active_status.size(); i++) { - os << i << "\t" << this->cca_statistics.active_status[i].cells_active_percent - << "\t" << this->cca_statistics.active_status[i].htree_active_percent << "\n"; + if (i % 100 == 0) { // Print to output file for every 100th cycle. + os << i << "\t" << this->cca_statistics.active_status[i].cells_active_percent + << "\t" << this->cca_statistics.active_status[i].htree_active_percent + << "\n"; + } } } else { // Invalid values just to preserve format. From 2fbbaa298193bad4f45ac1f9e2d577ca1f7bccf5 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Sat, 20 Apr 2024 03:10:00 -0400 Subject: [PATCH 8/9] generatized skipping the output printing per cycle --- Include/CCASimulator.hpp | 10 +++++----- Include/Constants.hpp | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Include/CCASimulator.hpp b/Include/CCASimulator.hpp index fedf251..8aa7ff6 100644 --- a/Include/CCASimulator.hpp +++ b/Include/CCASimulator.hpp @@ -298,11 +298,11 @@ class CCASimulator os << "Cycle#\tCells_Active_Percent\tHtree_Active_Percent\n"; if constexpr (active_percent_switch) { for (size_t i = 0; i < this->cca_statistics.active_status.size(); i++) { - if (i % 100 == 0) { // Print to output file for every 100th cycle. - os << i << "\t" << this->cca_statistics.active_status[i].cells_active_percent - << "\t" << this->cca_statistics.active_status[i].htree_active_percent - << "\n"; - } + // Print to output file for every output_skip_cycles-th cycle. + // if (i % output_skip_cycles == 0) { + os << i << "\t" << this->cca_statistics.active_status[i].cells_active_percent + << "\t" << this->cca_statistics.active_status[i].htree_active_percent << "\n"; + //} } } else { // Invalid values just to preserve format. diff --git a/Include/Constants.hpp b/Include/Constants.hpp index b16a5ef..be118bf 100644 --- a/Include/Constants.hpp +++ b/Include/Constants.hpp @@ -104,4 +104,7 @@ inline constexpr u_int32_t rhizome_inbound_degree_cutoff = RHIZOME_INDEGREE_CUTO // Or keep it one queue called the action queue inline constexpr bool split_queues = SPLIT_QUEUES; +// To print to the output every output_skip_cycles's cycle +inline constexpr u_int32_t output_skip_cycles = 1; + #endif // CONSTANTS_HPP From c88282265bfd082db825654acf906245406d21c5 Mon Sep 17 00:00:00 2001 From: Bibrak Qamar Date: Thu, 25 Apr 2024 01:46:09 -0400 Subject: [PATCH 9/9] updated the analytics scripts --- .../cca_chip_active_status_animation.py | 15 ++++++++------- Analytics/Post_Processing/post_processing.py | 9 +++++++++ .../Post_Processing/post_processing_simple.py | 19 ++++++++++++++----- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Analytics/Animations/cca_chip_active_status_animation.py b/Analytics/Animations/cca_chip_active_status_animation.py index a1d8732..42fe6fe 100644 --- a/Analytics/Animations/cca_chip_active_status_animation.py +++ b/Analytics/Animations/cca_chip_active_status_animation.py @@ -206,7 +206,7 @@ def update(frame): frames_to_show = cycles - start_from # Create the animation ani = animation.FuncAnimation( - fig, update, frames=range(0, frames_to_show, skip_frames), interval=70 + fig, update, frames=range(0, frames_to_show, skip_frames), interval=10 ) # Increase the interval # Set the grid cell size and ticks @@ -221,9 +221,9 @@ def update(frame): ax.set_ylabel("Rows of Compute Cells", fontsize=16) # Add a larger second title routing_algorithm = "Dimension Ordered Horizontal First Routing" -graph_size = "Random Directed Graph V=36K and E=0.66M" +graph_size = "RMAT Directed Graph V=65K and E=1.04M" plt.suptitle( - "Asynchronous SSSP on a CCA Chip of " + "Asynchronous BFS on a CCA Chip of " + str(dim_x) + " x " + str(dim_y) @@ -234,16 +234,17 @@ def update(frame): fontsize=16, ) - +TH="ON" +SH="ON" output_filename = ( - "SSSP_" + str(dim_x) + "x" + str(dim_y) # + "_" + routing_algorithm + "BFS_" + str(dim_x) + "x" + str(dim_y) + "_th_" + TH + "_SH" + SH ) # Save the animation as an MP4 file """ ani.save(output_filename+'.mp4', writer='ffmpeg', dpi=520) """ # Save the animation as a GIF file -""" ani.save(output_filename+'.gif', writer='pillow', dpi=100) """ +ani.save(output_filename+'.gif', writer='pillow', dpi=100) # ani.save(output_filename, writer='pillow', dpi=70, interval=50) # Display the plot -plt.show() +#plt.show() diff --git a/Analytics/Post_Processing/post_processing.py b/Analytics/Post_Processing/post_processing.py index 5f46d00..93c13a1 100644 --- a/Analytics/Post_Processing/post_processing.py +++ b/Analytics/Post_Processing/post_processing.py @@ -140,6 +140,9 @@ total_diffusions_created, total_diffusions_performed, total_diffusions_false_pred, + total_diffusions_filtered, + total_actions_overlaped, + total_diffusions_pruned, operons_moved, ) = ( file.readline().strip().split() @@ -155,6 +158,9 @@ diffusions_created, diffusions_performed, diffusions_false_pred, + diffusions_filtered, + actions_overlaped, + diffusions_pruned, operons_moved, ) = map( int, @@ -167,6 +173,9 @@ total_diffusions_created, total_diffusions_performed, total_diffusions_false_pred, + total_diffusions_filtered, + total_actions_overlaped, + total_diffusions_pruned, operons_moved, ], ) diff --git a/Analytics/Post_Processing/post_processing_simple.py b/Analytics/Post_Processing/post_processing_simple.py index 30aaa84..953c628 100644 --- a/Analytics/Post_Processing/post_processing_simple.py +++ b/Analytics/Post_Processing/post_processing_simple.py @@ -142,6 +142,9 @@ total_diffusions_created, total_diffusions_performed, total_diffusions_false_pred, + total_diffusions_filtered, + total_actions_overlaped, + total_diffusions_pruned, operons_moved, ) = ( file.readline().strip().split() @@ -157,6 +160,9 @@ diffusions_created, diffusions_performed, diffusions_false_pred, + diffusions_filtered, + actions_overlaped, + diffusions_pruned, operons_moved, ) = map( int, @@ -169,6 +175,9 @@ total_diffusions_created, total_diffusions_performed, total_diffusions_false_pred, + total_diffusions_filtered, + total_actions_overlaped, + total_diffusions_pruned, operons_moved, ], ) @@ -270,11 +279,11 @@ def congestion_charts(): x="left_send_contention_total", bins=bins, ax=axes[0], - color="#2F5597", + color="#B00002", ) axes[0].set_xlabel("") # Remove x-axis label for the second subplot sns.histplot( - data=stats, x="up_send_contention_total", bins=bins, ax=axes[1], color="#2F5597" + data=stats, x="up_send_contention_total", bins=bins, ax=axes[1], color="#B00002" ) axes[1].set_xlabel("") # Remove x-axis label for the second subplot sns.histplot( @@ -282,7 +291,7 @@ def congestion_charts(): x="right_send_contention_total", bins=bins, ax=axes[2], - color="#2F5597", + color="#B00002", ) axes[2].set_xlabel("") # Remove x-axis label for the second subplot sns.histplot( @@ -290,7 +299,7 @@ def congestion_charts(): x="down_send_contention_total", bins=bins, ax=axes[3], - color="#2F5597", + color="#B00002", ) axes[3].set_xlabel("") # Remove x-axis label for the second subplot @@ -309,7 +318,7 @@ def congestion_charts(): ax.xaxis.set_major_formatter(FuncFormatter(thousands_formatter)) ax.yaxis.set_major_formatter(FuncFormatter(thousands_formatter)) # ax.set_xlim(0, 400000) # Set the x-axis limit - # ax.set_ylim(0, 5900) # Set the y-axis limit + ax.set_ylim(0, 2500) # Set the y-axis limit # Adjust spacing between subplots plt.tight_layout()