[PATCH 2/3] lib/gpgpu_shader: add function for computing max number of threads per tg

Jan Maslak jan.maslak at intel.com
Tue Jul 1 13:53:06 UTC 2025


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;
+		}
+	}
+
+	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);
+
 #endif /* GPGPU_SHADER_H */
-- 
2.34.1



More information about the igt-dev mailing list