[PATCH i-g-t v1 5/8] lib/intel_multigpu: Introduced gem_multigpu_count_class and igt_multi_fork_foreach_gpu

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue Jan 23 20:15:32 UTC 2024


From: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>

Introduced gem_multigpu_count_class function that returns an actual
number of GPUs present in system, which allows for writing multi-GPU
test scenarios that does not require
--device pci:vendor=intel,device=discrete,card=all
to run as intended. Based on patch by Chris Wilson.

Introduced igt_multi_fork_foreach_gpu macro that helps with
writing multi-GPU test scenarios in idiomatic form:

igt_multi_fork_foreach_gpu(i915, DRIVER_INTEL)
	test_function(i915);
igt_waitchildren();

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
Signed-off-by: Chris Wilson <chris.p.wilson at linux.intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 lib/intel_multigpu.c | 10 ++++++++++
 lib/intel_multigpu.h |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/intel_multigpu.c b/lib/intel_multigpu.c
index 446e3ff5f..0e76d8aa3 100644
--- a/lib/intel_multigpu.c
+++ b/lib/intel_multigpu.c
@@ -8,6 +8,16 @@
 #include "igt_device_scan.h"
 #include "intel_multigpu.h"
 
+int gem_multigpu_count_class(int class)
+{
+	int count = 0;
+
+	igt_foreach_gpu(fd, class)
+		count++;
+
+	return count;
+}
+
 void gem_require_multigpu(int count)
 {
 	struct igt_devices_print_format fmt = {
diff --git a/lib/intel_multigpu.h b/lib/intel_multigpu.h
index 5f98307fd..ad1e5cf07 100644
--- a/lib/intel_multigpu.h
+++ b/lib/intel_multigpu.h
@@ -9,8 +9,8 @@
 #include "igt_core.h"
 #include "igt_device_scan.h"
 
-void gem_require_multigpu(int count);
 int gem_multigpu_count_class(int class);
+void gem_require_multigpu(int count);
 
 #define igt_foreach_gpu(fd__, id__) \
 	for (int igt_unique(i) = 0, fd__; \
-- 
2.42.0



More information about the igt-dev mailing list