[PATCH 2/3] lib/gpgpu_shader: add function for computing max number of threads per tg
Hajda, Andrzej
andrzej.hajda at intel.com
Mon Jul 7 16:56:51 UTC 2025
W dniu 01.07.2025 o 15:53, Jan Maslak pisze:
> Adds function compute_max_threads_per_tg() that computes the maximum
> allowed amount of threads in a thread group for XE2-3 platforms.
>
> Signed-off-by: Jan Maslak <jan.maslak at intel.com>
> ---
> lib/gpgpu_shader.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
> lib/gpgpu_shader.h | 9 +++++++
> 2 files changed, 73 insertions(+)
>
> diff --git a/lib/gpgpu_shader.c b/lib/gpgpu_shader.c
> index b83e645e3..7e1d73d72 100644
> --- a/lib/gpgpu_shader.c
> +++ b/lib/gpgpu_shader.c
> @@ -919,3 +919,67 @@ void gpgpu_shader__read_a64_d32(struct gpgpu_shader *shdr, uint64_t ppgtt_addr)
> #endif \n\
> ", lower_32_bits(addr), upper_32_bits(addr));
> }
> +
> +static uint32_t compute_max_threads_in_tg_no_vrt(bool large_grf_mode,
> + uint32_t simd_size)
> +{
> + if (large_grf_mode) {
> + return 32;
> + } else {
> + if (simd_size == 16)
> + return 64;
> + else if (simd_size == 32)
> + return 32;
> + }
> +
> + igt_warn("Unsupported SIMD size %d\n", simd_size);
> + return 1;
> +}
> +
> +static uint32_t compute_max_threads_in_tg_vrt(enum gpgpu_shader_vrt_modes vrt,
> + uint32_t simd_size,
> + bool hw_local_id_generation)
> +{
> + if (vrt <= VRT_128) {
> + if (simd_size == 16)
> + return 64;
> + else if (simd_size == 32) {
> + if (hw_local_id_generation)
> + return 32;
> + else
> + return 64;
> + }
> + } else if (vrt == VRT_160) {
> + if (simd_size == 16)
> + return 48;
> + else if (simd_size == 32) {
> + if (hw_local_id_generation)
> + return 32;
> + else
> + return 48;
> + }
> + } else if (vrt == VRT_192) {
> + if (simd_size == 16)
> + return 40;
> + else if (simd_size == 32) {
> + if (hw_local_id_generation)
> + return 32;
> + else
> + return 40;
> + }
> + }
Quite complicated logic, could you document it with bspec number.
> +
> + igt_warn("Unsupported VRT mode %d or SIMD size %d\n", vrt, simd_size);
> + return 1;
> +}
> +
> +uint32_t compute_max_threads_in_tg(enum gpgpu_shader_vrt_modes vrt, bool large_grf_mode,
> + uint32_t simd_size, bool local_id_generation)
> +{
> + if (vrt == VRT_DISABLED) {
> + return compute_max_threads_in_tg_no_vrt(large_grf_mode, simd_size);
> + } else {
> + return compute_max_threads_in_tg_vrt(vrt, simd_size,
> + local_id_generation);
> + }
> +}
> diff --git a/lib/gpgpu_shader.h b/lib/gpgpu_shader.h
> index 411ad6292..b4db48b32 100644
> --- a/lib/gpgpu_shader.h
> +++ b/lib/gpgpu_shader.h
> @@ -14,7 +14,12 @@ struct intel_bb;
> struct intel_buf;
>
> enum gpgpu_shader_vrt_modes {
> + VRT_32 = 0x0,
> + VRT_64 = 0x1,
> VRT_96 = 0x2,
> + VRT_128 = 0x3,
> + VRT_160 = 0x4,
> + VRT_192 = 0x5,
> VRT_DISABLED,
> };
>
> @@ -103,4 +108,8 @@ void gpgpu_shader__jump_neq(struct gpgpu_shader *shdr, int label_id,
> uint32_t dw_offset, uint32_t value);
> void gpgpu_shader__loop_begin(struct gpgpu_shader *shdr, int label_id);
> void gpgpu_shader__loop_end(struct gpgpu_shader *shdr, int label_id, uint32_t iter);
> +
> +uint32_t compute_max_threads_in_tg(enum gpgpu_shader_vrt_modes vrt, bool large_grf_mode,
> + uint32_t simd_size, bool local_id_generation);
I wonder if it wouldn't be better to pass shader as parameter and put
all parameters into struct gpgpu_shader?
Also for public function please add prefix, maybe:
gpgpu_shader_get_max_threads_in_tg(struct gpgpu_shader shader);
Regards
Andrzej
> +
> #endif /* GPGPU_SHADER_H */
More information about the igt-dev
mailing list