diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-04-13 14:11:05 +0100 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-04-19 11:19:44 +0100 |
commit | 8e4cfb2ac60d5d00e3bd5d742c4d7e3cea190de9 (patch) | |
tree | 6da81e2635cc0ac9da1ee4022492292fbf5917f3 | |
parent | ac1fe0968dedf7e6ce8885e18f8d3c68984e59d2 (diff) |
igt/gem_exec_nop/headless: Verify GT performance in headless mode
Check that no-op execution speed is the same in headless mode
and with the display active.
v2:
* Set graphics mode for the test to disable blanking. (Imre)
* Use igt stats framework as suggested by Chris.
v3:
* Rename variable names for clearer assert.
* Simplify by using I915_EXEC_DEFAULT. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <imre.deak@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Petri Latvala <petri.latvala@intel.com>
-rw-r--r-- | tests/gem_exec_nop.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index 5d0d4957..66c2fc1d 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -112,6 +112,73 @@ static void single(int fd, uint32_t handle, ring_name, count, time*1e6 / count); } +static double +stable_nop_on_ring(int fd, uint32_t handle, unsigned int engine, + int timeout, int reps) +{ + igt_stats_t s; + double n; + + igt_assert(reps >= 5); + + igt_stats_init_with_size(&s, reps); + s.is_float = true; + + while (reps--) { + unsigned long count; + double time; + + time = nop_on_ring(fd, handle, engine, timeout, &count); + igt_stats_push_float(&s, time / count); + } + + n = igt_stats_get_median(&s); + igt_stats_fini(&s); + + return n; +} + +#define assert_within_epsilon(x, ref, tolerance) \ + igt_assert_f((x) <= (1.0 + tolerance) * ref && \ + (x) >= (1.0 - tolerance) * ref, \ + "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\ + #x, #ref, x, tolerance * 100.0, ref) + +static void headless(int fd, uint32_t handle) +{ + unsigned int nr_connected = 0; + drmModeConnector *connector; + drmModeRes *res; + double n_display, n_headless; + + res = drmModeGetResources(fd); + igt_assert(res); + + /* require at least one connected connector for the test */ + for (int i = 0; i < res->count_connectors; i++) { + connector = drmModeGetConnectorCurrent(fd, res->connectors[i]); + if (connector->connection == DRM_MODE_CONNECTED) + nr_connected++; + drmModeFreeConnector(connector); + } + igt_require(nr_connected > 0); + + /* set graphics mode to prevent blanking */ + kmstest_set_vt_graphics_mode(); + + /* benchmark nops */ + n_display = stable_nop_on_ring(fd, handle, I915_EXEC_DEFAULT, 1, 5); + + /* force all connectors off */ + kmstest_unset_all_crtcs(fd, res); + + /* benchmark nops again */ + n_headless = stable_nop_on_ring(fd, handle, I915_EXEC_DEFAULT, 1, 5); + + /* check that the two execution speeds are roughly the same */ + assert_within_epsilon(n_headless, n_display, 0.1f); +} + static bool ignore_engine(int fd, unsigned engine) { if (engine == 0) @@ -494,6 +561,9 @@ igt_main igt_subtest("context-sequential") sequential(device, handle, FORKED | CONTEXT, 150); + igt_subtest("headless") + headless(device, handle); + igt_fixture { igt_stop_hang_detector(); gem_close(device, handle); |