Skip to contentSkip to conversation

igt/gem_exec_nop/headless: Verify GT performance in headless mode

PATCH Superseded Tvrtko Ursulin 3 participants 6 messages Apr 13, 2017 – Apr 19, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igt/gem_exec_nop/headless: Verify GT performance in headless mode

From: Tvrtko Ursulin <[email protected]>

Check that no-op execution speed is the same in headless mode and with the display active.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <[email protected]>

---
 tests/gem_exec_nop.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/gem_exec_nop.c +42 -0
index 5d0d4957545e..e0e53a3108c6 100644
@@ -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);
+
+	/* 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);
+}
+
 static bool ignore_engine(int fd, unsigned engine)
 {
 	if (engine == 0)
@@ -494,6 +533,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);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 30 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Check that no-op execution speed is the same in headless mode and with the display active.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <[email protected]>

---
 tests/gem_exec_nop.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/gem_exec_nop.c +10 -0
index 5d0d4957545e..e0e53a3108c6 100644
@@ -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);

tests/gem_exec_nop.c static void single(int fd, uint32_t handle, · line 134

Quoted 10 lines
tests/gem_exec_nop.c +10 -0
+	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);

You could do an actual modeset in case fbcon is not configured. Also need to call kmstest_set_vt_graphics_mode() to prevent blanking. Otherwise the display part looks ok to me.

--Imre

Quoted 35 lines
tests/gem_exec_nop.c +22 -0
+
+	/* 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);
+
+	/* 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);
+}
+
 static bool ignore_engine(int fd, unsigned engine)
 {
 	if (engine == 0)
@@ -494,6 +533,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);
Signature · 1 line
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Tvrtko Ursulin
Quoted 35 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Check that no-op execution speed is the same in headless mode and with the display active.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <[email protected]>

---
 tests/gem_exec_nop.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/gem_exec_nop.c +15 -0
index 5d0d4957545e..e0e53a3108c6 100644
@@ -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]);

tests/gem_exec_nop.c static void single(int fd, uint32_t handle, · line 139

Quoted 10 lines
tests/gem_exec_nop.c +10 -0
+		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);

tests/gem_exec_nop.c static void single(int fd, uint32_t handle, · line 151

Quoted 12 lines
tests/gem_exec_nop.c +12 -0
+
+	/* 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

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH v2 1/1 igt/gem_exec_nop/headless: Verify GT performance in headless mode

From: Tvrtko Ursulin <[email protected]>

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.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572
Cc: Imre Deak <[email protected]>
Cc: Chris Wilson <[email protected]>

---
 tests/gem_exec_nop.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
tests/gem_exec_nop.c +71 -0
index 5d0d4957545e..1710bf4599fb 100644
@@ -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);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 1/1
#4 lore raw
Quoted 15 lines · Tvrtko Ursulin
tests/gem_exec_nop.c +15 -0
+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)

tests/gem_exec_nop.c static void single(int fd, uint32_t handle, · line 171

Quoted 10 lines
tests/gem_exec_nop.c +10 -0
+			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);

Minor, just use I915_EXEC_DEFAULT that has the semantics you want.

I think the test is interesting and further improvements can be made in situ.

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v3 1/1 igt/gem_exec_nop/headless: Verify GT performance in headless mode

From: Tvrtko Ursulin <[email protected]>

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)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100572

---
 tests/gem_exec_nop.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
tests/gem_exec_nop.c +70 -0
index 5d0d4957545e..66c2fc1dfa3c 100644
@@ -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);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx