[PATCH i-g-t v2 5/8] lib/intel_multigpu: Introduced gem_multigpu_count_class and igt_multi_fork_foreach_gpu
Piatkowski, Dominik Karol
dominik.karol.piatkowski at intel.com
Thu Jan 25 07:14:47 UTC 2024
Hi Kamil,
> -----Original Message-----
> From: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Sent: Wednesday, January 24, 2024 9:42 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Piatkowski, Dominik Karol <dominik.karol.piatkowski at intel.com>; Chris
> Wilson <chris.p.wilson at linux.intel.com>; Kamil Konieczny
> <kamil.konieczny at linux.intel.com>
> Subject: [PATCH i-g-t v2 5/8] lib/intel_multigpu: Introduced
> gem_multigpu_count_class and igt_multi_fork_foreach_gpu
>
> 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 | 13 ++++++++++++- lib/intel_multigpu.h | 15
> +++++++++++++++
> 2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/lib/intel_multigpu.c b/lib/intel_multigpu.c index
> 988c20033..0e76d8aa3 100644
> --- a/lib/intel_multigpu.c
> +++ b/lib/intel_multigpu.c
> @@ -3,9 +3,20 @@
> * Copyright © 2023 Intel Corporation
> */
>
> -#include "intel_multigpu.h"
> +#include "drmtest.h"
> #include "igt_core.h"
> #include "igt_device_scan.h"
> +#include "intel_multigpu.h"
A very small nitpick: in 4/8 #include "intel_multigpu.h" is added a line before igt_core.h. In here (5/8), it is moved down to maintain alphabetical order. Maybe that's a good idea to put it there in 4/8 and don't "fix" it in 5/8?
Otherwise, 1/8, 2/8, 4/8 and 5/8 LGTM, but I think I can't review them, as they are originally my patches. Please correct me if I'm wrong.
Dominik Karol
> +
> +int gem_multigpu_count_class(int class) {
> + int count = 0;
> +
> + igt_foreach_gpu(fd, class)
> + count++;
> +
> + return count;
> +}
>
> void gem_require_multigpu(int count)
> {
> diff --git a/lib/intel_multigpu.h b/lib/intel_multigpu.h index
> 98dc5a4ce..0ebc73e4a 100644
> --- a/lib/intel_multigpu.h
> +++ b/lib/intel_multigpu.h
> @@ -6,6 +6,21 @@
> #ifndef __INTEL_MULTIGPU_H
> #define __INTEL_MULTIGPU_H
>
> +#include "drmtest.h"
> +#include "igt_core.h"
> +
> void gem_require_multigpu(int count);
> +int gem_multigpu_count_class(int class);
> +
> +#define igt_foreach_gpu(fd__, id__) \
> + for (int igt_unique(i) = 0, fd__; \
> + (fd__ = __drm_open_driver_another(igt_unique(i)++, id__)) >=
> 0; \
> + close(fd__))
> +
> +#define igt_multi_fork_foreach_gpu(__fd, __id) \
> + igt_multi_fork(igt_unique(__i), gem_multigpu_count_class(__id)) \
> + for (int __fd = drm_open_driver_another(igt_unique(__i),
> __id); \
> + __fd >= 0; \
> + close(__fd), __fd = -1) \
>
> #endif /* __INTEL_MULTIGPU_H */
> --
> 2.42.0
More information about the igt-dev
mailing list