[Intel-gfx] [PATCH i-g-t 09/10] gem_wsim: Implement device selection
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Jun 17 16:01:19 UTC 2020
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
New command line options -L and -D <device> can respectively be used to
list and select a GPU when more than one is present.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
benchmarks/gem_wsim.c | 62 +++++++++++++++++++++++++++++++------------
1 file changed, 45 insertions(+), 17 deletions(-)
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 96ee923fb699..ca07b670bd42 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"
@@ -2593,7 +2594,9 @@ static void print_help(void)
" -S Synchronize the sequence of random batch durations between\n"
" clients.\n"
" -d Sync between data dependencies in userspace.\n"
-" -f <scale> Scale factor for batch durations."
+" -f <scale> Scale factor for batch durations.\n"
+" -L List GPUs.\n"
+" -D <gpu> One of the GPUs from -L."
);
}
@@ -2654,30 +2657,31 @@ int main(int argc, char **argv)
char *append_workload_arg = NULL;
struct w_arg *w_args = NULL;
unsigned int tolerance_pct = 1;
+ enum igt_devices_print_type printtype = IGT_PRINT_SIMPLE;
+ bool list_devices_arg = false;
int exitcode = EXIT_FAILURE;
+ struct igt_device_card card;
double scale_arg = 1.0f;
+ char *device_arg = NULL;
int prio = 0;
double t;
- int i, c;
+ int i, c, ret;
char *subopts, *value;
int raw_number = 0;
long calib_val;
int eng;
- /*
- * 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,
- "ThqvsSdc:n:r:w:W:a:t:p:I:f:")) != -1) {
+ "LThqvsSdc:n:r:w:W:a:t:p:I: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");
@@ -2798,6 +2802,33 @@ int main(int argc, char **argv)
}
}
+
+ igt_devices_scan(false);
+
+ if (list_devices_arg) {
+ igt_devices_print(printtype);
+ 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 {
+ igt_device_find_first_i915_discrete_card(&card);
+ }
+
+ if (card.render[0])
+ fd = igt_open_render(&card);
+ else
+ fd = __drm_open_driver_render(DRIVER_INTEL);
+ igt_require(fd);
+
if (!has_nop_calibration) {
if (verbose > 1) {
printf("Calibrating nop delays with %u%% tolerance...\n",
@@ -2908,15 +2939,12 @@ int main(int argc, char **argv)
clock_gettime(CLOCK_MONOTONIC, &t_start);
for (i = 0; i < clients; i++) {
- int ret;
-
ret = pthread_create(&w[i]->thread, NULL, run_workload, w[i]);
igt_assert_eq(ret, 0);
}
if (master_workload >= 0) {
- int ret = pthread_join(w[master_workload]->thread, NULL);
-
+ ret = pthread_join(w[master_workload]->thread, NULL);
igt_assert(ret == 0);
for (i = 0; i < clients; i++)
@@ -2925,7 +2953,7 @@ int main(int argc, char **argv)
for (i = 0; i < clients; i++) {
if (master_workload != i) {
- int ret = pthread_join(w[i]->thread, NULL);
+ ret = pthread_join(w[i]->thread, NULL);
igt_assert(ret == 0);
}
}
--
2.20.1
More information about the Intel-gfx
mailing list