gpu-compute: Add DebugFlag for LDS
This prints what values are read/written to LDS and the previous value on write. This is useful for debugging problems with LDS instructions. Change-Id: I30063327bec1a1a808914a018467d5d78d5d58b4
This commit is contained in:
@@ -84,6 +84,7 @@ DebugFlag('GPUExec')
|
||||
DebugFlag('GPUFetch')
|
||||
DebugFlag('GPUInst')
|
||||
DebugFlag('GPUKernelInfo')
|
||||
DebugFlag('GPULDS')
|
||||
DebugFlag('GPUMem')
|
||||
DebugFlag('GPUPort')
|
||||
DebugFlag('GPUPrefetch')
|
||||
@@ -106,4 +107,4 @@ DebugFlag('WavefrontStack')
|
||||
CompoundFlag('GPUALL', ['GPUCoalescer', 'GPUDisp', 'GPUExec', 'GPUFetch',
|
||||
'GPUMem', 'GPUPort', 'GPUSched', 'GPUSRF', 'GPUSync',
|
||||
'GPUTLB', 'GPUVRF', 'GPURFC', 'GPUWgLatency',
|
||||
'GPUKernelInfo', 'GPUInitAbi'])
|
||||
'GPUKernelInfo', 'GPUInitAbi', 'GPULDS'])
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "debug/GPULDS.hh"
|
||||
#include "gpu-compute/misc.hh"
|
||||
#include "mem/port.hh"
|
||||
#include "params/LdsState.hh"
|
||||
@@ -75,10 +76,30 @@ class LdsChunk
|
||||
* chunk allocated to this WG we return 0.
|
||||
*/
|
||||
if (index >= chunk.size()) {
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Read 0 beyond size (%ld)\n",
|
||||
dispatchId, wgId, chunk.size());
|
||||
return (T)0;
|
||||
}
|
||||
|
||||
T *p0 = (T *) (&(chunk.at(index)));
|
||||
|
||||
if (sizeof(T) <= 4) {
|
||||
[[maybe_unused]] uint32_t int_val =
|
||||
*reinterpret_cast<uint32_t*>(p0);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Read %08x from index %d\n",
|
||||
dispatchId, wgId, int_val, index);
|
||||
} else if (sizeof(T) <= 8) {
|
||||
[[maybe_unused]] uint64_t int_val =
|
||||
*reinterpret_cast<uint64_t*>(p0);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Read %016lx from index %d\n",
|
||||
dispatchId, wgId, int_val, index);
|
||||
} else if (sizeof(T) <= 16) {
|
||||
[[maybe_unused]] uint64_t *int_vals =
|
||||
reinterpret_cast<uint64_t*>(p0);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Read %016lx%016lx from index %d\n",
|
||||
dispatchId, wgId, int_vals[1], int_vals[0], index);
|
||||
}
|
||||
|
||||
return *p0;
|
||||
}
|
||||
|
||||
@@ -94,10 +115,33 @@ class LdsChunk
|
||||
* chunk allocated to this WG are dropped.
|
||||
*/
|
||||
if (index >= chunk.size()) {
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Ignoring write beyond size (%ld)\n",
|
||||
dispatchId, wgId, chunk.size());
|
||||
return;
|
||||
}
|
||||
|
||||
T *p0 = (T *) (&(chunk.at(index)));
|
||||
|
||||
if (sizeof(T) <= 4) {
|
||||
[[maybe_unused]] uint32_t prev_val =
|
||||
*reinterpret_cast<uint32_t*>(p0);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Write %08lx to index %d (was "
|
||||
"%08lx)\n", dispatchId, wgId, value, index, prev_val);
|
||||
} else if (sizeof(T) <= 8) {
|
||||
[[maybe_unused]] uint64_t prev_val =
|
||||
*reinterpret_cast<uint64_t*>(p0);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Write %016lx to index %d (was "
|
||||
"%016lx)\n", dispatchId, wgId, value, index, prev_val);
|
||||
} else if (sizeof(T) <= 16) {
|
||||
[[maybe_unused]] uint64_t *prev_vals =
|
||||
reinterpret_cast<uint64_t*>(p0);
|
||||
[[maybe_unused]] const uint64_t *next_vals =
|
||||
reinterpret_cast<const uint64_t*>(&value);
|
||||
DPRINTF(GPULDS, "LDS[%d][%d]: Write %016lx%016lx to index %d "
|
||||
"(was %016lx%016lx)\n", dispatchId, wgId, next_vals[1],
|
||||
next_vals[0], index, prev_vals[1], prev_vals[0]);
|
||||
}
|
||||
|
||||
*p0 = value;
|
||||
}
|
||||
|
||||
@@ -131,6 +175,9 @@ class LdsChunk
|
||||
return chunk.size();
|
||||
}
|
||||
|
||||
uint32_t dispatchId;
|
||||
uint32_t wgId;
|
||||
|
||||
protected:
|
||||
// the actual data store for this slice of the LDS
|
||||
std::vector<uint8_t> chunk;
|
||||
@@ -402,6 +449,9 @@ class LdsState: public ClockedObject
|
||||
// make an entry for this workgroup
|
||||
refCounter[dispatchId][wgId] = 0;
|
||||
|
||||
chunkMap[dispatchId][wgId].dispatchId = dispatchId;
|
||||
chunkMap[dispatchId][wgId].wgId = wgId;
|
||||
|
||||
return &chunkMap[dispatchId][wgId];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user