asahi: extract agx_get_num_cores

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32081>
This commit is contained in:
Alyssa Rosenzweig 2024-10-30 23:25:30 -04:00 committed by Marge Bot
parent e145425746
commit beab5d2792
3 changed files with 14 additions and 4 deletions

View file

@ -797,3 +797,15 @@ agx_get_driver_uuid(void *uuid)
assert(SHA1_DIGEST_LENGTH >= UUID_SIZE);
memcpy(uuid, sha1, UUID_SIZE);
}
unsigned
agx_get_num_cores(const struct agx_device *dev)
{
unsigned n = 0;
for (unsigned cl = 0; cl < dev->params.num_clusters_total; cl++) {
n += util_bitcount(dev->params.core_masks[cl]);
}
return n;
}

View file

@ -194,6 +194,7 @@ agx_gpu_time_to_ns(struct agx_device *dev, uint64_t gpu_time)
void agx_get_device_uuid(const struct agx_device *dev, void *uuid);
void agx_get_driver_uuid(void *uuid);
unsigned agx_get_num_cores(const struct agx_device *dev);
struct agx_va *agx_va_alloc(struct agx_device *dev, uint32_t size_B,
uint32_t align_B, enum agx_va_flags flags,

View file

@ -289,10 +289,7 @@ agx_scratch_init(struct agx_device *dev, struct agx_scratch *scratch)
#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]);
}
scratch->num_cores = agx_get_num_cores(dev);
#endif
}