additional intel_gpu_top profiling features
cover additional intel_gpu_top profiling features
From: Eugeni Dodonov <[email protected]>
This patchset adds a number of small but useful features into intel_gpu_top tool, as asked by Chris Wilson:
- support for getopt to customize internal parameters at runtime (such as number of samplings per second).
- possibility of non-interactive execution to collect GPU usage into a log file for future analysis
- possibility to profile a specific command, leaving when the profiled command reaches its end of the execution
- collection of initial statistics before the profile starts.
- account for the time spent within syscalls to provide more appropriate logging and more precise screen updates (e.g., instead of refreshing once a second, we could potentially take way longer than that due to the system calls overhead)
Eugeni Dodonov (6):
intel_gpu_top: account for time spent in syscalls
intel_gpu_top: suport command line parameters and variable samples
per second
intel_gpu_tool: initial support for non-screen output
intel_gpu_top: initialize monitoring statistics at startup
intel_gpu_top: support non-interactive mode
intel_gpu_top: support profiling user-specified commands
man/intel_gpu_top.1 | 22 ++++ tools/intel_gpu_top.c | 303 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 280 insertions(+), 45 deletions(-)
Signature · 1 line
1.7.6.1
PATCH 1/6 intel_gpu_top: account for time spent in syscalls
From: Eugeni Dodonov <[email protected]>
This allows intel_gpu_top to properly account for time spent inside system calls. Effectively, with previous implementation, intel_gpu_top could spent longer than 1s between consecutive measures. This attempts to minimize the extra time spent while polling for data.
--- tools/intel_gpu_top.c | 53 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 41 insertions(+), 12 deletions(-)
tools/intel_gpu_top.c +41 -12
@@ -1,5 +1,6 @@/* * Copyright © 2007 Intel Corporation +* Copyright © 2011 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"),
@@ -22,6 +23,7 @@* * Authors: * Eric Anholt <[email protected]> +* Eugeni Dodonov <[email protected]> * */
@@ -30,6 +32,7 @@#include <stdio.h> #include <err.h> #include <sys/ioctl.h> +#include <sys/time.h> #include "intel_gpu_tools.h" #include "instdone.h"
@@ -104,6 +107,14 @@ const char *stats_reg_names[STATS_COUNT] = {uint64_t stats[STATS_COUNT ];uint64_t last_stats[STATS_COUNT ]; +static unsigned long +gettime (void ) +{ +struct timeval t; +gettimeofday (&t,NULL ); +return (t.tv_usec + (t.tv_sec *1000000 )); +} +static int top_bits_sort (const void *a,const void *b) {
@@ -362,21 +373,23 @@ static void ring_sample(struct ring *ring) ring->full += full; } -static void ring_print (struct ring *ring) +static void ring_print (struct ring *ring,unsigned long samples_per_sec) { -int percent, len; +int samples_to_percent_ratio, percent, len;if (!ring->size)return ; - percent =100 - ring->idle /SAMPLES_TO_PERCENT_RATIO ; +/* Calculate current value of samples_to_percent_ratio */ + samples_to_percent_ratio = (ring->idle *100 ) / samples_per_sec; + percent =100 - samples_to_percent_ratio; len =printf ("%25s busy: %3d%%: " , ring->name, percent);print_percentage_bar (percent, len);printf ("%24s space: %d/%d (%d%%)\n" , ring->name, - (int )(ring->full /SAMPLES_PER_SEC ), + (int )(ring->full / samples_per_sec), ring->size, - (int )((ring->full /SAMPLES_TO_PERCENT_RATIO ) / ring->size)); + (int )((ring->full / samples_to_percent_ratio) / ring->size)); }int main (int argc,char **argv)
@@ -418,18 +431,25 @@ int main(int argc, char **argv)for (;;) {int j; +unsigned long long t1, ti, tf; +unsigned long long def_sleep =1000000 /SAMPLES_PER_SEC ; +unsigned long long last_samples_per_sec =SAMPLES_PER_SEC ;char clear_screen[] = {0x1b ,'[' ,'H' ,0x1b ,'[' ,'J' ,0x0 };int percent;int len; + t1 =gettime (); +ring_reset (&render_ring);ring_reset (&bsd_ring);ring_reset (&bsd6_ring);ring_reset (&blt_ring);for (i =0 ; i <SAMPLES_PER_SEC ; i++) { +long long interval; + ti =gettime ();if (IS_965 (devid)) { instdone =INREG (INST_DONE_I965 ); instdone1 =INREG (INST_DONE_1 );
@@ -443,7 +463,16 @@ int main(int argc, char **argv)ring_sample (&bsd_ring);ring_sample (&bsd6_ring);ring_sample (&blt_ring); -usleep (1000000 /SAMPLES_PER_SEC ); + + tf =gettime (); +if (tf - t1 >=1000000 ) { +/* We are out of sync, bail out */ + last_samples_per_sec = i+1 ; +break ; + } + interval = def_sleep - (tf - ti); +if (interval >0 ) +usleep (interval); }if (HAS_STATS_REGS (devid)) {
@@ -477,16 +506,16 @@ int main(int argc, char **argv)print_clock_info (pci_dev); -ring_print (&render_ring); -ring_print (&bsd_ring); -ring_print (&bsd6_ring); -ring_print (&blt_ring); +ring_print (&render_ring, last_samples_per_sec); +ring_print (&bsd_ring, last_samples_per_sec); +ring_print (&bsd6_ring, last_samples_per_sec); +ring_print (&blt_ring, last_samples_per_sec);printf ("\n%30s %s\n" ,"task" ,"percent busy" );for (i =0 ; i < max_lines; i++) {if (top_bits_sorted[i]->count >0 ) { - percent = top_bits_sorted[i]->count / -SAMPLES_TO_PERCENT_RATIO ; + percent = (top_bits_sorted[i]->count *100 ) / + last_samples_per_sec; len =printf ("%30s: %3d%%: " , top_bits_sorted[i]->bit->name, percent);
Signature · 6 lines
1.7.6.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 intel_gpu_top: suport command line parameters and variable samples per second
In reply to Eugeni DodonovFrom: Eugeni Dodonov <[email protected]>
This patch adds support for getopt, and adds two default parameters to it:
-h to show usage notes; and -s to allow user to define number of samples to acquire per second.
Manpage documentation is also adjusted accordingly.
--- man/intel_gpu_top.1 | 9 ++++++++ tools/intel_gpu_top.c | 52 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 4 deletions(-)
man/intel_gpu_top.1 +9 -0
@@ -4,11 +4,20 @@ .SH NAME intel_gpu_top \- Display a top-like summary of Intel GPU usage .SH SYNOPSIS +.nf .B intel_gpu_top +.B intel_gpu_top [ parameters ] .SH DESCRIPTION .B intel_gpu_top is a tool to display usage information of an Intel GPU. It requires root privilege to map the graphics device. +.SS Options +.TP +.B -s [samples per second] +number of samples to acquire per second +.TP +.B -h +show usage notes .PP Note that idle units are not displayed, so an entirely idle GPU will only display the ring status and
tools/intel_gpu_top.c +48 -4
76 lines not on this page · raw message
Signature · 1 line
1.7.6.1
Re: [PATCH 2/6] intel_gpu_top: suport command line parameters and variable samples per second
Quoted 5 lines · Eugeni Dodonov
From: Eugeni Dodonov <[email protected]>
This patch adds support for getopt, and adds two default parameters to it:
-h to show usage notes; and -s to allow user to define number of samples to acquire per second.
Just a minor style issue, otherwise it looks good. All I need is someway to correlate GPU activity with batches (and especially the contents of those batches) and with even higher level code and then I'd be happy. Oh, and integrated with a timeline of CPU activity, of course. :-)
tools/intel_gpu_top.c int main(int argc, char **argv) · line 436
Quoted 6 lines
tools/intel_gpu_top.c +6
-0+/* Parse options? */ +while ((ch =getopt (argc, argv,"s:h" )) !=-1 ) + { +switch (ch) + { +case 's' : samples_per_sec =atoi (optarg);
In the modules we own, we have adopted the kernel CODING_STYLE as our standard. 8 space indents, 80 cols line (except where readibility is improved by going over), braces on the same line as the control flow, /*
* This style of long comments.
*/
and case statements should being at the same indentation as the switch and so should the parameters of a multiline function... -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 2/6] intel_gpu_top: suport command line parameters and variable samples per second
Quoted 4 lines · Chris Wilson
In the modules we own, we have adopted the kernel
CODING_STYLEas our standard. 8 space indents, 80 cols line (except where readibility is improved by going over), braces on the same line as the control flow,
Fixed, thanks!
Signature · 1 line
Eugeni Dodonov <http://eugeni.dodonov.net/>
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/6 intel_gpu_tool: initial support for non-screen output
In reply to Eugeni DodonovFrom: Eugeni Dodonov <[email protected]>
This patch adds initial support for non-stdio output, to be used for non-interactive monitoring.
--- tools/intel_gpu_top.c | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
tools/intel_gpu_top.c +15 -13
@@ -373,7 +373,8 @@ static void ring_sample(struct ring *ring) ring->full += full; } -static void ring_print (struct ring *ring,unsigned long samples_per_sec) +static void ring_print (struct ring *ring,unsigned long samples_per_sec, +FILE *output) {int samples_to_percent_ratio, percent, len;
@@ -383,9 +384,9 @@ static void ring_print(struct ring *ring, unsigned long samples_per_sec)/* Calculate current value of samples_to_percent_ratio */ samples_to_percent_ratio = (ring->idle *100 ) / samples_per_sec; percent =100 - samples_to_percent_ratio; - len =printf ("%25s busy: %3d%%: " , ring->name, percent); + len =fprintf (output,"%25s busy: %3d%%: " , ring->name, percent);print_percentage_bar (percent, len); - printf("%24s space: %d/%d (%d%%)\n", + fprintf(output, "%24s space: %d/%d (%d%%)\n", ring->name, (int)(ring->full / samples_per_sec), ring->size,
@@ -427,6 +428,7 @@ int main(int argc, char **argv) };int i, ch;int samples_per_sec =SAMPLES_PER_SEC ; +FILE *output = stdout;/* Parse options? */ while ((ch =getopt (argc, argv,"s:h" )) !=-1 )
@@ -546,30 +548,30 @@ int main(int argc, char **argv)if (max_lines >= num_instdone_bits) max_lines = num_instdone_bits; -printf ("%s" , clear_screen); +fprintf (output,"%s" , clear_screen);print_clock_info (pci_dev); -ring_print (&render_ring, last_samples_per_sec); -ring_print (&bsd_ring, last_samples_per_sec); -ring_print (&bsd6_ring, last_samples_per_sec); -ring_print (&blt_ring, last_samples_per_sec); +ring_print (&render_ring, last_samples_per_sec, output); +ring_print (&bsd_ring, last_samples_per_sec, output); +ring_print (&bsd6_ring, last_samples_per_sec, output); +ring_print (&blt_ring, last_samples_per_sec, output); -printf ("\n%30s %s\n" ,"task" ,"percent busy" ); +fprintf (output,"\n%30s %s\n" ,"task" ,"percent busy" );for (i =0 ; i < max_lines; i++) {if (top_bits_sorted[i]->count >0 ) { percent = (top_bits_sorted[i]->count *100 ) / last_samples_per_sec; - len =printf ("%30s: %3d%%: " , + len =fprintf (output,"%30s: %3d%%: " , top_bits_sorted[i]->bit->name, percent);print_percentage_bar (percent, len); }else { -printf ("%*s" ,PERCENTAGE_BAR_END ,"" ); +fprintf (output,"%*s" ,PERCENTAGE_BAR_END ,"" ); }if (i <STATS_COUNT &&HAS_STATS_REGS (devid)) { -printf ("%13s: %llu (%lld/sec)" , +fprintf (output,"%13s: %llu (%lld/sec)" , stats_reg_names[i], stats[i], stats[i] - last_stats[i]);
@@ -578,7 +580,7 @@ int main(int argc, char **argv)if (!top_bits_sorted[i]->count)break ; } -printf ("\n" ); +fprintf (output,"\n" ); }for (i =0 ; i < num_instdone_bits; i++) {
Signature · 1 line
1.7.6.1
Re: [PATCH 3/6] intel_gpu_tool: initial support for non-screen output
Is that really necessary? Isn't "intel_gpu_tool > logfile" enough?
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/6] intel_gpu_tool: initial support for non-screen output
My bad, it is necessary to add file.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/6] intel_gpu_tool: initial support for non-screen output
In reply to Łukasz KuryłoQuoted 4 lines · Łukasz Kuryło
**
Is that really necessary? Isn't "
intel_gpu_tool> logfile" enough?
It would work too, but it won't be parseable easily. The idea here was to have different ways of outputting data in stdout mode (with nice ascii art and CLI features), and in file-out mode (in tab-separated gnuplot and parsing-friendly format).
Signature · 1 line
Eugeni Dodonov <http://eugeni.dodonov.net/>
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/6 intel_gpu_top: initialize monitoring statistics at startup
In reply to Eugeni DodonovFrom: Eugeni Dodonov <[email protected]>
This patch initializes the last_stats[] for registers prior to starting the monitoring itself. This way, the first measure will already contain the difference from the previous value instead of non-initialized value.
--- tools/intel_gpu_top.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
tools/intel_gpu_top.c +16 -0
@@ -475,6 +475,22 @@ int main(int argc, char **argv)ring_init (&blt_ring); } +/* Initialize GPU stats */ +if (HAS_STATS_REGS (devid)) { +for (i =0 ; i <STATS_COUNT ; i++) { +uint32_t stats_high, stats_low, stats_high_2; + +do { + stats_high =INREG (stats_regs[i] +4 ); + stats_low =INREG (stats_regs[i]); + stats_high_2 =INREG (stats_regs[i] +4 ); + }while (stats_high != stats_high_2); + + last_stats[i] = (uint64_t )stats_high <<32 | + stats_low; + } + } +for (;;) {int j;unsigned long long t1, ti, tf;
Signature · 1 line
1.7.6.1
PATCH 5/6 intel_gpu_top: support non-interactive mode
In reply to Eugeni DodonovFrom: Eugeni Dodonov <[email protected]>
This patch adds support for non-interactive mode, invoked by running with '-o output' switch. In this case, no interactive output is being performed, but the execution statistics are being saved into the output file.
The output file is generated in both human and gnuplot-readable format.
Unlike interactive mode, where non-supported pipes and non-active registers are skipped, the content of such pipes and registers is recorded into the log file to simplify parsing and standardize the list of columns.
Also, unlike interactive mode, the registers are not sorted according to the usage - this way, their variation over time can be analysed offline.
--- man/intel_gpu_top.1 | 3 + tools/intel_gpu_top.c | 150 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 112 insertions(+), 41 deletions(-)
man/intel_gpu_top.1 +3 -0
@@ -16,6 +16,9 @@ privilege to map the graphics device. .B -s [samples per second] number of samples to acquire per second .TP +.B -o [output file] +run non-interactively and collect usage statistics to [file] +.TP .B -h show usage notes .PP
tools/intel_gpu_top.c +109 -41
200 lines not on this page · raw message
Signature · 1 line
1.7.6.1
PATCH 6/6 intel_gpu_top: support profiling user-specified commands
In reply to Eugeni DodonovFrom: Eugeni Dodonov <[email protected]>
This patch adds support for running intel_gpu_top to profile specific commands. The required command will be carried out in separate process, and main intel_gpu_top will leave when the child process will exit.
--- man/intel_gpu_top.1 | 10 ++++++++ tools/intel_gpu_top.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletions(-)
man/intel_gpu_top.1 +10 -0
@@ -19,8 +19,18 @@ number of samples to acquire per second .B -o [output file] run non-interactively and collect usage statistics to [file] .TP +.B -e ["command to profile"] +execute a command, and leave when it is finished. Note that the entire command +with all parameters should be included as one parameter. +.TP .B -h show usage notes +.SH EXAMPLES +.TP +intel_gpu_top -o "cairo-trace-gvim.log" -s 100 -e "cairo-perf-trace /tmp/gvim" +will run cairo-perf-trace with /tmp/gvim trace, non-interactively, saving the +statistics into cairo-trace-gvim.log file, and collecting 100 samples per +second. .PP Note that idle units are not displayed, so an entirely idle GPU will only display the ring status and
tools/intel_gpu_top.c +55 -1
86 lines not on this page · raw message
Signature · 1 line
1.7.6.1