From: Samuel Pitoiset Date: Wed, 19 Aug 2020 08:40:35 +0000 (+0200) Subject: aco: add ACO_DEBUG=force-waitcnt to emit wait-states X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=f15315173032714b1cc4c1820e50b95ae29dd88c;hp=258ef4d4a4b6c11b141e12e6736b01f408461c1d aco: add ACO_DEBUG=force-waitcnt to emit wait-states Sounds useful for debugging missing wait-states and for improving detection of the faulty instruction in case of memory violations. Signed-off-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Part-of: --- diff --git a/docs/envvars.rst b/docs/envvars.rst index 4beba25b43f..cee45fb306d 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -612,6 +612,8 @@ RADV driver environment variables validate register assignment of ACO IR and catches many RA bugs ``perfwarn`` abort on some suboptimal code generation + ``force-waitcnt`` + force emitting waitcnt states if there is something to wait for radeonsi driver environment variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/amd/compiler/aco_insert_waitcnt.cpp b/src/amd/compiler/aco_insert_waitcnt.cpp index db0c7c0d68c..751892e4436 100644 --- a/src/amd/compiler/aco_insert_waitcnt.cpp +++ b/src/amd/compiler/aco_insert_waitcnt.cpp @@ -473,9 +473,32 @@ wait_imm perform_barrier(wait_ctx& ctx, memory_sync_info sync, unsigned semantic return imm; } +void force_waitcnt(wait_ctx& ctx, wait_imm& imm) +{ + if (ctx.vm_cnt) + imm.vm = 0; + if (ctx.exp_cnt) + imm.exp = 0; + if (ctx.lgkm_cnt) + imm.lgkm = 0; + + if (ctx.chip_class >= GFX10) { + if (ctx.vs_cnt) + imm.vs = 0; + } +} + wait_imm kill(Instruction* instr, wait_ctx& ctx, memory_sync_info sync_info) { wait_imm imm; + + if (debug_flags & DEBUG_FORCE_WAITCNT) { + /* Force emitting waitcnt states right after the instruction if there is + * something to wait for. + */ + force_waitcnt(ctx, imm); + } + if (ctx.exp_cnt || ctx.vm_cnt || ctx.lgkm_cnt) imm.combine(check_instr(instr, ctx)); diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp index 2a0a500a7b6..801fbc68616 100644 --- a/src/amd/compiler/aco_ir.cpp +++ b/src/amd/compiler/aco_ir.cpp @@ -34,6 +34,7 @@ static const struct debug_control aco_debug_options[] = { {"validateir", DEBUG_VALIDATE_IR}, {"validatera", DEBUG_VALIDATE_RA}, {"perfwarn", DEBUG_PERFWARN}, + {"force-waitcnt", DEBUG_FORCE_WAITCNT}, {NULL, 0} }; diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 0b3a7767a3c..0e5b69a7863 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -51,6 +51,7 @@ enum { DEBUG_VALIDATE_IR = 0x1, DEBUG_VALIDATE_RA = 0x2, DEBUG_PERFWARN = 0x4, + DEBUG_FORCE_WAITCNT = 0x8, }; /**