@@ -252,14 +252,16 @@ static bool primitive_has_external_output(const t_pb_graph_node* prim) {
252252 return false ;
253253}
254254
255- std::map<t_logical_block_type_ptr, size_t > DeviceSizeEstimator::estimate_resource_requirement (const Prepacker& prepacker) {
255+ std::map<t_logical_block_type_ptr, size_t > DeviceSizeEstimator::estimate_resource_requirement (const Prepacker& prepacker, bool store_ram_groups ) {
256256 vtr::ScopedStartFinishTimer timer (" Estimate Resource Requirement" );
257257 const auto & atom_ctx = g_vpr_ctx.atom ();
258258
259259 // Group RAM atoms and assign to minimum-area types.
260- // Results are stored in ram_groups_ for later use by RamMapper.
261- ram_groups_ = group_ram_atoms (atom_ctx.netlist (), prepacker);
262- assign_ram_groups_by_min_area (ram_groups_, false /* is_fixed_device*/ );
260+ // If requested, results are stored in ram_groups_ for later use by RamMapper.
261+ vtr::vector<LogicalRamGroupId, LogicalRamGroup> ram_groups = group_ram_atoms (atom_ctx.netlist (), prepacker);
262+ assign_ram_groups_by_min_area (ram_groups, false /* is_fixed_device*/ );
263+ if (store_ram_groups)
264+ ram_groups_ = ram_groups;
263265
264266 // Group non-RAM molecules by their logical block type.
265267 vtr::vector<LogicalModelId, std::vector<t_logical_block_type_ptr>>
@@ -306,8 +308,8 @@ std::map<t_logical_block_type_ptr, size_t> DeviceSizeEstimator::estimate_resourc
306308 }
307309
308310 // Estimate instance counts for RAM types using logical RAM groups.
309- for (LogicalRamGroupId ram_group_id : ram_groups_ .keys ()) {
310- const LogicalRamGroup& ram_group = ram_groups_ [ram_group_id];
311+ for (LogicalRamGroupId ram_group_id : ram_groups .keys ()) {
312+ const LogicalRamGroup& ram_group = ram_groups [ram_group_id];
311313 t_logical_block_type_ptr logical_type = ram_group.pre_assigned_type ? ram_group.pre_assigned_type : ram_group.candidate_types [0 ];
312314 size_t inferred_number_of_instances = std::ceil (vtr::safe_ratio<float >(ram_group.total_memory_slices , ram_group.candidate_capacity .at (logical_type)));
313315 num_type_instances[logical_type] += inferred_number_of_instances;
@@ -378,7 +380,8 @@ static std::pair<size_t, size_t> read_rr_graph_grid_dims(const std::string& file
378380
379381DeviceSizeEstimator::DeviceSizeEstimator (t_vpr_setup& vpr_setup,
380382 const t_arch& arch,
381- const Prepacker& prepacker) {
383+ const Prepacker& prepacker,
384+ bool always_estimate_resource_requirement) {
382385 vtr::ScopedStartFinishTimer timer (" Estimate Device Size" );
383386 const std::string& device_layout = vpr_setup.PackerOpts .device_layout ;
384387 const t_packer_opts& packer_opts = vpr_setup.PackerOpts ;
@@ -416,6 +419,8 @@ DeviceSizeEstimator::DeviceSizeEstimator(t_vpr_setup& vpr_setup,
416419 // resizing during and after packing.
417420 device_ctx.grid = create_device_grid (device_layout, arch.grid_layouts , width, height);
418421 device_ctx.grid .set_fixed_by_rr_graph (true );
422+ if (always_estimate_resource_requirement)
423+ estimated_num_type_instances_ = estimate_resource_requirement (prepacker, /* store_ram_groups=*/ false );
419424 return ;
420425 }
421426
@@ -426,6 +431,8 @@ DeviceSizeEstimator::DeviceSizeEstimator(t_vpr_setup& vpr_setup,
426431 device_ctx.grid = create_device_grid (device_layout, arch.grid_layouts ,
427432 num_type_instances,
428433 packer_opts.target_device_utilization );
434+ if (always_estimate_resource_requirement)
435+ estimated_num_type_instances_ = estimate_resource_requirement (prepacker, /* store_ram_groups=*/ false );
429436 return ;
430437 }
431438
@@ -437,12 +444,15 @@ DeviceSizeEstimator::DeviceSizeEstimator(t_vpr_setup& vpr_setup,
437444 {}, packer_opts.target_device_utilization ,
438445 vpr_setup.device_width );
439446 report_device_grid_stats (device_ctx.grid );
447+ if (always_estimate_resource_requirement)
448+ estimated_num_type_instances_ = estimate_resource_requirement (prepacker, /* store_ram_groups=*/ false );
440449 return ;
441450 }
442451
443452 VTR_LOG (" Device layout '%s' selected. Need to estimate device size.\n " , device_layout.c_str ());
444453
445454 std::map<t_logical_block_type_ptr, size_t > num_type_instances = estimate_resource_requirement (prepacker);
455+ estimated_num_type_instances_ = num_type_instances;
446456 VTR_LOG (" Estimated resource requirements:\n " );
447457 for (auto & [type_ptr, count] : num_type_instances)
448458 VTR_LOG (" %s: %zu requested instances\n " , type_ptr->name .c_str (), count);
0 commit comments