public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org,
	Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Subject: [igt-dev] [PATCH i-g-t 09/11] gem_wsim: Implement device selection
Date: Thu, 18 Jun 2020 11:47:45 +0100	[thread overview]
Message-ID: <20200618104747.24005-9-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20200618104747.24005-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@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@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 8788f752121b..59ddc798a3ea 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"
@@ -2611,7 +2612,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."
 	);
 }
 
@@ -2672,31 +2675,32 @@ 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_time = 1.0f;
 	double scale_dur = 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:F:")) != -1) {
+			   "LThqvsSdc:n:r:w:W:a:t: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");
@@ -2820,6 +2824,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",
@@ -2932,15 +2963,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++)
@@ -2949,7 +2977,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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-06-18 10:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18 10:47 [igt-dev] [PATCH i-g-t 01/11] gem_wsim: Rip out userspace balancing Tvrtko Ursulin
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 02/11] gem_wsim: Buffer objects working sets and complex dependencies Tvrtko Ursulin
2020-06-18 11:10   ` Chris Wilson
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 03/11] gem_wsim: Show workload timing stats Tvrtko Ursulin
2020-06-18 11:11   ` Chris Wilson
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 04/11] gem_wsim: Move BO allocation to a helper Tvrtko Ursulin
2020-06-18 11:11   ` Chris Wilson
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 05/11] gem_wsim: Support random buffer sizes Tvrtko Ursulin
2020-06-18 11:12   ` [Intel-gfx] " Chris Wilson
2020-06-18 10:47 ` [Intel-gfx] [PATCH i-g-t 06/11] gem_wsim: Support scaling workload batch durations Tvrtko Ursulin
2020-06-18 11:13   ` [igt-dev] " Chris Wilson
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 07/11] gem_wsim: Log max and active working set sizes in verbose mode Tvrtko Ursulin
2020-06-18 10:47 ` [Intel-gfx] [PATCH i-g-t 08/11] gem_wsim: Snippet of a workload extracted from carchase Tvrtko Ursulin
2020-06-18 11:13   ` [igt-dev] " Chris Wilson
2020-06-18 10:47 ` Tvrtko Ursulin [this message]
2020-06-18 10:47 ` [Intel-gfx] [PATCH i-g-t 10/11] gem_wsim: Fix calibration handling Tvrtko Ursulin
2020-06-18 11:15   ` [igt-dev] " Chris Wilson
2020-06-18 10:47 ` [igt-dev] [PATCH i-g-t 11/11] gem_wsim: Do not keep batch mapped unless needed Tvrtko Ursulin
2020-06-18 10:56 ` [igt-dev] ✗ Fi.CI.BUILD: failure for series starting with [i-g-t,01/11] gem_wsim: Rip out userspace balancing Patchwork
2020-06-18 11:09 ` [Intel-gfx] [igt-dev] [PATCH i-g-t 01/11] " Chris Wilson

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=20200618104747.24005-9-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tvrtko.ursulin@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