[igt-dev] [PATCH igt] igt/gem_exec_schedule: Trim max number of contexts used

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 13 09:26:48 UTC 2018


icl offers a much reduced context space, and in its simplest setup we
cannot allocate one context per priority level, so trim the number and
reuse the same context for multiple priority requests.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/gem_exec_schedule.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index 05f7ae38..ec02d994 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -43,6 +43,8 @@
 #define BUSY_QLEN 8
 #define MAX_ELSP_QLEN 16
 
+#define MAX_CONTEXTS 256
+
 IGT_TEST_DESCRIPTION("Check that we can control the order of execution");
 
 static void store_dword(int fd, uint32_t ctx, unsigned ring,
@@ -556,8 +558,8 @@ static void preemptive_hang(int fd, unsigned ring)
 static void deep(int fd, unsigned ring)
 {
 #define XS 8
-	const unsigned int nctx = MAX_PRIO - MIN_PRIO;
-	const unsigned size = ALIGN(4*nctx, 4096);
+	const unsigned int nreq = MAX_PRIO - MIN_PRIO;
+	const unsigned size = ALIGN(4*nreq, 4096);
 	struct timespec tv = {};
 	struct cork cork;
 	uint32_t result, dep[XS];
@@ -565,10 +567,9 @@ static void deep(int fd, unsigned ring)
 	uint32_t *ptr;
 	uint32_t *ctx;
 
-	ctx = malloc(sizeof(*ctx) * nctx);
-	for (int n = 0; n < nctx; n++) {
+	ctx = malloc(sizeof(*ctx) * MAX_CONTEXTS);
+	for (int n = 0; n < MAX_CONTEXTS; n++) {
 		ctx[n] = gem_context_create(fd);
-		gem_context_set_priority(fd, ctx[n], MAX_PRIO - nctx + n);
 	}
 
 	result = gem_create(fd, size);
@@ -592,7 +593,7 @@ static void deep(int fd, unsigned ring)
 		execbuf.buffers_ptr = to_user_pointer(obj);
 		execbuf.buffer_count = XS + 2;
 		execbuf.flags = ring;
-		for (int n = 0; n < nctx; n++) {
+		for (int n = 0; n < MAX_CONTEXTS; n++) {
 			execbuf.rsvd1 = ctx[n];
 			gem_execbuf(fd, &execbuf);
 		}
@@ -603,22 +604,29 @@ static void deep(int fd, unsigned ring)
 	plug(fd, &cork);
 
 	/* Create a deep dependency chain, with a few branches */
-	for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 8; n++)
+	for (int n = 0; n < nreq && igt_seconds_elapsed(&tv) < 8; n++) {
+		uint32_t context = ctx[n % MAX_CONTEXTS];
+		gem_context_set_priority(fd, context, MAX_PRIO - nreq + n);
+
 		for (int m = 0; m < XS; m++)
-			store_dword(fd, ctx[n], ring, dep[m], 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION);
+			store_dword(fd, context, ring, dep[m], 4*n, context, cork.handle, I915_GEM_DOMAIN_INSTRUCTION);
+	}
+
+	for (int n = 0; n < nreq && igt_seconds_elapsed(&tv) < 6; n++) {
+		uint32_t context = ctx[n % MAX_CONTEXTS];
+		gem_context_set_priority(fd, context, MAX_PRIO - nreq + n);
 
-	for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 6; n++) {
 		for (int m = 0; m < XS; m++) {
-			store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], dep[m], 0);
-			store_dword(fd, ctx[n], ring, result, 4*m, ctx[n], 0, I915_GEM_DOMAIN_INSTRUCTION);
+			store_dword(fd, context, ring, result, 4*n, context, dep[m], 0);
+			store_dword(fd, context, ring, result, 4*m, context, 0, I915_GEM_DOMAIN_INSTRUCTION);
 		}
-		expected = ctx[n];
+		expected = context;
 	}
 
 	unplug_show_queue(fd, &cork, ring);
 	igt_require(expected); /* too slow */
 
-	for (int n = 0; n < nctx; n++)
+	for (int n = 0; n < MAX_CONTEXTS; n++)
 		gem_context_destroy(fd, ctx[n]);
 
 	for (int m = 0; m < XS; m++) {
@@ -627,8 +635,8 @@ static void deep(int fd, unsigned ring)
 				I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
 		gem_close(fd, dep[m]);
 
-		for (int n = 0; n < nctx; n++)
-			igt_assert_eq_u32(ptr[n], ctx[n]);
+		for (int n = 0; n < nreq; n++)
+			igt_assert_eq_u32(ptr[n], ctx[n % MAX_CONTEXTS]);
 		munmap(ptr, size);
 	}
 
-- 
2.16.1



More information about the igt-dev mailing list