aco: add ACO_DEBUG=force-waitcnt to emit wait-states
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 19 Aug 2020 08:40:35 +0000 (10:40 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Aug 2020 11:22:58 +0000 (13:22 +0200)
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 <samuel.pitoiset@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6386>

docs/envvars.rst
src/amd/compiler/aco_insert_waitcnt.cpp
src/amd/compiler/aco_ir.cpp
src/amd/compiler/aco_ir.h

index 4beba25b43f5a0e807b0b407b03ebfcf988d263c..cee45fb306d3791ed434bb8a4617334a1420c592 100644 (file)
@@ -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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index db0c7c0d68c38457a98a857e4632bcc178734ad2..751892e44368a476d1f1ff44261826d536037691 100644 (file)
@@ -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));
 
index 2a0a500a7b69c9e2803e2c26ac05af86ce295749..801fbc68616be47af44a9f83abb9e6c358e7454c 100644 (file)
@@ -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}
 };
 
index 0b3a7767a3c3b851c0d9ded61d5da9b616ef5f24..0e5b69a7863b7e088ff01fbc82f2c74f1991df90 100644 (file)
@@ -51,6 +51,7 @@ enum {
    DEBUG_VALIDATE_IR = 0x1,
    DEBUG_VALIDATE_RA = 0x2,
    DEBUG_PERFWARN = 0x4,
+   DEBUG_FORCE_WAITCNT = 0x8,
 };
 
 /**