gfx9: read VGPRs of halted waves
cover gfx9: read VGPRs of halted waves
Hi all,
it seems that reading wave VGPRs actually works now with gfx9, at least for halted waves, and that can be pretty powerful for debugging.
Due to the volume of data it prints out, it's only enabled with -O bits.
In order for it to work properly, you'll also need the kernel patch I just sent out (drm/amdgpu/gfx9: implement wave VGPR reading).
Please review!
Thanks,
Nicolai
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170909105530.10913-1-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/4 Fix wave SGPR reading
From: Nicolai Hähnle <[email protected]>
The hardware adds the alloc base already, no need to do it in the tool.
--- src/app/print_waves.c | 8 ++++---- src/lib/read_sgpr.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-)
src/app/print_waves.c +4 -4
@@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)"\n" , (unsigned )se, (unsigned )sh, (unsigned )cu, (unsigned )ws.hw_id.simd_id, (unsigned )ws.hw_id.wave_id, (unsigned long )ws.wave_status.value, (unsigned long )ws.pc_hi, (unsigned long )ws.pc_lo, (unsigned long )ws.wave_inst_dw0, (unsigned long )ws.wave_inst_dw1, (unsigned long )ws.exec_hi, (unsigned long )ws.exec_lo, (unsigned long )ws.hw_id.value, (unsigned long )ws.gpr_alloc.value, (unsigned long )ws.lds_alloc.value, (unsigned long )ws.trapsts.value, (unsigned long )ws.ib_sts.value, (unsigned long )ws.tba_hi, (unsigned long )ws.tba_lo, (unsigned long )ws.tma_hi, (unsigned long )ws.tma_lo, (unsigned long )ws.ib_dbg0, (unsigned long )ws.m0 );if (ws.wave_status.halt)for (x =0 ; x < ((ws.gpr_alloc.sgpr_size +1 ) << shift); x +=4 )printf (">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n" , - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x), - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x +3 ), + (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); pgm_addr = (((uint64_t )ws.pc_hi <<32 ) | ws.pc_lo) - (sizeof (opcodes)/2 );umr_read_vram (asic, ws.hw_id.vm_id, pgm_addr,sizeof (opcodes), opcodes);for (x =0 ; x <sizeof (opcodes)/4 ; x++) { printf(">pgm[%lu@%llx] = %08lx\n", (unsigned long)ws.hw_id.vm_id,
@@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)Hv ("GPR_ALLOC" , ws.gpr_alloc.value);PP (gpr_alloc, vgpr_base);PP (gpr_alloc, vgpr_size);PP (gpr_alloc, sgpr_base);PP (gpr_alloc, sgpr_size);if (ws.wave_status.halt) {printf ("\n\nSGPRS:\n" );for (x =0 ; x < ((ws.gpr_alloc.sgpr_size +1 ) << shift); x +=4 )printf ("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n" , - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x), - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x +3 ), + (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); }printf ("\n\nPGM_MEM:\n" ); pgm_addr = (((uint64_t )ws.pc_hi <<32 ) | ws.pc_lo) - (sizeof (opcodes)/2 );umr_read_vram (asic, ws.hw_id.vm_id, pgm_addr,sizeof (opcodes), opcodes);for (x =0 ; x <sizeof (opcodes)/4 ; x++) {
src/lib/read_sgpr.c +3 -2
@@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *uint64_t addr, shift;if (asic->family <=FAMILY_CIK ) shift =3 ;// on SI..CIK allocations were done in 8-dword blocks else shift =4 ;// on VI allocations are in 16-dword blocks if (!asic->options.no_kernel) { addr = (1ULL <<60 ) |// reading SGPRs - ((uint64_t )ws->gpr_alloc.sgpr_base << shift) |// starting address to read from + ((uint64_t )0 ) |// starting address to read from ((uint64_t )ws->hw_id.se_id <<12 ) | ((uint64_t )ws->hw_id.sh_id <<20 ) | ((uint64_t )ws->hw_id.cu_id <<28 ) | ((uint64_t )ws->hw_id.wave_id <<36 ) | ((uint64_t )ws->hw_id.simd_id <<44 ) | (0ULL <<52 );// thread_id lseek (asic->fd.gpr, addr,SEEK_SET );return read (asic->fd.gpr, dst,4 * ((ws->gpr_alloc.sgpr_size +1 ) << shift)); }else {umr_grbm_select_index (asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id); -wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id, ws->gpr_alloc.sgpr_base << shift,0 , (ws->gpr_alloc.sgpr_size +1 ) << shift, dst); +wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id,0 ,0 , + (ws->gpr_alloc.sgpr_size +1 ) << shift, dst);umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF );return 0 ; } }
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170909105530.10913-2-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH umr 1/4] Fix wave SGPR reading
Hi Nicolai,
I don't get this patch, 'x' starts at 0 and goes to sgpr_size but that doesn't include the offset into the SGPR space right?
I mean I get the patch in umr_read_sgprs() but in print_waves() won't that mean you're printing out SGPRS[0..size]?
Or are you saying having the base added to the printout is confusing for UMD debugging since the shader you're debugging probably doesn't have the offsets explicitly stated?
Cheers,
Tom
Quoted 90 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
The hardware adds the alloc base already, no need to do it in the tool.
Signed-off-by Nicolai Hähnle <[email protected]>--- src/app/print_waves.c | 8 ++++---- src/lib/read_sgpr.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-)src/app/print_waves.c +4
-4@@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)"\n" , (unsigned )se, (unsigned )sh, (unsigned )cu, (unsigned )ws.hw_id.simd_id, (unsigned )ws.hw_id.wave_id, (unsigned long )ws.wave_status.value, (unsigned long )ws.pc_hi, (unsigned long )ws.pc_lo, (unsigned long )ws.wave_inst_dw0, (unsigned long )ws.wave_inst_dw1, (unsigned long )ws.exec_hi, (unsigned long )ws.exec_lo, (unsigned long )ws.hw_id.value, (unsigned long )ws.gpr_alloc.value, (unsigned long )ws.lds_alloc.value, (unsigned long )ws.trapsts.value, (unsigned long )ws.ib_sts.value, (unsigned long )ws.tba_hi, (unsigned long )ws.tba_lo, (unsigned long )ws.tma_hi, (unsigned long )ws.tma_lo, (unsigned long )ws.ib_dbg0, (unsigned long )ws.m0 );if (ws.wave_status.halt)for (x =0 ; x < ((ws.gpr_alloc.sgpr_size +1 ) << shift); x +=4 )printf (">SGPRS[%u..%u] = { %08lx, %08lx, %08lx, %08lx }\n" , - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x), - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x +3 ), + (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); pgm_addr = (((uint64_t )ws.pc_hi <<32 ) | ws.pc_lo) - (sizeof (opcodes)/2 );umr_read_vram (asic, ws.hw_id.vm_id, pgm_addr,sizeof (opcodes), opcodes);for (x =0 ; x <sizeof (opcodes)/4 ; x++) { printf(">pgm[%lu@%llx] = %08lx\n", (unsigned long)ws.hw_id.vm_id,@@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)Hv ("GPR_ALLOC" , ws.gpr_alloc.value);PP (gpr_alloc, vgpr_base);PP (gpr_alloc, vgpr_size);PP (gpr_alloc, sgpr_base);PP (gpr_alloc, sgpr_size);if (ws.wave_status.halt) {printf ("\n\nSGPRS:\n" );for (x =0 ; x < ((ws.gpr_alloc.sgpr_size +1 ) << shift); x +=4 )printf ("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n" , - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x), - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x +3 ), + (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); }printf ("\n\nPGM_MEM:\n" ); pgm_addr = (((uint64_t )ws.pc_hi <<32 ) | ws.pc_lo) - (sizeof (opcodes)/2 );umr_read_vram (asic, ws.hw_id.vm_id, pgm_addr,sizeof (opcodes), opcodes);for (x =0 ; x <sizeof (opcodes)/4 ; x++) {src/lib/read_sgpr.c +1
-1@@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *uint64_t addr, shift;if (asic->family <=FAMILY_CIK ) shift =3 ;// on SI..CIK allocations were done in 8-dword blocks else shift =4 ;// on VI allocations are in 16-dword blocks if (!asic->options.no_kernel) { addr = (1ULL <<60 ) |// reading SGPRs - ((uint64_t )ws->gpr_alloc.sgpr_base << shift) |// starting address to read from + ((uint64_t )0 ) |// starting address to read from ((uint64_t )ws->hw_id.se_id <<12 ) | ((uint64_t )ws->hw_id.sh_id <<20 ) | ((uint64_t )ws->hw_id.cu_id <<28 ) | ((uint64_t )ws->hw_id.wave_id <<36 ) | ((uint64_t )ws->hw_id.simd_id <<44 ) | (0ULL <<52 );// thread_id lseek (asic->fd.gpr, addr,SEEK_SET );
src/lib/read_sgpr.c int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t * · line 83
Quoted 10 lines
src/lib/read_sgpr.c +2
-1return read (asic->fd.gpr, dst,4 * ((ws->gpr_alloc.sgpr_size +1 ) << shift)); }else {umr_grbm_select_index (asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id); -wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id, ws->gpr_alloc.sgpr_base << shift,0 , (ws->gpr_alloc.sgpr_size +1 ) << shift, dst); +wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id,0 ,0 , + (ws->gpr_alloc.sgpr_size +1 ) << shift, dst);umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF );return 0 ; } }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): d0cd7c52-c14d-4d54-81d8-39141ff429b1-5C7GfCeVMHo@public.gmane.org
Re: [PATCH umr 1/4] Fix wave SGPR reading
Quoted 7 lines · Tom St Denis
Hi Nicolai,
I don't get this patch, 'x' starts at 0 and goes to
sgpr_sizebut that doesn't include the offset into the SGPR space right?I mean I get the patch in
umr_read_sgprs()but inprint_waves()won't that mean you're printing out SGPRS[0..size]?Or are you saying having the base added to the printout is confusing for UMD debugging since the shader you're debugging probably doesn't have the offsets explicitly stated?
Precisely.
It's not a huge deal, but it's slightly easier to follow along the register dump and shader disassembly side-by-side when they both use the same indexing into the register files :)
Cheers,
Nicolai
Quoted 130 lines
Cheers,
TomQuoted 113 lines · Nicolai Hähnle
From: Nicolai Hähnle <[email protected]>
The hardware adds the alloc base already, no need to do it in the tool.
Signed-off-by Nicolai Hähnle <[email protected]>--- src/app/print_waves.c | 8 ++++---- src/lib/read_sgpr.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-)src/app/print_waves.c +0
-0@@ -75,22 +75,22 @@ void umr_print_waves(struct umr_asic *asic)"\n" , (unsigned )se, (unsigned )sh, (unsigned )cu, (unsigned )ws.hw_id.simd_id, (unsigned )ws.hw_id.wave_id, (unsigned long )ws.wave_status.value, (unsigned long )ws.pc_hi, (unsigned long )ws.pc_lo, (unsigned long )ws.wave_inst_dw0, (unsigned long )ws.wave_inst_dw1, (unsigned long )ws.exec_hi, (unsigned long )ws.exec_lo, (unsigned long )ws.hw_id.value, (unsigned long )ws.gpr_alloc.value, (unsigned long )ws.lds_alloc.value, (unsigned long )ws.trapsts.value, (unsigned long )ws.ib_sts.value, (unsigned long)ws.tba_hi, (unsigned long)ws.tba_lo, (unsignedlong)ws.tma_hi, (unsigned long)ws.tma_lo, (unsigned long)ws.ib_dbg0, (unsigned long)ws.m0
); if (ws.wave_status.halt) for (x = 0; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4) printf(">SGPRS[%u..%u] = { %08lx,%08lx, %08lx, %08lx }\n",
-
(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x), -
(unsigned)((ws.gpr_alloc.sgpr_base << shift) + x + 3),src/app/print_waves.c +2
-0+ (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long)sgprs[x+3]); pgm_addr = (((uint64_t)ws.pc_hi << 32) |ws.pc_lo) - (sizeof(opcodes)/2); umr_read_vram(asic, ws.hw_id.vm_id, pgm_addr, sizeof(opcodes), opcodes); for (x = 0; x < sizeof(opcodes)/4; x++) { printf(">pgm[%lu@%llx] = %08lx\n", (unsigned long)ws.hw_id.vm_id,src/app/print_waves.c +3
-2@@ -156,22 +156,22 @@ void umr_print_waves(struct umr_asic *asic)Hv ("GPR_ALLOC" , ws.gpr_alloc.value);PP (gpr_alloc, vgpr_base);PP (gpr_alloc, vgpr_size);PP (gpr_alloc, sgpr_base);PP (gpr_alloc, sgpr_size);if (ws.wave_status.halt) {printf ("\n\nSGPRS:\n" );for (x =0 ; x < ((ws.gpr_alloc.sgpr_size + 1) << shift); x += 4) printf("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n", - (unsigned)((ws.gpr_alloc.sgpr_base << shift) + x), - (unsigned )((ws.gpr_alloc.sgpr_base << shift) + x +3 ), + (unsigned )(x), + (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); }printf ("\n\nPGM_MEM:\n" ); pgm_addr = (((uint64_t)ws.pc_hi << 32) |ws.pc_lo) - (sizeof(opcodes)/2); umr_read_vram(asic, ws.hw_id.vm_id, pgm_addr, sizeof(opcodes), opcodes); for (x = 0; x < sizeof(opcodes)/4; x++) {src/lib/read_sgpr.c +0
-0@@ -56,27 +56,28 @@ int umr_read_sgprs(struct umr_asic *asic, struct
umr_wave_status*ws,uint32_t*uint64_t addr, shift; if (asic->family <= FAMILY_CIK) shift = 3; // on SI..CIK allocations were done in 8-dwordblocks
else
shift = 4; // on VI allocations are in 16-dword blocks
if (!asic->options.no_kernel) {
addr =
(1ULL << 60) | // reading SGPRs
- ((uint64_t)ws->gpr_alloc.sgpr_base << shift) | //
starting address to read from
+ ((uint64_t)0) | // starting
address to read from((uint64_t)ws->hw_id.se_id << 12) | ((uint64_t)ws->hw_id.sh_id << 20) | ((uint64_t)ws->hw_id.cu_id << 28) | ((uint64_t)ws->hw_id.wave_id << 36) | ((uint64_t)ws->hw_id.simd_id << 44) | (0ULL << 52); // thread_id lseek(asic->fd.gpr, addr, SEEK_SET); return read(asic->fd.gpr, dst, 4 * ((ws->gpr_alloc.sgpr_size + 1) << shift)); } else { umr_grbm_select_index(asic, ws->hw_id.se_id,
ws->hw_id.sh_id,ws->hw_id.cu_id);
- wave_read_regs_via_mmio(asic,ws->hw_id.simd_id,ws->hw_id.wave_id,ws->gpr_alloc.sgpr_base<< shift, 0, (ws->gpr_alloc.sgpr_size+ 1) << shift, dst);
+ wave_read_regs_via_mmio(asic,ws->hw_id.simd_id,ws->hw_id.wave_id, 0, 0,Quoted 7 lines
+ (ws->gpr_alloc.sgpr_size + 1) << shift, dst); umr_grbm_select_index(asic, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); return 0; }}
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Signature · 6 lines
Lerne, wie die Welt wirklich ist, Aber vergiss niemals, wie sie sein sollte. _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 Rename lib/read_sgpr.c to lib/read_gpr.c
In reply to a message not in the archiveFrom: Nicolai Hähnle <[email protected]>
We will implement VGPR reading, hence this is a better name.
---
src/lib/CMakeLists.txt | 2 +-
src/lib/{read_sgpr.c => read_gpr.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename src/lib/{read_sgpr.c => read_gpr.c} (100%)src/lib/CMakeLists.txt +1 -1
@@ -11,21 +11,21 @@ add_library(umrcore STATIC create_mmio_accel.c discover_by_did.c discover_by_name.c discover.c dump_ib.c find_reg.c free_maps.c mmio.c query_drm.c read_sensor.c - read_sgpr.c + read_gpr.c read_vram.c ring_decode.c scan_config.c sq_cmd_halt_waves.c transfer_soc15.c wave_status.c update.c $<TARGET_OBJECTS:asic> $<TARGET_OBJECTS:ip> )
src/lib/read_gpr.c renamed from src/lib/read_sgpr.c +0 -0
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 Read VGPRs of halted waves on gfx9
In reply to a message not in the archiveFrom: Nicolai Hähnle <[email protected]>
--- src/app/print_waves.c | 40 +++++++++++++++++++++++++++++++++++++++- src/lib/read_gpr.c | 30 ++++++++++++++++++++++++++++++ src/umr.h | 1 + 3 files changed, 70 insertions(+), 1 deletion(-)
src/app/print_waves.c +39 -1
@@ -29,20 +29,22 @@#define P (x) if (col++ == 4) { col = 1; printf("\n\t"); } printf("%20s: %8u | ", #x, (unsigned)ws.x);#define X (x) if (col++ == 4) { col = 1; printf("\n\t"); } printf("%20s: %08lx | ", #x, (unsigned long)ws.x);#define H (x) if (col) { printf("\n"); }; col = 0; printf("\n\n%s:\n\t", x);#define Hv (x, y) if (col) { printf("\n"); }; col = 0; printf("\n\n%s[%08lx]:\n\t", x, (unsigned long)y);void umr_print_waves (struct umr_asic *asic) {uint32_t x, se, sh, cu, simd, wave, sgprs[1024 ], shift, opcodes[8 ]; +uint32_t vgprs[64 *256 ]; +uint32_t thread;uint64_t pgm_addr;struct umr_wave_status ws;int first =1 , col =0 ;if (asic->options.halt_waves)umr_sq_cmd_halt_waves (asic,UMR_SQ_CMD_HALT );if (asic->family <=FAMILY_CIK ) shift =3 ;// on SI..CIK allocations were done in 8-dword blocks else
@@ -50,24 +52,36 @@ void umr_print_waves(struct umr_asic *asic)for (se =0 ; se < asic->config.gfx.max_shader_engines; se++)for (sh =0 ; sh < asic->config.gfx.max_sh_per_se; sh++)for (cu =0 ; cu < asic->config.gfx.max_cu_per_sh; cu++) {umr_get_wave_sq_info (asic, se, sh, cu, &ws);if (ws.sq_info.busy) {for (simd =0 ; simd <4 ; simd++)for (wave =0 ; wave <10 ; wave++) {//both simd/wave are hard coded at the moment... umr_get_wave_status (asic, se, sh, cu, simd, wave, &ws);if (ws.wave_status.halt || ws.wave_status.valid) { +unsigned have_vgprs =0 ; +// grab sgprs.. -if (ws.wave_status.halt) +if (ws.wave_status.halt) {umr_read_sgprs (asic, &ws, &sgprs[0 ]); +if (options.bitfields) { + have_vgprs =1 ; +for (thread =0 ; thread <64 ; ++thread) { +if (umr_read_vgprs (asic, &ws, thread, + &vgprs[256 * thread]) <0 ) + have_vgprs =0 ; + } + } + } +if (!options.bitfields && first) { first =0 ;printf ("SE SH CU SIMD WAVE# WAVE_STATUS PC_HI PC_LO INST_DW0 INST_DW1 EXEC_HI EXEC_LO HW_ID GPRALLOC LDSALLOC TRAPSTS IBSTS TBA_HI TBA_LO TMA_HI TMA_LO IB_DBG0 M0\n" ); }if (!options.bitfields) {printf ("%u %u %u %u %u " // se/sh/cu/simd/wave "%08lx %08lx %08lx " // wave_status pc/hi/lo "%08lx %08lx %08lx %08lx " // inst0/1 exec hi/lo "%08lx %08lx %08lx %08lx %08lx " // HW_ID GPR/LDSALLOC TRAP/IB STS
@@ -164,20 +178,44 @@ void umr_print_waves(struct umr_asic *asic)for (x =0 ; x < ((ws.gpr_alloc.sgpr_size +1 ) << shift); x +=4 )printf ("\t[%4u..%4u] = { %08lx, %08lx, %08lx, %08lx }\n" , (unsigned )(x), (unsigned )(x +3 ), (unsigned long )sgprs[x], (unsigned long )sgprs[x+1 ], (unsigned long )sgprs[x+2 ], (unsigned long )sgprs[x+3 ]); } + +if (have_vgprs) { +printf ("\n" ); +for (x =0 ; x < ((ws.gpr_alloc.vgpr_size +1 ) <<2 ); ++x) { +if (x %16 ==0 ) { +if (x ==0 ) +printf ("VGPRS: " ); +else +printf (" " ); +for (thread =0 ; thread <64 ; ++thread) { +unsigned live = thread <32 ? (ws.exec_lo & (1u << thread)) + : (ws.exec_hi & (1u << (thread -32 ))); +printf (live ?" t%02u " :" (t%02u) " , thread); + } +printf ("\n" ); + } + +printf (" [%3u] = {" , x); +for (thread =0 ; thread <64 ; ++thread) +printf (" %08x" , vgprs[thread *256 + x]); +printf (" }\n" ); + } + } +printf ("\n\nPGM_MEM:\n" ); pgm_addr = (((uint64_t )ws.pc_hi <<32 ) | ws.pc_lo) - (sizeof (opcodes)/2 );umr_read_vram (asic, ws.hw_id.vm_id, pgm_addr,sizeof (opcodes), opcodes);for (x =0 ; x <sizeof (opcodes)/4 ; x++) {if (x == (sizeof (opcodes)/8 ))printf ("*\t" );else printf ("\t" ); printf("pgm[%lu@%llx] = %08lx\n", (unsigned long)ws.hw_id.vm_id,
src/lib/read_gpr.c +30 -0
@@ -74,10 +74,40 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t *lseek (asic->fd.gpr, addr,SEEK_SET );return read (asic->fd.gpr, dst,4 * ((ws->gpr_alloc.sgpr_size +1 ) << shift)); }else {umr_grbm_select_index (asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id);wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id,0 ,0 , (ws->gpr_alloc.sgpr_size +1 ) << shift, dst);umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF );return 0 ; } } + + +int umr_read_vgprs (struct umr_asic *asic,struct umr_wave_status *ws,uint32_t thread,uint32_t *dst) +{ +uint64_t addr; + +if (asic->family <FAMILY_AI ) +return -1 ; + +if (!asic->options.no_kernel) { + addr = + (0ULL <<60 ) |// reading VGPRs + ((uint64_t )0 ) |// starting address to read from + ((uint64_t )ws->hw_id.se_id <<12 ) | + ((uint64_t )ws->hw_id.sh_id <<20 ) | + ((uint64_t )ws->hw_id.cu_id <<28 ) | + ((uint64_t )ws->hw_id.wave_id <<36 ) | + ((uint64_t )ws->hw_id.simd_id <<44 ) | + ((uint64_t )thread <<52 ); + +lseek (asic->fd.gpr, addr,SEEK_SET ); +return read (asic->fd.gpr, dst,4 * ((ws->gpr_alloc.vgpr_size +1 ) <<2 )); + }else { +umr_grbm_select_index (asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id); +wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id, thread,0x400 , + (ws->gpr_alloc.vgpr_size +1 ) <<2 , dst); +umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF ); +return 0 ; + } +}
src/umr.h +1 -0
@@ -494,20 +494,21 @@ void umr_free_asic(struct umr_asic *asic);void umr_free_maps (struct umr_asic *asic);void umr_close_asic (struct umr_asic *asic);// call this to close a fully open asic int umr_query_drm (struct umr_asic *asic,int field,void *ret,int size);void umr_enumerate_devices (void );int umr_update (struct umr_asic *asic,char *script);/* lib helpers */ int umr_get_wave_status (struct umr_asic *asic,unsigned se,unsigned sh,unsigned cu,unsigned simd,unsigned wave,struct umr_wave_status *ws);int umr_get_wave_sq_info (struct umr_asic *asic,unsigned se,unsigned sh,unsigned cu,struct umr_wave_status *ws);int umr_read_sgprs (struct umr_asic *asic,struct umr_wave_status *ws,uint32_t *dst); +int umr_read_vgprs (struct umr_asic *asic,struct umr_wave_status *ws,uint32_t thread,uint32_t *dst);int umr_read_sensor (struct umr_asic *asic,int sensor,void *dst,int *size);/* mmio helpers */ // init the mmio lookup table int umr_create_mmio_accel (struct umr_asic *asic);// find the word address of a register uint32_t umr_find_reg (struct umr_asic *asic,char *regname);// find the register data for a register
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 Fix the no-kernel case of wave SGPR reading
In reply to a message not in the archiveFrom: Nicolai Hähnle <[email protected]>
--- src/lib/read_gpr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/lib/read_gpr.c +1 -1
@@ -68,21 +68,21 @@ int umr_read_sgprs(struct umr_asic *asic, struct umr_wave_status *ws, uint32_t * ((uint64_t )ws->hw_id.sh_id <<20 ) | ((uint64_t )ws->hw_id.cu_id <<28 ) | ((uint64_t )ws->hw_id.wave_id <<36 ) | ((uint64_t )ws->hw_id.simd_id <<44 ) | (0ULL <<52 );// thread_id lseek (asic->fd.gpr, addr,SEEK_SET );return read (asic->fd.gpr, dst,4 * ((ws->gpr_alloc.sgpr_size +1 ) << shift)); }else {umr_grbm_select_index (asic, ws->hw_id.se_id, ws->hw_id.sh_id, ws->hw_id.cu_id); -wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id,0 ,0 , +wave_read_regs_via_mmio (asic, ws->hw_id.simd_id, ws->hw_id.wave_id,0 ,0x200 , (ws->gpr_alloc.sgpr_size +1 ) << shift, dst);umr_grbm_select_index (asic,0xFFFFFFFF ,0xFFFFFFFF ,0xFFFFFFFF );return 0 ; } }int umr_read_vgprs (struct umr_asic *asic,struct umr_wave_status *ws,uint32_t thread,uint32_t *dst) {uint64_t addr;
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Nicolai,
Patches look good I'll give them a whirl tomorrow when I have some free time. I'll have to dig out your headless piglit instructions since I still can't bring X up on my Raven board.
Also I noticed the use of "(options.bitfields)" (etc, in print_waves) which is not your bug (since I did it first hehehe) but is a bug ... they should all be "asic->options.bitfields" which I'll fix in a follow-up patch after.
(provided they apply and combined with the kernel patch doesn't oops on me I'll R-b + push them out tomorrow or Monday morning).
Thanks,
Tom
Quoted 12 lines · Nicolai Hähnle
Hi all,
it seems that reading wave VGPRs actually works now with gfx9, at least for halted waves, and that can be pretty powerful for debugging.
Due to the volume of data it prints out, it's only enabled with -O bits.
In order for it to work properly, you'll also need the kernel patch I just sent out (drm/amdgpu/gfx9: implement wave VGPR reading).
Please review!
Quoted 8 lines
Thanks,
Nicolai_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx