[OpenFPGA Tool] Bug fix for long runtime
This commit is contained in:
parent
47f3c79927
commit
e179a58b15
|
@ -122,7 +122,6 @@ int build_fabric(OpenfpgaContext& openfpga_ctx,
|
|||
VTR_ASSERT(false == fkey_fname.empty());
|
||||
curr_status = write_fabric_key_to_xml_file(openfpga_ctx.module_graph(),
|
||||
fkey_fname,
|
||||
openfpga_ctx.arch().config_protocol.type(),
|
||||
cmd_context.option_enable(cmd, opt_verbose));
|
||||
/* If there is any error, final status cannot be overwritten by a success flag */
|
||||
if (CMD_EXEC_SUCCESS != curr_status) {
|
||||
|
|
|
@ -221,6 +221,8 @@ void build_top_module_configurable_regions(ModuleManager& module_manager,
|
|||
const ModuleId& top_module,
|
||||
const ConfigProtocol& config_protocol) {
|
||||
|
||||
vtr::ScopedStartFinishTimer timer("Build configurable regions for the top module");
|
||||
|
||||
/* Ensure we have valid configurable children */
|
||||
VTR_ASSERT(false == module_manager.configurable_children(top_module).empty());
|
||||
|
||||
|
@ -240,7 +242,7 @@ void build_top_module_configurable_regions(ModuleManager& module_manager,
|
|||
size_t region_child_counter = 0;
|
||||
bool create_region = true;
|
||||
ConfigRegionId curr_region = ConfigRegionId::INVALID();
|
||||
for (size_t ichild = 0; ichild < num_configurable_children; ++ichild) {
|
||||
for (size_t ichild = 0; ichild < module_manager.configurable_children(top_module).size(); ++ichild) {
|
||||
if (true == create_region) {
|
||||
curr_region = module_manager.add_config_region(top_module);
|
||||
}
|
||||
|
@ -249,7 +251,8 @@ void build_top_module_configurable_regions(ModuleManager& module_manager,
|
|||
module_manager.add_configurable_child_to_region(top_module,
|
||||
curr_region,
|
||||
module_manager.configurable_children(top_module)[ichild],
|
||||
module_manager.configurable_child_instances(top_module)[ichild]);
|
||||
module_manager.configurable_child_instances(top_module)[ichild],
|
||||
ichild);
|
||||
|
||||
/* See if the current region is full or not:
|
||||
* For the last region, we will keep adding until we finish all the children
|
||||
|
@ -262,6 +265,9 @@ void build_top_module_configurable_regions(ModuleManager& module_manager,
|
|||
region_child_counter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure that the number of configurable regions created matches the definition */
|
||||
VTR_ASSERT((size_t)config_protocol.num_regions() == module_manager.regions(top_module).size());
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
@ -500,7 +506,8 @@ void shuffle_top_module_configurable_children(ModuleManager& module_manager,
|
|||
orig_configurable_child_instances[shuffled_keys[ikey]]);
|
||||
}
|
||||
|
||||
/* Split memory modules into different regions */
|
||||
/* Reset configurable regions */
|
||||
module_manager.clear_config_region(top_module);
|
||||
build_top_module_configurable_regions(module_manager, top_module, config_protocol);
|
||||
}
|
||||
|
||||
|
@ -520,6 +527,8 @@ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager
|
|||
/* Ensure a clean start */
|
||||
module_manager.clear_configurable_children(top_module);
|
||||
|
||||
size_t curr_configurable_child_id = 0;
|
||||
|
||||
for (const FabricRegionId& region : fabric_key.regions()) {
|
||||
/* Create a configurable region in the top module */
|
||||
ConfigRegionId top_module_config_region = module_manager.add_config_region(top_module);
|
||||
|
@ -572,7 +581,9 @@ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager
|
|||
module_manager.add_configurable_child_to_region(top_module,
|
||||
top_module_config_region,
|
||||
instance_info.first,
|
||||
instance_info.second);
|
||||
instance_info.second,
|
||||
curr_configurable_child_id);
|
||||
curr_configurable_child_id++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace openfpga {
|
|||
***************************************************************************************/
|
||||
int write_fabric_key_to_xml_file(const ModuleManager& module_manager,
|
||||
const std::string& fname,
|
||||
const e_config_protocol_type& config_protocol_type,
|
||||
const bool& verbose) {
|
||||
std::string timer_message = std::string("Write fabric key to XML file '") + fname + std::string("'");
|
||||
|
||||
|
@ -58,13 +57,6 @@ int write_fabric_key_to_xml_file(const ModuleManager& module_manager,
|
|||
FabricKey fabric_key;
|
||||
size_t num_keys = module_manager.configurable_children(top_module).size();
|
||||
|
||||
/* Exclude configuration-related modules in the keys */
|
||||
if (CONFIG_MEM_MEMORY_BANK == config_protocol_type) {
|
||||
num_keys -= 2;
|
||||
} else if (CONFIG_MEM_FRAME_BASED == config_protocol_type) {
|
||||
num_keys -= 1;
|
||||
}
|
||||
|
||||
fabric_key.reserve_keys(num_keys);
|
||||
|
||||
size_t num_regions = module_manager.regions(top_module).size();
|
||||
|
@ -75,7 +67,7 @@ int write_fabric_key_to_xml_file(const ModuleManager& module_manager,
|
|||
FabricRegionId fabric_region = fabric_key.create_region();
|
||||
fabric_key.reserve_region_keys(fabric_region, module_manager.region_configurable_children(top_module, config_region).size());
|
||||
|
||||
for (size_t ichild = 0; ichild < num_keys; ++ichild) {
|
||||
for (size_t ichild = 0; ichild < module_manager.region_configurable_children(top_module, config_region).size(); ++ichild) {
|
||||
ModuleId child_module = module_manager.region_configurable_children(top_module, config_region)[ichild];
|
||||
size_t child_instance = module_manager.region_configurable_child_instances(top_module, config_region)[ichild];
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ namespace openfpga {
|
|||
|
||||
int write_fabric_key_to_xml_file(const ModuleManager& module_manager,
|
||||
const std::string& fname,
|
||||
const e_config_protocol_type& config_protocol_type,
|
||||
const bool& verbose);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
|
|
@ -737,31 +737,16 @@ ConfigRegionId ModuleManager::add_config_region(const ModuleId& module) {
|
|||
void ModuleManager::add_configurable_child_to_region(const ModuleId& parent_module,
|
||||
const ConfigRegionId& config_region,
|
||||
const ModuleId& child_module,
|
||||
const size_t& child_instance) {
|
||||
const size_t& child_instance,
|
||||
const size_t& config_child_id) {
|
||||
/* Validate the module id */
|
||||
VTR_ASSERT ( valid_module_id(parent_module) );
|
||||
VTR_ASSERT ( valid_module_id(child_module) );
|
||||
VTR_ASSERT ( valid_region_id(parent_module, config_region) );
|
||||
|
||||
/* Ensure that the child module is in the configurable children list */
|
||||
size_t config_child_id = configurable_children(parent_module).size();
|
||||
for (size_t ichild = 0; ichild < configurable_children(parent_module).size(); ++ichild) {
|
||||
if ( (child_module == configurable_children(parent_module)[ichild])
|
||||
&& (child_instance == configurable_child_instances(parent_module)[ichild]) ) {
|
||||
config_child_id = ichild;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Error out as the child is not valid */
|
||||
if (config_child_id == configurable_children(parent_module).size()) {
|
||||
VTR_LOGF_ERROR(__FILE__, __LINE__,
|
||||
"Try to add an invalid configurable child '%s[%lu]' to region '%lu'!\n",
|
||||
module_name(child_module).c_str(),
|
||||
child_instance,
|
||||
size_t(config_region));
|
||||
exit(1);
|
||||
}
|
||||
VTR_ASSERT(child_module == configurable_children(parent_module)[config_child_id]);
|
||||
VTR_ASSERT(child_instance == configurable_child_instances(parent_module)[config_child_id]);
|
||||
|
||||
/* If the child is already in another region, error out */
|
||||
if ( (true == valid_region_id(parent_module, configurable_child_regions_[parent_module][config_child_id]))
|
||||
|
@ -775,18 +760,6 @@ void ModuleManager::add_configurable_child_to_region(const ModuleId& parent_modu
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Ensure that the child is not in the list */
|
||||
if (config_region_children_[parent_module][config_region].end() != std::find(config_region_children_[parent_module][config_region].begin(),
|
||||
config_region_children_[parent_module][config_region].end(),
|
||||
config_child_id)) {
|
||||
VTR_LOGF_ERROR(__FILE__, __LINE__,
|
||||
"The configurable child '%s[%lu]' is already in the region '%lu'! Skip adding\n",
|
||||
module_name(child_module).c_str(),
|
||||
child_instance,
|
||||
size_t(config_region));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Passed all the checks, add the child to the region */
|
||||
config_region_children_[parent_module][config_region].push_back(config_child_id);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,8 @@ class ModuleManager {
|
|||
void add_configurable_child_to_region(const ModuleId& parent_module,
|
||||
const ConfigRegionId& config_region,
|
||||
const ModuleId& child_module,
|
||||
const size_t& child_instance);
|
||||
const size_t& child_instance,
|
||||
const size_t& config_child_id);
|
||||
|
||||
/* Reserved a number of module nets for a given module
|
||||
* for memory efficiency
|
||||
|
|
Loading…
Reference in New Issue