* [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection
@ 2020-11-17 11:40 Tvrtko Ursulin
2020-11-17 11:51 ` Chris Wilson
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2020-11-17 11:40 UTC (permalink / raw)
To: igt-dev; +Cc: Intel-gfx
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-L and -D <device> on the command line.
With no device specified tool tries to find i915 discrete or integrated in
that order.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
benchmarks/gem_wsim.c | 61 +++++++++++++++++++++++++++++++++++--------
1 file changed, 50 insertions(+), 11 deletions(-)
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index ecad4a8dcd22..f3567f7b9a0b 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -43,6 +43,7 @@
#include <pthread.h>
#include <math.h>
+#include "igt_device_scan.h"
#include "intel_chipset.h"
#include "intel_reg.h"
#include "drm.h"
@@ -2520,7 +2521,9 @@ static void print_help(void)
" clients.\n"
" -d Sync between data dependencies in userspace.\n"
" -f <scale> Scale factor for batch durations.\n"
-" -F <scale> Scale factor for delays."
+" -F <scale> Scale factor for delays.\n"
+" -L List GPUs.\n"
+" -D <gpu> One of the GPUs from -L.\n"
);
}
@@ -2570,6 +2573,7 @@ add_workload_arg(struct w_arg *w_args, unsigned int nr_args, char *w_arg,
int main(int argc, char **argv)
{
+ bool list_devices_arg = false;
unsigned int repeat = 1;
unsigned int clients = 1;
unsigned int flags = 0;
@@ -2581,26 +2585,25 @@ int main(int argc, char **argv)
char *append_workload_arg = NULL;
struct w_arg *w_args = NULL;
int exitcode = EXIT_FAILURE;
+ struct igt_device_card card;
+ char *device_arg = NULL;
double scale_time = 1.0f;
double scale_dur = 1.0f;
int prio = 0;
double t;
int i, c, ret;
- /*
- * Open the device via the low-level API so we can do the GPU quiesce
- * manually as close as possible in time to the start of the workload.
- * This minimizes the gap in engine utilization tracking when observed
- * via external tools like trace.pl.
- */
- fd = __drm_open_driver_render(DRIVER_INTEL);
- igt_require(fd);
-
master_prng = time(NULL);
while ((c = getopt(argc, argv,
- "hqvsSdc:r:w:W:a:p:I:f:F:")) != -1) {
+ "LhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
switch (c) {
+ case 'L':
+ list_devices_arg = true;
+ break;
+ case 'D':
+ device_arg = strdup(optarg);
+ break;
case 'W':
if (master_workload >= 0) {
wsim_err("Only one master workload can be given!\n");
@@ -2661,6 +2664,42 @@ int main(int argc, char **argv)
}
}
+ igt_devices_scan(false);
+
+ if (list_devices_arg) {
+ struct igt_devices_print_format fmt = {
+ .type = IGT_PRINT_USER,
+ .option = IGT_PRINT_DRM,
+ };
+
+ igt_devices_print(&fmt);
+
+ return EXIT_SUCCESS;
+ }
+
+ if (device_arg) {
+ ret = igt_device_card_match(device_arg, &card);
+ if (!ret) {
+ wsim_err("Requested device %s not found!\n",
+ device_arg);
+ free(device_arg);
+
+ return EXIT_FAILURE;
+ }
+ free(device_arg);
+ } else {
+ ret = igt_device_find_first_i915_discrete_card(&card);
+ if (!ret)
+ ret = igt_device_find_integrated_card(&card);
+ if (!ret) {
+ wsim_err("No device filter specified and no discrete/integrated i915 devices found\n");
+ return EXIT_FAILURE;
+ }
+ }
+
+ fd = igt_open_card(&card);
+ igt_require(fd);
+
if (!nr_w_args) {
wsim_err("No workload descriptor(s)!\n");
goto err;
--
2.25.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection
2020-11-17 11:40 [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection Tvrtko Ursulin
@ 2020-11-17 11:51 ` Chris Wilson
2020-11-17 12:18 ` Chris Wilson
2020-11-17 13:59 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
2 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2020-11-17 11:51 UTC (permalink / raw)
To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx
Quoting Tvrtko Ursulin (2020-11-17 11:40:50)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> -L and -D <device> on the command line.
>
> With no device specified tool tries to find i915 discrete or integrated in
> that order.
I'm shocked you didn't add D.x to .wsim :)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection
2020-11-17 11:40 [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection Tvrtko Ursulin
2020-11-17 11:51 ` Chris Wilson
@ 2020-11-17 12:18 ` Chris Wilson
2020-11-17 12:33 ` Tvrtko Ursulin
2020-11-17 13:59 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
2 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2020-11-17 12:18 UTC (permalink / raw)
To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx
Quoting Tvrtko Ursulin (2020-11-17 11:40:50)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> -L and -D <device> on the command line.
>
> With no device specified tool tries to find i915 discrete or integrated in
> that order.
Ok, looks straightforward enough. (I still like having an idiot's guide
with examples of -L output and what to pass to -D).
> + fd = igt_open_card(&card);
> + igt_require(fd);
Does igt_require() still generate weirdness when used outside of igt
tests?
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection
2020-11-17 12:18 ` Chris Wilson
@ 2020-11-17 12:33 ` Tvrtko Ursulin
2020-11-17 12:37 ` Chris Wilson
0 siblings, 1 reply; 8+ messages in thread
From: Tvrtko Ursulin @ 2020-11-17 12:33 UTC (permalink / raw)
To: Chris Wilson, igt-dev; +Cc: Intel-gfx
On 17/11/2020 12:18, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2020-11-17 11:40:50)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> -L and -D <device> on the command line.
>>
>> With no device specified tool tries to find i915 discrete or integrated in
>> that order.
>
> Ok, looks straightforward enough. (I still like having an idiot's guide
> with examples of -L output and what to pass to -D).
>
>> + fd = igt_open_card(&card);
>> + igt_require(fd);
>
> Does igt_require() still generate weirdness when used outside of igt
> tests?
It appears to do nothing. But more importantly I don't know how I ended
up with it here. Probably some copy & paste again.
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Can I convert to igt_assert and keep the r-b?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection
2020-11-17 12:33 ` Tvrtko Ursulin
@ 2020-11-17 12:37 ` Chris Wilson
0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2020-11-17 12:37 UTC (permalink / raw)
To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx
Quoting Tvrtko Ursulin (2020-11-17 12:33:11)
>
> On 17/11/2020 12:18, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2020-11-17 11:40:50)
> >> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>
> >> -L and -D <device> on the command line.
> >>
> >> With no device specified tool tries to find i915 discrete or integrated in
> >> that order.
> >
> > Ok, looks straightforward enough. (I still like having an idiot's guide
> > with examples of -L output and what to pass to -D).
> >
> >> + fd = igt_open_card(&card);
> >> + igt_require(fd);
> >
> > Does igt_require() still generate weirdness when used outside of igt
> > tests?
>
> It appears to do nothing. But more importantly I don't know how I ended
> up with it here. Probably some copy & paste again.
>
> > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> Can I convert to igt_assert and keep the r-b?
Make it return sensibly with a wsim_err.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Intel-gfx] [PATCH i-g-t v2] gem_wsim: Implement device selection
2020-11-17 11:40 [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection Tvrtko Ursulin
2020-11-17 11:51 ` Chris Wilson
2020-11-17 12:18 ` Chris Wilson
@ 2020-11-17 13:59 ` Tvrtko Ursulin
2020-11-17 14:06 ` [Intel-gfx] [igt-dev] " Chris Wilson
2 siblings, 1 reply; 8+ messages in thread
From: Tvrtko Ursulin @ 2020-11-17 13:59 UTC (permalink / raw)
To: igt-dev; +Cc: Intel-gfx
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-L and -D <device> on the command line.
With no device specified tool tries to find i915 discrete or integrated in
that order.
v2:
* Fix error handling and support render devices.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
benchmarks/gem_wsim.c | 75 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 64 insertions(+), 11 deletions(-)
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index ecad4a8dcd22..1c0c591ed8af 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -43,6 +43,7 @@
#include <pthread.h>
#include <math.h>
+#include "igt_device_scan.h"
#include "intel_chipset.h"
#include "intel_reg.h"
#include "drm.h"
@@ -2520,7 +2521,9 @@ static void print_help(void)
" clients.\n"
" -d Sync between data dependencies in userspace.\n"
" -f <scale> Scale factor for batch durations.\n"
-" -F <scale> Scale factor for delays."
+" -F <scale> Scale factor for delays.\n"
+" -L List GPUs.\n"
+" -D <gpu> One of the GPUs from -L.\n"
);
}
@@ -2570,6 +2573,8 @@ add_workload_arg(struct w_arg *w_args, unsigned int nr_args, char *w_arg,
int main(int argc, char **argv)
{
+ struct igt_device_card card = { };
+ bool list_devices_arg = false;
unsigned int repeat = 1;
unsigned int clients = 1;
unsigned int flags = 0;
@@ -2581,26 +2586,25 @@ int main(int argc, char **argv)
char *append_workload_arg = NULL;
struct w_arg *w_args = NULL;
int exitcode = EXIT_FAILURE;
+ char *device_arg = NULL;
double scale_time = 1.0f;
double scale_dur = 1.0f;
int prio = 0;
double t;
int i, c, ret;
-
- /*
- * Open the device via the low-level API so we can do the GPU quiesce
- * manually as close as possible in time to the start of the workload.
- * This minimizes the gap in engine utilization tracking when observed
- * via external tools like trace.pl.
- */
- fd = __drm_open_driver_render(DRIVER_INTEL);
- igt_require(fd);
+ char *drm_dev;
master_prng = time(NULL);
while ((c = getopt(argc, argv,
- "hqvsSdc:r:w:W:a:p:I:f:F:")) != -1) {
+ "LhqvsSdc:r:w:W:a:p:I:f:F:D:")) != -1) {
switch (c) {
+ case 'L':
+ list_devices_arg = true;
+ break;
+ case 'D':
+ device_arg = strdup(optarg);
+ break;
case 'W':
if (master_workload >= 0) {
wsim_err("Only one master workload can be given!\n");
@@ -2661,6 +2665,55 @@ int main(int argc, char **argv)
}
}
+ igt_devices_scan(false);
+
+ if (list_devices_arg) {
+ struct igt_devices_print_format fmt = {
+ .type = IGT_PRINT_USER,
+ .option = IGT_PRINT_DRM,
+ };
+
+ igt_devices_print(&fmt);
+ return EXIT_SUCCESS;
+ }
+
+ if (device_arg) {
+ ret = igt_device_card_match(device_arg, &card);
+ if (!ret) {
+ wsim_err("Requested device %s not found!\n",
+ device_arg);
+ free(device_arg);
+ return EXIT_FAILURE;
+ }
+ free(device_arg);
+ } else {
+ ret = igt_device_find_first_i915_discrete_card(&card);
+ if (!ret)
+ ret = igt_device_find_integrated_card(&card);
+ if (!ret) {
+ wsim_err("No device filter specified and no i915 devices found!\n");
+ return EXIT_FAILURE;
+ }
+ }
+
+ if (strlen(card.card)) {
+ drm_dev = card.card;
+ } else if (strlen(card.render)) {
+ drm_dev = card.render;
+ } else {
+ wsim_err("Failed to detect device!\n");
+ return EXIT_FAILURE;
+ }
+
+ fd = open(drm_dev, O_RDWR);
+ if (fd < 0) {
+ wsim_err("Failed to open '%s'! (%s)\n",
+ drm_dev, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ if (verbose > 1)
+ printf("Using device %s\n", drm_dev);
+
if (!nr_w_args) {
wsim_err("No workload descriptor(s)!\n");
goto err;
--
2.25.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v2] gem_wsim: Implement device selection
2020-11-17 13:59 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
@ 2020-11-17 14:06 ` Chris Wilson
2020-11-18 11:56 ` Tvrtko Ursulin
0 siblings, 1 reply; 8+ messages in thread
From: Chris Wilson @ 2020-11-17 14:06 UTC (permalink / raw)
To: Tvrtko Ursulin, igt-dev; +Cc: Intel-gfx
Quoting Tvrtko Ursulin (2020-11-17 13:59:18)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> -L and -D <device> on the command line.
>
> With no device specified tool tries to find i915 discrete or integrated in
> that order.
>
> v2:
> * Fix error handling and support render devices.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Hmm, optarg should be a pointer into the argv, so is the copy necessary?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [igt-dev] [PATCH i-g-t v2] gem_wsim: Implement device selection
2020-11-17 14:06 ` [Intel-gfx] [igt-dev] " Chris Wilson
@ 2020-11-18 11:56 ` Tvrtko Ursulin
0 siblings, 0 replies; 8+ messages in thread
From: Tvrtko Ursulin @ 2020-11-18 11:56 UTC (permalink / raw)
To: Chris Wilson, igt-dev; +Cc: Intel-gfx
On 17/11/2020 14:06, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2020-11-17 13:59:18)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> -L and -D <device> on the command line.
>>
>> With no device specified tool tries to find i915 discrete or integrated in
>> that order.
>>
>> v2:
>> * Fix error handling and support render devices.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> Hmm, optarg should be a pointer into the argv, so is the copy necessary?
I don't remember if I tried, and I don't see that getopt(3) explains
optarg from that angle, so probably safest to keep as is. Too lazy to
try.. Or maybe presence of strdup suggests I did already try and that
optarg is indeed temporary copy managed by getopt.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-11-18 11:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 11:40 [Intel-gfx] [PATCH i-g-t] gem_wsim: Implement device selection Tvrtko Ursulin
2020-11-17 11:51 ` Chris Wilson
2020-11-17 12:18 ` Chris Wilson
2020-11-17 12:33 ` Tvrtko Ursulin
2020-11-17 12:37 ` Chris Wilson
2020-11-17 13:59 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
2020-11-17 14:06 ` [Intel-gfx] [igt-dev] " Chris Wilson
2020-11-18 11:56 ` Tvrtko Ursulin
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).