asahi: scratch: Add feature to debug core IDs

Define SCRATCH_DEBUG_CORES to a raw core count to bypass the mapping
machinery and allocate memory for many cores, so we can work out how the
core IDs are mapped.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27616>
This commit is contained in:
Asahi Lina 2024-01-17 17:51:48 +09:00 committed by Marge Bot
parent 494399c65c
commit fa475c1b56
2 changed files with 15 additions and 1 deletions

View file

@ -173,6 +173,7 @@ agx_scratch_realloc(struct agx_scratch *scratch)
unsigned num_cores = 0;
unsigned core_id;
for (core_id = 0; core_id < AGX_MAX_CORE_ID; core_id++) {
#ifndef SCRATCH_DEBUG_CORES
unsigned cores_per_cluster =
util_next_power_of_two(scratch->dev->params.num_cores_per_cluster);
unsigned cluster = core_id / cores_per_cluster;
@ -182,6 +183,7 @@ agx_scratch_realloc(struct agx_scratch *scratch)
if (core >= scratch->dev->params.num_cores_per_cluster ||
!(scratch->dev->params.core_masks[cluster] & BITFIELD_BIT(core)))
continue;
#endif
num_cores++;
#ifdef SCRATCH_DEBUG
scratch->core_present[core_id] = true;
@ -304,10 +306,14 @@ agx_scratch_init(struct agx_device *dev, struct agx_scratch *scratch)
memset(scratch, 0, sizeof(*scratch));
scratch->dev = dev;
#ifdef SCRATCH_DEBUG_CORES
scratch->num_cores = SCRATCH_DEBUG_CORES;
#else
scratch->num_cores = 0;
for (unsigned cl = 0; cl < dev->params.num_clusters_total; cl++) {
scratch->num_cores += util_bitcount(dev->params.core_masks[cl]);
}
#endif
}
void

View file

@ -9,11 +9,19 @@
#include "agx_pack.h"
#include "libagx.h"
// Enable this to debug core mappings.
// #define SCRATCH_DEBUG_CORES 512
#define AGX_SPILL_SIZE_BUCKETS 16
#define AGX_MAX_CORES_PER_CLUSTER 16
#define AGX_MAX_CLUSTERS 8
#define AGX_MAX_CORE_ID (AGX_MAX_CLUSTERS * AGX_MAX_CORES_PER_CLUSTER)
#ifdef SCRATCH_DEBUG_CORES
#define AGX_MAX_CORE_ID SCRATCH_DEBUG_CORES
#else
#define AGX_MAX_CORE_ID (AGX_MAX_CLUSTERS * AGX_MAX_CORES_PER_CLUSTER)
#endif
struct agx_helper_block {
uint32_t blocks[4];