public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org
Subject: [PATH i-g-t 11/13] media-bench: Fix tracing of direct workloads
Date: Wed,  5 Sep 2018 14:49:37 +0100	[thread overview]
Message-ID: <20180905134939.2942-12-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20180905134939.2942-1-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Build argument list properly and check exit codes when executing
sub-commands.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 scripts/media-bench.pl | 54 +++++++++++++++++++++++++++---------------
 1 file changed, 35 insertions(+), 19 deletions(-)

diff --git a/scripts/media-bench.pl b/scripts/media-bench.pl
index 5070cae088f3..9bf8c8789fe2 100755
--- a/scripts/media-bench.pl
+++ b/scripts/media-bench.pl
@@ -131,7 +131,8 @@ sub add_wps_arg
 	return @args if $realtime_target <= 0;
 
 	$period = int(1000000 / $realtime_target);
-	push @args, "-a p.$period";
+	push @args, '-a';
+	push @args, 'p.$period';
 
 	return @args;
 }
@@ -144,7 +145,7 @@ sub run_workload
 	@args = add_wps_arg(@args);
 	push @args, '-2' if $gt2;
 
-	unshift @args, "$wsim";
+	unshift @args, $wsim;
 	$cmd = join ' ', @args;
 	show_cmd($cmd);
 
@@ -164,23 +165,31 @@ sub run_workload
 sub trace_workload
 {
 	my ($wrk, $b, $r, $c) = @_;
-	my @args = ( "-n $nop", "-r $r", "-c $c");
+	my @args = ($tracepl, '--trace', $wsim, '-q', '-n', $nop, '-r', $r, '-c', $c);
 	my $min_batches = 16 + $r * $c / 2;
 	my @skip_engine;
 	my %engines;
 	my ($cmd, $file);
-	my $warg = defined $w_direct ? $wrk : "-w $wrk_root/$wrk";
 
-	push @args, "$b -R" unless $b eq '<none>';
 	push @args, '-2' if $gt2;
-	push @args, $warg;
 
-	unshift @args, '-q';
-	unshift @args, "$tracepl --trace $wsim";
+	unless ($b eq '<none>') {
+		push @args, '-R';
+		push @args, split /\s+/, $b;
+	}
 
-	$cmd = join ' ', @args;
-	show_cmd($cmd);
-	system($cmd);
+	if (defined $w_direct) {
+		push @args, split /\s+/, $wrk;
+	} else {
+		push @args, '-w';
+		push @args, $wrk_root . '/' . $wrk;
+	}
+
+	show_cmd(join ' ', @args);
+	if (-e 'perf.data') {
+		unlink 'perf.data' or die;
+	}
+	system(@args) == 0 or die;
 
 	$cmd = "perf script | $tracepl";
 	show_cmd($cmd);
@@ -205,13 +214,13 @@ sub trace_workload
 
 	$cmd = "perf script > ${file}.trace";
 	show_cmd($cmd);
-	system($cmd);
+	system($cmd) == 0 or die;
 
 	$cmd = "perf script | $tracepl --html -x ctxsave -s -c ";
 	$cmd .= join ' ', map("-i $_", @skip_engine);
 	$cmd .= " > ${file}.html";
 	show_cmd($cmd);
-	system($cmd);
+	system($cmd) == 0 or die;
 
 	return \%engines;
 }
@@ -219,7 +228,6 @@ sub trace_workload
 sub calibrate_workload
 {
 	my ($wrk) = @_;
-	my $warg = defined $w_direct ? $wrk : "-w $wrk_root/$wrk";
 	my $tol = $tolerance;
 	my $loops = 0;
 	my $error;
@@ -227,9 +235,16 @@ sub calibrate_workload
 
 	$r = $realtime_target > 0 ? $realtime_target * $client_target_s : 23;
 	for (;;) {
-		my @args = ( "-n $nop", "-r $r", $warg);
+		my @args = ('-n', $nop, '-r', $r);
 		my ($time, $wps);
 
+		if (defined $w_direct) {
+			push @args, split /\s+/, $wrk;
+		} else {
+			push @args, '-w';
+			push @args, $wrk_root . '/' . $wrk;
+		}
+
 		($time, $wps) = run_workload(@args);
 
 		$error = abs($time - $client_target_s) / $client_target_s;
@@ -254,23 +269,24 @@ sub find_saturation_point
 	my ($last_wps, $c, $swps);
 	my $target = $realtime_target > 0 ? $realtime_target : $wps_target;
 	my $r = $rr;
-	my ($warg, $wcnt);
+	my $wcnt;
 	my $maxc;
 	my $max = 0;
 
 	if (defined $w_direct) {
-		$warg = $wrk;
+		push @args, split /\s+/, $wrk;
 		$wcnt = () = $wrk =~ /-[wW]/gi;
 
 	} else {
-		$warg = "-w $wrk_root/$wrk";
+		push @args, '-w';
+		push @args, $wrk_root . '/' . $wrk;
 		$wcnt = 1;
 	}
 
 	for ($c = 1; ; $c = $c + 1) {
 		my ($time, $wps);
 
-		($time, $wps) = run_workload((@args, ($warg, "-r $r", "-c $c")));
+		($time, $wps) = run_workload((@args, ('-r', $r, '-c', $c)));
 
 		say "        $c clients is $wps wps." if $verbose;
 
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-09-05 13:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05 13:49 [PATH i-g-t 00/13] Tracing & workload simulation misc patches Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 01/13] trace.pl: Fix frequency timeline Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 02/13] trace.pl: Use undocumented -o to perf record to allow tee Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 03/13] gem_wsim: Fix BCS usage under VCS2 remap warning Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 04/13] gem_wsim: Check sleep times Tvrtko Ursulin
2018-09-05 14:09   ` [igt-dev] " Ville Syrjälä
2018-09-07  8:37     ` Tvrtko Ursulin
2018-09-07  8:45       ` Chris Wilson
2018-09-07 14:13         ` Ville Syrjälä
2018-09-07 16:00           ` Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 05/13] gem_wsim: Make workload commands case sensitive Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 06/13] gem_wsim: Context priority support Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 07/13] gem_wsim: Make batches preemptable by default Tvrtko Ursulin
2018-09-07  8:48   ` [igt-dev] " Chris Wilson
2018-09-05 13:49 ` [PATH i-g-t 08/13] gem_wsim: Per context preemption point control Tvrtko Ursulin
2018-09-07  8:49   ` [igt-dev] " Chris Wilson
2018-09-07  8:51     ` Chris Wilson
2018-09-05 13:49 ` [PATH i-g-t 09/13] media-bench: Update for engine=class:instance tracepoints Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 10/13] media-bench: Protect against incorrect -b syntax Tvrtko Ursulin
2018-09-05 13:49 ` Tvrtko Ursulin [this message]
2018-09-05 13:49 ` [PATH i-g-t 12/13] media-bench: Write out trace files directly Tvrtko Ursulin
2018-09-05 13:49 ` [PATH i-g-t 13/13] media-bench: Add mixed mode evaluation Tvrtko Ursulin

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=20180905134939.2942-12-tvrtko.ursulin@linux.intel.com \
    --to=tursulin@ursulin.net \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    /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