From: Andrzej Hajda <andrzej.hajda@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
Priyanka Dandamudi <priyanka.dandamudi@intel.com>,
Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
Jan Maslak <jan.maslak@intel.com>,
Andrzej Hajda <andrzej.hajda@intel.com>
Subject: [PATCH 02/11] lib/xe/xe_query: add helpers to return count of EUs and EU threads
Date: Fri, 28 Nov 2025 15:12:06 +0100 [thread overview]
Message-ID: <20251128-pagefault-one-of-many-v1-2-a8377a93da8f@intel.com> (raw)
In-Reply-To: <20251128-pagefault-one-of-many-v1-0-a8377a93da8f@intel.com>
These helpers will be useful for compute tests.
Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
lib/xe/xe_query.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/xe/xe_query.h | 3 +++
2 files changed, 60 insertions(+)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 3f3ee9b96594..38f8f5595060 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -1047,6 +1047,63 @@ int xe_wait_for_pxp_init(int fd)
return -ETIMEDOUT;
}
+/**
+ * xe_query_eu_count:
+ * @fd: xe device fd
+ * @gt: GT id
+ *
+ * Return count of EUs for given GT.
+ */
+int xe_query_eu_count(int fd, int gt)
+{
+ struct drm_xe_query_topology_mask *c_dss = NULL, *g_dss = NULL, *eu_per_dss = NULL;
+ struct drm_xe_query_topology_mask *topology, *topo;
+ uint32_t size;
+ int eu_count;
+
+ topology = xe_query_device(fd, DRM_XE_DEVICE_QUERY_GT_TOPOLOGY, &size);
+ xe_for_each_topology_mask(topology, size, topo) {
+ if (topo->gt_id != gt)
+ continue;
+
+ if (topo->type == DRM_XE_TOPO_DSS_GEOMETRY) {
+ g_dss = topo;
+ } else if (topo->type == DRM_XE_TOPO_DSS_COMPUTE) {
+ c_dss = topo;
+ } else if (topo->type == DRM_XE_TOPO_EU_PER_DSS ||
+ topo->type == DRM_XE_TOPO_SIMD16_EU_PER_DSS) {
+ eu_per_dss = topo;
+ break;
+ }
+ }
+
+ igt_assert(g_dss && c_dss && eu_per_dss);
+ igt_assert_eq_u32(c_dss->num_bytes, g_dss->num_bytes);
+
+ for (int i = 0; i < c_dss->num_bytes; i++)
+ c_dss->mask[i] |= g_dss->mask[i];
+
+ eu_count = igt_bitmap_hweight(c_dss->mask, c_dss->num_bytes * 8);
+ eu_count *= igt_bitmap_hweight(eu_per_dss->mask, eu_per_dss->num_bytes * 8);
+
+ free(topology);
+
+ return eu_count;
+}
+
+/**
+ * xe_query_eu_thread_count:
+ * @fd: xe device fd
+ * @gt: GT id
+ *
+ * Return count of EU threads for given GT.
+ */
+int xe_query_eu_thread_count(int fd, int gt)
+{
+ return xe_query_eu_count(fd, gt) *
+ xe_hwconfig_lookup_value_u32(fd, INTEL_HWCONFIG_NUM_THREADS_PER_EU);
+}
+
igt_constructor
{
xe_device_cache_init();
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 3eb05a6c0535..8c57bb21df55 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -175,4 +175,7 @@ static inline void *xe_query_device(int fd, uint32_t type, uint32_t *size)
struct xe_device *xe_device_get(int fd);
void xe_device_put(int fd);
+int xe_query_eu_count(int fd, int gt);
+int xe_query_eu_thread_count(int fd, int gt);
+
#endif /* XE_QUERY_H */
--
2.43.0
next prev parent reply other threads:[~2025-11-28 14:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 14:12 [PATCH 00/11] tests/intel/xe_eudebug_online: add pagefault-one-of-many test Andrzej Hajda
2025-11-28 14:12 ` [PATCH 01/11] lib/igt_aux: add hweight helper for bitmaps Andrzej Hajda
2025-11-28 14:12 ` Andrzej Hajda [this message]
2025-11-28 14:12 ` [PATCH 03/11] lib/gpgpu_shader: use recently introduced helper to get EU thread count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 04/11] tests/intel/xe_eudebug_online: use igt_bitmap_hweight Andrzej Hajda
2025-11-28 14:12 ` [PATCH 05/11] lib/igt_aux: add fls helper for bitmaps Andrzej Hajda
2025-11-28 14:12 ` [PATCH 06/11] tests/intel/xe_eudebug_online: use igt_bitmap_fls to calculate max dss count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 07/11] tests/intel/xe_eudebug_online: add fd and flags to online_debug_data Andrzej Hajda
2025-11-28 14:12 ` [PATCH 08/11] tests/intel/xe_eudebug_online: rename threads_count to thread_hit_count Andrzej Hajda
2025-11-28 14:12 ` [PATCH 09/11] tests/intel/xe_eudebug_online: use online_debug_data in get_(shader|sip) Andrzej Hajda
2025-11-28 14:12 ` [PATCH 10/11] tests/intel/xe_eudebug_online: cache thread count value Andrzej Hajda
2025-11-28 14:12 ` [PATCH 11/11] tests/intel/xe_eudebug_online: add pagefault-one-of-many test Andrzej Hajda
2025-11-28 15:01 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-11-28 15:39 ` ✓ i915.CI.BAT: " Patchwork
2025-11-28 15:58 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-01 13:24 ` â " Hajda, Andrzej
2025-11-28 16:24 ` ✗ i915.CI.Full: " Patchwork
2025-12-01 14:54 ` â " Hajda, Andrzej
2025-12-03 11:16 ` [PATCH 00/11] " Maciej Patelczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251128-pagefault-one-of-many-v1-2-a8377a93da8f@intel.com \
--to=andrzej.hajda@intel.com \
--cc=gwan-gyeong.mun@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jan.maslak@intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=priyanka.dandamudi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).