[PATCH i-g-t v2] 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.

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>
---
 tests/gem_exec_nop.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 5d0d4957545e..1710bf4599fb 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -112,6 +112,74 @@ 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)
+{
+	const struct intel_execution_engine *e = &intel_execution_engines[0];
+	unsigned int nr_connected = 0;
+	drmModeConnector *connector;
+	drmModeRes *res;
+	double n[2];
+
+	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[0] = stable_nop_on_ring(fd, handle, e->exec_id | e->flags, 1, 5);
+
+	/* force all connectors off */
+	kmstest_unset_all_crtcs(fd, res);
+
+	/* benchmark nops again */
+	n[1] = stable_nop_on_ring(fd, handle, e->exec_id | e->flags, 1, 5);
+
+	/* check that the two execution speeds are roughly the same */
+	assert_within_epsilon(n[1], n[0], 0.1f);
+}
+
 static bool ignore_engine(int fd, unsigned engine)
 {
 	if (engine == 0)
@@ -494,6 +562,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