diff options
author | Tony Wasserka <tony.wasserka@gmx.de> | 2020-11-05 17:04:12 +0100 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-12-29 18:57:10 +0000 |
commit | d06abc263d33eb05816d530561299e20eabf7b78 (patch) | |
tree | eb1963dae1dda15c43d1c7cdff88d7b36745f2ba /src/amd/compiler | |
parent | 36097fc7ef70471ecfecd428f990233276e9c45b (diff) |
aco/ra: Add policy parameter to select implementation details for testing
This new policy parameter allows disabling the optimistic path of get_reg
(i.e. get_reg_simple) to improve test coverage of the pessimistic path
provided by get_reg_impl.
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7461>
Diffstat (limited to 'src/amd/compiler')
-rw-r--r-- | src/amd/compiler/aco_ir.h | 8 | ||||
-rw-r--r-- | src/amd/compiler/aco_register_allocation.cpp | 32 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 8eb0cba49fb..5cb6360f781 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1789,6 +1789,11 @@ struct live { std::vector<std::vector<RegisterDemand>> register_demand; }; +struct ra_test_policy { + /* Force RA to always use its pessimistic fallback algorithm */ + bool skip_optimistic_path = false; +}; + void init(); void init_program(Program *program, Stage stage, struct radv_shader_info *info, @@ -1818,7 +1823,8 @@ void value_numbering(Program* program); void optimize(Program* program); void setup_reduce_temp(Program* program); void lower_to_cssa(Program* program, live& live_vars); -void register_allocation(Program *program, std::vector<IDSet>& live_out_per_block); +void register_allocation(Program *program, std::vector<IDSet>& live_out_per_block, + ra_test_policy = {}); void ssa_elimination(Program* program); void lower_to_hw_instr(Program* program); void schedule_program(Program* program, live& live_vars); diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index c672e4d81b7..d5a921eece7 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -77,12 +77,16 @@ struct ra_ctx { unsigned max_used_vgpr = 0; std::bitset<64> defs_done; /* see MAX_ARGS in aco_instruction_selection_setup.cpp */ - ra_ctx(Program* program_) : program(program_), - assignments(program->peekAllocationId()), - renames(program->blocks.size()), - incomplete_phis(program->blocks.size()), - filled(program->blocks.size()), - sealed(program->blocks.size()) + ra_test_policy policy; + + ra_ctx(Program* program_, ra_test_policy policy_) + : program(program_), + assignments(program->peekAllocationId()), + renames(program->blocks.size()), + incomplete_phis(program->blocks.size()), + filled(program->blocks.size()), + sealed(program->blocks.size()), + policy(policy_) { pseudo_dummy.reset(create_instruction<Instruction>(aco_opcode::p_parallelcopy, Format::PSEUDO, 0, 0)); } @@ -1231,11 +1235,15 @@ PhysReg get_reg(ra_ctx& ctx, DefInfo info(ctx, instr, temp.regClass(), operand_index); - /* try to find space without live-range splits */ - std::pair<PhysReg, bool> res = get_reg_simple(ctx, reg_file, info); + std::pair<PhysReg, bool> res; - if (res.second) - return res.first; + if (!ctx.policy.skip_optimistic_path) { + /* try to find space without live-range splits */ + res = get_reg_simple(ctx, reg_file, info); + + if (res.second) + return res.first; + } /* try to find space with live-range splits */ res = get_reg_impl(ctx, reg_file, parallelcopies, info, instr); @@ -1703,9 +1711,9 @@ void try_remove_trivial_phi(ra_ctx& ctx, Temp temp) } /* end namespace */ -void register_allocation(Program *program, std::vector<IDSet>& live_out_per_block) +void register_allocation(Program *program, std::vector<IDSet>& live_out_per_block, ra_test_policy policy) { - ra_ctx ctx(program); + ra_ctx ctx(program, policy); std::vector<std::vector<Temp>> phi_ressources; std::unordered_map<unsigned, unsigned> temp_to_phi_ressources; |