def apply_modifier(vpr_args, io_grid, seed=0): with Silence(): vpr_context = VPRContext(vpr_args) placement = vpr_context.get_random_placement() placement.set_io(io_grid) calc = BBCalculator.create(placement) initial_cost = calc.compute_cost() modifier = get_modifier(placement, seed=seed) new_placement = modifier.get_placement() return new_placement.get_io_grid(), new_placement.get_grid()
def apply_combination(vpr_args, io_grid, grid1, grid2, seed=None): with Silence(): vpr_context = VPRContext(vpr_args) p1 = vpr_context.get_random_placement() p1.set_io(io_grid) p1.set_grid(grid1) p2 = p1.copy() p2.set_grid(grid2) c = ConstrainedSwapPlacementCombination(p1, p2) best_grid, min_id, costs = c.swaps_min_placement(seed=None) return best_grid, min_id, costs
args.arch_file = path(args.arch_file[0]) assert(args.run_count > 0) return args if __name__ == '__main__': import sys args = _parse_args() vpr_args = ['./vpr', args.netlist_file, args.arch_file] + ('placed.out '\ 'routed.out -place_only -fast -nodisp -place_algorithm '\ 'bounding_box -seed %d' % args.seed).split(' ') print vpr_args vpr_context = VPRContext(vpr_args) new_placements = [] placement = vpr_context.get_random_placement() calc = BBCalculator.create(placement) initial_cost = calc.compute_cost() for i in range(args.run_count): modifier = get_modifier(placement, seed=i) new_placement = modifier.get_placement() new_placements.append(new_placement) final_costs = [] for p in new_placements: calc = BBCalculator.create(p) final_costs.append(calc.compute_cost())
if args.output_dir: args.output_dir = path(args.output_dir) args.output_dir.makedirs_p() args.netlist_file = path(args.netlist_file[0]) args.arch_file = path(args.arch_file[0]) assert(args.run_count > 0) return args if __name__ == '__main__': import sys args = _parse_args() vpr_context = VPRContext.annealer_context(args.netlist_file, args.arch_file, args.seed) # Note that each repeated call to get_random_placement() will return a # unique placement. placement1 = vpr_context.get_random_placement() placement2 = vpr_context.get_random_placement() # Since we currently do not process I/O placement in the anneal, for our # comparison between placements, we want to start all placements with the # same I/O positions. Therefore, we will use the positions from placement1 # to apply to placement2. placement2.set_io(placement1.get_io_grid()) c = ConstrainedSwapPlacementCombination(placement1, placement2) # Perform all swaps between placement1 and placement2, recording the fitness