[PATCH i-g-t v3] igt/gem_exec_nop/headless: Verify GT performance in headless mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

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@xxxxxxxxx>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <imre.deak@xxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 tests/gem_exec_nop.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 5d0d4957545e..66c2fc1dfa3c 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);
-- 
2.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux