program->lds_alloc_granule = args->options->chip_class >= GFX7 ? 512 : 256;
program->lds_limit = args->options->chip_class >= GFX7 ? 65536 : 32768;
program->vgpr_limit = 256;
+ program->vgpr_alloc_granule = 3;
if (args->options->chip_class >= GFX10) {
program->physical_sgprs = 2560; /* doesn't matter as long as it's at least 128 * 20 */
program->sgpr_alloc_granule = 127;
program->sgpr_limit = 106;
+ program->vgpr_alloc_granule = program->wave_size == 32 ? 7 : 3;
} else if (program->chip_class >= GFX8) {
program->physical_sgprs = 800;
program->sgpr_alloc_granule = 15;
uint16_t sgpr_limit;
uint16_t physical_sgprs;
uint16_t sgpr_alloc_granule; /* minus one. must be power of two */
+ uint16_t vgpr_alloc_granule; /* minus one. must be power of two */
bool needs_vcc = false;
bool needs_xnack_mask = false;
/* number of sgprs that need to be allocated but might notbe addressable as s0-s105 */
uint16_t get_extra_sgprs(Program *program);
-/* get number of sgprs allocated required to address a number of sgprs */
+/* get number of sgprs/vgprs allocated required to address a number of sgprs/vgprs */
uint16_t get_sgpr_alloc(Program *program, uint16_t addressable_sgprs);
+uint16_t get_vgpr_alloc(Program *program, uint16_t addressable_vgprs);
-/* return number of addressable SGPRs for max_waves */
+/* return number of addressable sgprs/vgprs for max_waves */
uint16_t get_addr_sgpr_from_waves(Program *program, uint16_t max_waves);
+uint16_t get_addr_vgpr_from_waves(Program *program, uint16_t max_waves);
typedef struct {
const int16_t opcode_gfx7[static_cast<int>(aco_opcode::num_opcodes)];
return align(std::max(sgprs, granule), granule);
}
+uint16_t get_vgpr_alloc(Program *program, uint16_t addressable_vgprs)
+{
+ assert(addressable_vgprs <= program->vgpr_limit);
+ uint16_t granule = program->vgpr_alloc_granule + 1;
+ return align(std::max(addressable_vgprs, granule), granule);
+}
+
uint16_t get_addr_sgpr_from_waves(Program *program, uint16_t max_waves)
{
uint16_t sgprs = program->physical_sgprs / max_waves & ~program->sgpr_alloc_granule;
return std::min(sgprs, program->sgpr_limit);
}
+uint16_t get_addr_vgpr_from_waves(Program *program, uint16_t max_waves)
+{
+ uint16_t vgprs = 256 / max_waves & ~program->vgpr_alloc_granule;
+ return std::min(vgprs, program->vgpr_limit);
+}
+
void update_vgpr_sgpr_demand(Program* program, const RegisterDemand new_demand)
{
/* TODO: max_waves_per_simd, simd_per_cu and the number of physical vgprs for Navi */
unsigned simd_per_cu_wgp = wgp ? simd_per_cu * 2 : simd_per_cu;
unsigned lds_limit = wgp ? program->lds_limit * 2 : program->lds_limit;
- const int16_t vgpr_alloc = std::max<int16_t>(4, (new_demand.vgpr + 3) & ~3);
/* this won't compile, register pressure reduction necessary */
if (new_demand.vgpr > program->vgpr_limit || new_demand.sgpr > program->sgpr_limit) {
program->num_waves = 0;
program->max_reg_demand = new_demand;
} else {
program->num_waves = program->physical_sgprs / get_sgpr_alloc(program, new_demand.sgpr);
- program->num_waves = std::min<uint16_t>(program->num_waves, 256 / vgpr_alloc);
+ program->num_waves = std::min<uint16_t>(program->num_waves, 256 / get_vgpr_alloc(program, new_demand.vgpr));
program->max_waves = max_waves_per_simd;
/* adjust max_waves for workgroup and LDS limits */
/* incorporate max_waves and calculate max_reg_demand */
program->num_waves = std::min<uint16_t>(program->num_waves, program->max_waves);
- program->max_reg_demand.vgpr = int16_t((256 / program->num_waves) & ~3);
+ program->max_reg_demand.vgpr = get_addr_vgpr_from_waves(program, program->num_waves);
program->max_reg_demand.sgpr = get_addr_sgpr_from_waves(program, program->num_waves);
}
}
ctx.num_waves = 8;
assert(ctx.num_waves > 0 && ctx.num_waves <= program->num_waves);
- ctx.max_registers = { int16_t(((256 / ctx.num_waves) & ~3) - 2), int16_t(get_addr_sgpr_from_waves(program, ctx.num_waves))};
+ ctx.max_registers = { int16_t(get_addr_vgpr_from_waves(program, ctx.num_waves) - 2),
+ int16_t(get_addr_sgpr_from_waves(program, ctx.num_waves))};
for (Block& block : program->blocks)
schedule_block(ctx, program, &block, live_vars);