panfrost: move max_thread_count and take reg_count into account

We'll need it to report proper thread counts for OpenCL.

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19855>
This commit is contained in:
Karol Herbst 2022-11-30 17:53:12 +01:00 committed by Marge Bot
parent 3212ac4658
commit 87aeea20ac
2 changed files with 33 additions and 28 deletions

View file

@ -170,40 +170,13 @@ panfrost_query_core_count(int fd, unsigned *core_id_range)
return util_bitcount(mask);
}
/* Architectural maximums, since this register may be not implemented
* by a given chip. G31 is actually 512 instead of 768 but it doesn't
* really matter. */
static unsigned
panfrost_max_thread_count(unsigned arch)
{
switch (arch) {
/* Midgard */
case 4:
case 5:
return 256;
/* Bifrost, first generation */
case 6:
return 384;
/* Bifrost, second generation (G31 is 512 but it doesn't matter) */
case 7:
return 768;
/* Valhall (for completeness) */
default:
return 1024;
}
}
static unsigned
panfrost_query_thread_tls_alloc(int fd, unsigned major)
{
unsigned tls =
panfrost_query_raw(fd, DRM_PANFROST_PARAM_THREAD_TLS_ALLOC, false, 0);
return (tls > 0) ? tls : panfrost_max_thread_count(major);
return (tls > 0) ? tls : panfrost_max_thread_count(major, 0);
}
static uint32_t

View file

@ -458,4 +458,36 @@ pan_subgroup_size(unsigned arch)
return 1;
}
/* Architectural maximums, since this register may be not implemented
* by a given chip. G31 is actually 512 instead of 768 but it doesn't
* really matter. */
static inline unsigned
panfrost_max_thread_count(unsigned arch, unsigned work_reg_count)
{
switch (arch) {
/* Midgard */
case 4:
case 5:
if (work_reg_count > 8)
return 64;
else if (work_reg_count > 4)
return 128;
else
return 256;
/* Bifrost, first generation */
case 6:
return 384;
/* Bifrost, second generation (G31 is 512 but it doesn't matter) */
case 7:
return work_reg_count > 32 ? 384 : 768;
/* Valhall (for completeness) */
default:
return work_reg_count > 32 ? 512 : 1024;
}
}
#endif