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()
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()) np_final_costs = np.array(final_costs) print 'Initial cost: %s' % initial_cost print 'Final costs: %s' % np_final_costs print 'Mean cost: %s' % np.mean(np_final_costs)