-
Notifications
You must be signed in to change notification settings - Fork 415
Noc traffic flows parser final #2083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 107 commits
ad67564
66b81f1
97861ba
e66973c
4c6e038
ae3fc05
aaa4687
5b088b6
6fcb368
7a80043
b966d70
db4c1f3
d57ad16
790e660
1401585
e3a0400
dfa7742
dd51424
887af99
0577a29
076b091
37e11ef
6f4beae
1e55e3d
cfa3969
dbb09c4
3ca57f1
3b2a565
12afbd6
52f0598
d8bf75a
5eec09e
f3e12a6
cf0f135
fb41204
0de01cc
df88ab7
ad39612
c3dbe68
7786b8f
1b291e8
fcb9bfb
cc40fd6
df6651c
5129422
8f226c3
6321cc5
2e461f1
b9d3f67
066e57a
11c88fa
bde20d4
774e10f
fc66cc9
ba26e7c
0038cc0
bd6ca3f
ee0c344
e6332d9
a142d1b
3c31e04
76342be
3711019
7b96833
22b4071
89232af
72b4f96
e73fece
9571c5c
3bd8100
c6b7b24
5a77e6b
b487e33
d14f6bb
ca1304b
b30a1f6
4175d51
91daab2
9873d39
76016e1
80c35ec
279f89d
7422117
f180c93
8d8af65
32125ff
4837211
f4e3ee4
76f9f49
72926e5
a153da5
d018f1b
1f3a951
3ad6112
caee85f
af61c84
70de39a
496c9a4
0c8d04d
9b8cbf2
9491ffe
2addace
9578626
55c8ae4
abc735b
5001d14
b6aaa9a
ae2734f
5372ba6
96539ac
8b6b860
8033563
77d24b1
a78c867
b32fba0
c9e568c
57bfd96
6551f65
5137869
5eba6ac
682522c
d16c5db
ad0bebf
f11ed2d
9cbcf33
9f6ca9f
7776f03
6869f55
b1f1477
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,8 @@ ClusterBlockId ClusteredNetlist::create_block(const char* name, t_pb* pb, t_logi | |
|
||
//Allocate and initialize every potential pin of the block | ||
block_logical_pins_.insert(blk_id, std::vector<ClusterPinId>(get_max_num_pins(type), ClusterPinId::INVALID())); | ||
|
||
add_block_to_logical_type(blk_id, type); | ||
} | ||
|
||
//Check post-conditions: size | ||
|
@@ -274,6 +276,28 @@ void ClusteredNetlist::shrink_to_fit_impl() { | |
net_is_global_.shrink_to_fit(); | ||
} | ||
|
||
/** | ||
* @brief Given a newly created block, find its logical type and store the | ||
* block in a list where all the other blocks in the list are of the | ||
* blocks logical type. | ||
*/ | ||
void ClusteredNetlist::add_block_to_logical_type(ClusterBlockId blk_id, t_logical_block_type_ptr type) { | ||
std::string logical_block_type_name = type->name; | ||
|
||
// check if a group of blocks exist for the current logical block type | ||
// basically checking if this is the first time we are seeing this logical block type | ||
auto logical_type_blocks = block_type_to_id.find(logical_block_type_name); | ||
|
||
if (logical_type_blocks == block_type_to_id.end()) { | ||
// if the current logical block doesnt exist then create a new group of blocks for it and add it | ||
block_type_to_id.emplace(logical_block_type_name, std::vector<ClusterBlockId>({blk_id})); | ||
} else { | ||
// current logical block exists, so add the current block to the group other blocks of this type | ||
logical_type_blocks->second.push_back(blk_id); | ||
} | ||
return; | ||
} | ||
|
||
/* | ||
* | ||
* Sanity Checks | ||
|
@@ -306,3 +330,52 @@ bool ClusteredNetlist::validate_net_sizes_impl(size_t num_nets) const { | |
} | ||
return true; | ||
} | ||
|
||
/** | ||
* @brief Finds a block where the blocks name contains within it the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will have to update comment . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated comment |
||
* provided input name. The intented use is to find the block id of a | ||
* hard block when provided with the its module name in the HDL design. | ||
* | ||
* For example, suppose a RAM block was instantiated in the design and it | ||
* was named "test_ram". The generated netlist would not have the block | ||
* named as "test_ram", instead it would be something different but the | ||
* name should contain "test_ram" inside it since it represents that | ||
* block. If "test_ram" is provided to find_block() above, then an | ||
* invalid block ID would be returned. The find_block_with_matching_name | ||
* () can instead be used and it should find the ram block that has | ||
* "test_ram" within its name. | ||
* | ||
* There is a similiar function in the Netlist Class. This function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this paragraph. No data structure stored anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
* additionally requires the logical type of the block as well. Since | ||
* the inteded use is to find hard blocks, it is quite inefficient to | ||
* to go through all the blocks to find a matching one. Instead, an | ||
* additional datastructure is created that groups clusters by their | ||
* logical type. This function filters the clusters and only searches | ||
* for the matching block within a list of blocks that are the same | ||
* logical type. The idea here is that the filtered list should be | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can just make this routine take a pass in vector of blocks to search if you want to keep it efficient (can compute that vector once in the calling routine); if someone didn't know the vector of blocks they could pass in a vector of the whole netlist There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this new data-structure from the clustered netlist, |
||
* considereably smaller that a list of every block in the netlist | ||
* and this should help improve run time. | ||
* | ||
*/ | ||
ClusterBlockId ClusteredNetlist::find_block_with_matching_name(const std::string& name, t_logical_block_type_ptr blk_type) const { | ||
ClusterBlockId blk_id = ClusterBlockId::INVALID(); | ||
auto blks_of_logical_type = block_type_to_id.find(blk_type->name); | ||
std::regex name_to_match(name); | ||
|
||
if (blks_of_logical_type != block_type_to_id.end()) { | ||
// get the list of blocks that are of the specified logical type | ||
const std::vector<ClusterBlockId>* blk_list = &blks_of_logical_type->second; | ||
|
||
// go through the list of blocks to find if any block name matches the provided name (contains the input string in its name) | ||
for (auto blk = blk_list->begin(); blk != blk_list->end(); blk++) { | ||
// another thing you can do is go through blocks and instead string.find(), you can use a regular expression version (so match a regular expression) | ||
|
||
// check for the string match | ||
if (std::regex_match(Netlist::block_name(*blk), name_to_match)) { | ||
blk_id = *blk; | ||
break; | ||
} | ||
} | ||
} | ||
return blk_id; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,14 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi | |
///@brief Sets the flag in net_is_global_ = state | ||
void set_net_is_global(ClusterNetId net_id, bool state); | ||
|
||
/** | ||
* @brief Given a name of a block and logical type, go through all the | ||
* cluster blocks of that type and return the id of a block where | ||
* the block name matches to provided name. | ||
* | ||
*/ | ||
ClusterBlockId find_block_with_matching_name(const std::string& name, t_logical_block_type_ptr blk_type) const; | ||
|
||
private: //Private Members | ||
/* | ||
* Netlist compression/optimization | ||
|
@@ -242,6 +250,9 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi | |
///@brief Shrinks internal data structures to required size to reduce memory consumption | ||
void shrink_to_fit_impl() override; | ||
|
||
///@brief Group the block to its corresponding logical type | ||
void add_block_to_logical_type(ClusterBlockId blk_id, t_logical_block_type_ptr type); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still in .h file --> please remove. Also check for any other dangling definitions in .h files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed and went through all other header files, did not see any other dangling function definitions. |
||
|
||
/* | ||
* Component removal | ||
*/ | ||
|
@@ -277,8 +288,10 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi | |
vtr::vector_map<ClusterBlockId, t_pb*> block_pbs_; ///<Physical block representing the clustering & internal hierarchy of each CLB | ||
vtr::vector_map<ClusterBlockId, t_logical_block_type_ptr> block_types_; ///<The type of logical block this user circuit block is mapped to | ||
vtr::vector_map<ClusterBlockId, std::vector<ClusterPinId>> block_logical_pins_; ///<The logical pin associated with each physical tile pin | ||
|
||
//Pins | ||
std::unordered_map<std::string, std::vector<ClusterBlockId>> block_type_to_id; ///<Group the physical blocks by their logical types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete --> go local There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted |
||
/// each logical type contains a list of blocks that are | ||
/// its type | ||
/// the key here is the logical type name | ||
/** | ||
* @brief The logical pin index of this block (i.e. pin index in t_logical_block_type) | ||
* corresponding to the clustered pin | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ enum e_echo_files { | |
|
||
//NoC | ||
E_ECHO_NOC_MODEL, | ||
E_ECHO_NOC_TRAFFIC_FLOWS, | ||
|
||
E_ECHO_END_TOKEN | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -727,6 +727,13 @@ class Netlist { | |
*/ | ||
BlockId find_block(const std::string& name) const; | ||
|
||
/** | ||
* @brief Returns the BlockId of the specified block or BlockId::INVALID() if not found. The name of the block returned contains the provided input name in it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to find_block_by_name_substring (or by_name_fragment). Make that clear in comment too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put O(N) in comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Say it returns first match if there are multiple. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also can move some or all of the .cpp example comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated function name and also incorporated these changes into the comments |
||
* | ||
* @param name The name of the block | ||
*/ | ||
BlockId find_block_with_matching_name(const std::string& name) const; | ||
|
||
/** | ||
* @brief Returns the PortId of the specifed port if it exists or PortId::INVALID() if not | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,6 +458,39 @@ BlockId Netlist<BlockId, PortId, PinId, NetId>::find_block(const std::string& na | |
} | ||
} | ||
|
||
/** | ||
* @brief Finds a block where the blocks name contains within it the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blocks name -> block's name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated comment to bring in these changes |
||
* provided input name. The intented use is to find the block id of a | ||
* hard block when provided with the its module name in the HDL design. | ||
* | ||
* For example, suppose a RAM block was instantiated in the design and it | ||
* was named "test_ram". The generated netlist would not have the block | ||
* named as "test_ram", instead it would be something different but the | ||
* name should contain "test_ram" inside it since it represents that | ||
* block. If "test_ram" is provided to find_block() above, then an | ||
* invalid block ID would be returned. The find_block_with_matching_name | ||
* () can instead be used and it should find the ram block that has | ||
* "test_ram" within its name. | ||
* | ||
*/ | ||
template<typename BlockId, typename PortId, typename PinId, typename NetId> | ||
BlockId Netlist<BlockId, PortId, PinId, NetId>::find_block_with_matching_name(const std::string& name) const { | ||
BlockId matching_blk_id = BlockId::INVALID(); | ||
const std::string blk_name; | ||
|
||
// go through all the blocks in the netlist | ||
for (auto blk_id = block_ids_.begin(); blk_id != block_ids_.end(); blk_id++) { | ||
// get the corresponding block name | ||
blk_name = &strings_[block_names_[*blk_id]]; | ||
// check whether the current block name contains the input string within it | ||
if (blk_name.find(name) != std::string::npos) { | ||
matching_blk_id = blk_id; | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return first match; not guaranteeing it the only match. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added to the comment |
||
} | ||
} | ||
return matching_blk_id; | ||
} | ||
|
||
template<typename BlockId, typename PortId, typename PinId, typename NetId> | ||
PortId Netlist<BlockId, PortId, PinId, NetId>::find_port(const BlockId blk_id, const std::string& name) const { | ||
VTR_ASSERT_SAFE(valid_block_id(blk_id)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2622,6 +2622,13 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg | |
.default_value("off") | ||
.show_in(argparse::ShowIn::HELP_ONLY); | ||
|
||
noc_grp.add_argument<std::string>(args.noc_flows_file, "--noc_flows_file") | ||
.help( | ||
"XML file containing the list of traffic flows within the NoC (communication between routers)." | ||
"This is required if the --noc option is turned on.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "turned on" --> "on" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or just if --noc is on |
||
.default_value("") | ||
.show_in(argparse::ShowIn::HELP_ONLY); | ||
|
||
return parser; | ||
} | ||
|
||
|
@@ -2803,7 +2810,7 @@ void set_conditional_defaults(t_options& args) { | |
|
||
bool verify_args(const t_options& args) { | ||
/* | ||
* Check for conflicting paramaters | ||
* Check for conflicting paramaters or dependencies where one parameter set requires another parameter to be included | ||
*/ | ||
if (args.read_rr_graph_file.provenance() == Provenance::SPECIFIED | ||
&& args.RouteChanWidth.provenance() != Provenance::SPECIFIED) { | ||
|
@@ -2826,5 +2833,19 @@ bool verify_args(const t_options& args) { | |
args.router_lookahead_type.argument_name().c_str()); | ||
} | ||
|
||
/** | ||
* @brief If the user provided the "--noc" command line option, then there | ||
* must be a NoC in the FPGA and the netlist must include NoC routers. | ||
* Therefore, the user must also provide a noc traffic flows file to | ||
* describe the communication within the NoC. We ensure that a noc traffic | ||
* flows file is provided when the "--noc" option is used. If it is not | ||
* provided, we throw an error. | ||
* | ||
*/ | ||
if (args.noc.provenance() == Provenance::SPECIFIED && args.noc_flows_file.provenance() != Provenance::SPECIFIED) { | ||
VPR_FATAL_ERROR(VPR_ERROR_OTHER, | ||
"--noc_flows_file option must be specified if --noc is turned on.\n"); | ||
} | ||
|
||
return true; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
#include <climits> | ||
#include <cmath> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
#include "SetupGrid.h" | ||
#include "setup_clocks.h" | ||
#include "setup_noc.h" | ||
#include "read_xml_noc_traffic_flows_file.h" | ||
#include "stats.h" | ||
#include "read_options.h" | ||
#include "echo_files.h" | ||
|
@@ -518,6 +519,8 @@ void vpr_setup_noc(const t_vpr_setup& vpr_setup, const t_arch& arch) { | |
if (vpr_setup.NocOpts.noc == true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just leave out the == true |
||
// create the NoC model based on the user description from the arch file | ||
setup_noc(arch); | ||
// read and store the noc traffic flow information | ||
read_xml_noc_traffic_flows_file(vpr_setup.NocOpts.noc_flows_file.c_str()); | ||
|
||
#ifndef NO_GRAPHICS | ||
// setup the graphics | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
#include "metadata_storage.h" | ||
#include "vpr_constraints.h" | ||
#include "noc_storage.h" | ||
#include "noc_traffic_flows.h" | ||
|
||
/** | ||
* @brief A Context is collection of state relating to a particular part of VPR | ||
|
@@ -427,6 +428,16 @@ struct NocContext : public Context { | |
* The NoC model is created once from the architecture file description. | ||
*/ | ||
NocStorage noc_model; | ||
|
||
/** | ||
* @brief Stores all the communication happening betwee routers in the NoC | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. betwee --> between |
||
* | ||
* Contains all of the traffic flows that describe which two routers are communication with each other and also some metrics and constraints on the data transfer between the two routers. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "describe which pairs of logical routers are communicating and also ..." |
||
* | ||
* | ||
* This is created from a user supplied .flows file. | ||
*/ | ||
NocTrafficFlows noc_traffic_flows_storage; | ||
}; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1271,7 +1271,8 @@ struct t_analysis_opts { | |
|
||
// used to store NoC specific options, when supplied as an input by the user | ||
struct t_noc_opts { | ||
bool noc; ///<options to model the noc within the FPGA device | ||
bool noc; ///<options to model the noc within the FPGA device | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns on hard NoC modeling & optimization There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
std::string noc_flows_file; ///<name of the file that contains all the traffic flow information in the NoC | ||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this data since it is only used in one parser and instead create locally (in a map or whatever you want there). Easier to understand and maintain since the data is local and has a short lifetime then.
Right now you're adding global state that all netlist modifiers (delete_block for example) will have to keep up to date. Since it's only used in one spot, it isn't worth it.