diff options
author | Eric Anholt <[email protected]> | 2012-12-10 09:44:19 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2012-12-14 15:05:10 -0800 |
commit | f74560f3fb516971e6a7b03a2382db2f58699f59 (patch) | |
tree | 45c28d454046d7d7dc9ec50f29ca39b47a95ba5a /src/mesa/drivers/dri/i965/brw_program.c | |
parent | 338b5f887d462bbe7ef58a233cd00619e43415f0 (diff) |
i965: Scale shader_time to compensate for resets.
Some shaders experience resets more than others, which skews the numbers
reported. Attempt to correct for this by linearly scaling according to
the number of resets that happen.
Note that will not be accurate if invocations of shaders have varying
times and longer invocations are more likely to reset. However, this
should at least be better than the previous situation.
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_program.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.c | 72 |
1 files changed, 66 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 1859041bc27..035824171e3 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -222,16 +222,73 @@ compare_time(const void *a, const void *b) } static void +get_written_and_reset(struct brw_context *brw, int i, + uint64_t *written, uint64_t *reset) +{ + enum shader_time_shader_type type = brw->shader_time.types[i]; + assert(type == ST_VS || type == ST_FS8 || type == ST_FS16); + + /* Find where we recorded written and reset. */ + int wi, ri; + + for (wi = i; brw->shader_time.types[wi] != type + 1; wi++) + ; + + for (ri = i; brw->shader_time.types[ri] != type + 2; ri++) + ; + + *written = brw->shader_time.cumulative[wi]; + *reset = brw->shader_time.cumulative[ri]; +} + +static void brw_report_shader_time(struct brw_context *brw) { if (!brw->shader_time.bo || !brw->shader_time.num_entries) return; + uint64_t scaled[brw->shader_time.num_entries]; uint64_t *sorted[brw->shader_time.num_entries]; double total = 0; for (int i = 0; i < brw->shader_time.num_entries; i++) { - sorted[i] = &brw->shader_time.cumulative[i]; - total += brw->shader_time.cumulative[i]; + uint64_t written = 0, reset = 0; + + sorted[i] = &scaled[i]; + + switch (brw->shader_time.types[i]) { + case ST_VS_WRITTEN: + case ST_VS_RESET: + case ST_FS8_WRITTEN: + case ST_FS8_RESET: + case ST_FS16_WRITTEN: + case ST_FS16_RESET: + /* We'll handle these when along with the time. */ + scaled[i] = 0; + continue; + + case ST_VS: + case ST_FS8: + case ST_FS16: + get_written_and_reset(brw, i, &written, &reset); + break; + + default: + /* I sometimes want to print things that aren't the 3 shader times. + * Just print the sum in that case. + */ + written = 1; + reset = 0; + break; + } + + uint64_t time = brw->shader_time.cumulative[i]; + if (written) { + scaled[i] = time / written * (written + reset); + } else { + scaled[i] = time; + } + + total += scaled[i]; } if (total == 0) { @@ -245,7 +302,10 @@ brw_report_shader_time(struct brw_context *brw) printf("type ID cycles spent %% of total\n"); for (int s = 0; s < brw->shader_time.num_entries; s++) { /* Work back from the sorted pointers times to a time to print. */ - int i = sorted[s] - brw->shader_time.cumulative; + int i = sorted[s] - scaled; + + if (scaled[i] == 0) + continue; int shader_num = -1; if (brw->shader_time.programs[i]) { @@ -268,9 +328,9 @@ brw_report_shader_time(struct brw_context *brw) } printf("%16lld (%7.2f Gcycles) %4.1f%%\n", - (long long)brw->shader_time.cumulative[i], - (double)brw->shader_time.cumulative[i] / 1000000000.0, - (double)brw->shader_time.cumulative[i] / total * 100.0); + (long long)scaled[i], + (double)scaled[i] / 1000000000.0, + (double)scaled[i] / total * 100.0); } } |