summaryrefslogtreecommitdiff
path: root/scripts/trace.pl
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2017-05-23 15:38:47 +0100
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2017-05-23 16:59:46 +0100
commit2f64c684b651993425a5d12b5cb2e7b0efc7c997 (patch)
tree46e2341ddd8047ca588ed1b7622575b1230c819a /scripts/trace.pl
parent1af2ae74fa7418a689e479be3e6d406b089fa5e8 (diff)
trace.pl: Option to draw the aggreate GPU busy timeline
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'scripts/trace.pl')
-rwxr-xr-xscripts/trace.pl46
1 files changed, 44 insertions, 2 deletions
diff --git a/scripts/trace.pl b/scripts/trace.pl
index 3e737d13..1c7b3fab 100755
--- a/scripts/trace.pl
+++ b/scripts/trace.pl
@@ -39,6 +39,7 @@ my $html = 0;
my $trace = 0;
my $avg_delay_stats = 0;
my $squash_context_id = 0;
+my $gpu_timeline = 0;
my @args;
@@ -108,6 +109,7 @@ Usage:
--avg-delay-stats Print average delay stats.
--squash-ctx-id Squash context id by substracting engine
id from ctx id.
+ --gpu-timeline Draw overall GPU busy timeline.
ENDHELP
exit 0;
@@ -152,6 +154,18 @@ sub arg_squash_ctx_id
return @_;
}
+sub arg_gpu_timeline
+{
+ return unless scalar(@_);
+
+ if ($_[0] eq '--gpu-timeline') {
+ shift @_;
+ $gpu_timeline = 1;
+ }
+
+ return @_;
+}
+
sub arg_trace
{
my @events = ( 'i915:intel_gpu_freq_change',
@@ -273,6 +287,7 @@ while (@args) {
@args = arg_html(@args);
@args = arg_avg_delay_stats(@args);
@args = arg_squash_ctx_id(@args);
+ @args = arg_gpu_timeline(@args);
@args = arg_trace(@args);
@args = arg_max_items(@args);
@args = arg_zoom_width(@args);
@@ -749,6 +764,7 @@ foreach my $gid (sort keys %rings) {
}
# Calculate overall GPU idle time
+my @gpu_intervals;
my (@s_, @e_);
# Extract all GPU busy intervals and sort them.
@@ -784,6 +800,13 @@ for my $i (0..$#s_) {
$total = $total + ($e_[$i] - $s_[$i]);
}
+# Generate data for the GPU timeline if requested
+if ($gpu_timeline) {
+ for my $i (0..$#s_) {
+ push @gpu_intervals, [ $s_[$i], $e_[$i] ];
+ }
+}
+
$flat_busy{'gpu-busy'} = $total / ($last_ts - $first_ts) * 100.0;
$flat_busy{'gpu-idle'} = (1.0 - $total / ($last_ts - $first_ts)) * 100.0;
@@ -886,10 +909,14 @@ sub stdio_stats
}
print "\t{id: 0, content: 'Freq'},\n" if $html;
+print "\t{id: 1, content: 'GPU'},\n" if $gpu_timeline;
+
+my $engine_start_id = $gpu_timeline ? 2 : 1;
+
foreach my $group (sort keys %rings) {
my $name;
my $ring = $ringmap{$rings{$group}};
- my $id = 1 + $rings{$group};
+ my $id = $engine_start_id + $rings{$group};
my $elapsed = $last_ts - $first_ts;
my %stats;
@@ -927,7 +954,7 @@ foreach my $key (sort {$db{$a}->{'queue'} <=> $db{$b}->{'queue'}} keys %db) {
my ($queue, $start, $notify, $end) = ($db{$key}->{'queue'}, $db{$key}->{'start'}, $db{$key}->{'notify'}, $db{$key}->{'end'});
my $submit = $queue + $db{$key}->{'submit-delay'};
my ($content, $style);
- my $group = 1 + $rings{$db{$key}->{'ring'}};
+ my $group = $engine_start_id + $rings{$db{$key}->{'ring'}};
my $type = ' type: \'range\',';
my $startend;
my $skey;
@@ -1002,6 +1029,21 @@ foreach my $item (@freqs) {
$i++;
}
+if ($gpu_timeline) {
+ foreach my $item (@gpu_intervals) {
+ my ($start, $end) = @$item;
+ my $startend;
+
+ next if $start > $last_ts;
+
+ $start = $first_ts if $start < $first_ts;
+ $end = $last_ts if $end > $last_ts;
+ $startend = 'start: \'' . ts($start) . '\', end: \'' . ts($end) . '\'';
+ print "\t{id: $i, type: 'range', group: 1, $startend},\n";
+ $i++;
+ }
+}
+
my $end_ts = ts($first_ts + $width_us);
$first_ts = ts($first_ts);