On Thu, Apr 13, 2017 at 02:14:17PM +0100, Tvrtko Ursulin wrote: > From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > > Check that no-op execution speed is the same in headless mode > and with the display active. > > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572 > Cc: Imre Deak <imre.deak@xxxxxxxxx> > --- > tests/gem_exec_nop.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c > index 5d0d4957545e..e0e53a3108c6 100644 > --- a/tests/gem_exec_nop.c > +++ b/tests/gem_exec_nop.c > @@ -112,6 +112,45 @@ static void single(int fd, uint32_t handle, > ring_name, count, time*1e6 / count); > } > > +static void headless(int fd, uint32_t handle) > +{ > + const struct intel_execution_engine *e = &intel_execution_engines[0]; > + unsigned int nr_connected = 0; > + drmModeConnector *connector; > + drmModeRes *res; > + unsigned long n1, n2; > + double delta; > + > + res = drmModeGetResources(fd); > + igt_assert(res); > + > + /* require 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 == 1); > + > + /* warmup */ > + nop_on_ring(fd, handle, e->exec_id | e->flags, 2, &n1); > + /* benchmark nops */ > + nop_on_ring(fd, handle, e->exec_id | e->flags, 2, &n1); Hmm, using count isn't great by itself as the duration may vary (but significantly? unlikely). Why just 1? How about using the median of 5 runs? static double stable_nop_on_ring(int fd, unsigned int handle, unsigned int engine, int timeout, int reps) { igt_stats_t s; double n; 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; } n[ACTIVE] = stable_nop_on_ring(fd, handle, e>exec_id | e->flags, 2, 5); > + > + /* force the last connector off */ > + kmstest_unset_all_crtcs(fd, res); > + > + /* warmup */ > + nop_on_ring(fd, handle, e->exec_id | e->flags, 2, &n2); > + /* benchmark nops again */ > + nop_on_ring(fd, handle, e->exec_id | e->flags, 2, &n2); > + > + /* check that the two execution speeds are roughly the same */ > + delta = abs((long)n2 - (long)n1); > + igt_assert(delta < n1 * 0.1f); I suggest somethike like (tests/gem_spin_batch.c): #define assert_float_within_epsilon(x, ref, tolerance) \ igt_assert_f((x) <= (1 + tolerance/100.) * ref && \ (x) >= (1 - tolerance/100.) * ref, \ "'%s' != '%s' (%f not within %d%% tolerance of %fd)\n",\ #x, #ref, x, tolerance, ref) assert_float_within_epsilon(n[ACTIVE], n[HEADLESS], 10); -Chris -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx