[igt-dev] [PATCH] i915/gem_spin_batch: Add test to execute in parallel on all engines

Vanshidhar Konda vanshidhar.r.konda at intel.com
Thu Oct 31 18:01:59 UTC 2019


Add a test that submits batch buffers to all engines and executes them
in parallel; either from the same context or from new contexts for each
engine.

Signed-off-by: Vanshidhar Konda <vanshidhar.r.konda at intel.com>
---
 tests/i915/gem_spin_batch.c | 53 +++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index df59512a..c79cb7ea 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -136,6 +136,54 @@ static void spin_on_all_engines(int fd, unsigned int timeout_sec)
 	igt_waitchildren();
 }
 
+#define PARALLEL_SPIN_NEW_CTX (1 << 0)
+static void parallel_spin_all_engines(int fd, unsigned int flags)
+{
+	igt_spin_t *spinner[I915_EXEC_RING_MASK + 1];
+	uint32_t ctx[I915_EXEC_RING_MASK + 1];
+	struct intel_execution_engine2 *engine;
+	int num_engines;
+	int i;
+
+	ctx[0] = gem_context_create(fd);
+	gem_context_set_all_engines(fd, ctx[0]);
+
+	for (i = 1; i < I915_EXEC_RING_MASK + 1; i++) {
+		ctx[i] = ctx[0];
+		if (flags & PARALLEL_SPIN_NEW_CTX) {
+			ctx[i] = gem_context_create(fd);
+			gem_context_set_all_engines(fd, ctx[i]);
+		}
+	}
+
+	i = 0;
+	for_each_context_engine(fd, ctx[0], engine) {
+		igt_debug("Starting spin on engine: %d\n", i);
+		spinner[i] = igt_spin_new(fd,
+					  .ctx = ctx[i],
+					  .engine = i,
+					  .flags = (IGT_SPIN_POLL_RUN |
+						   IGT_SPIN_NO_PREEMPTION));
+		i++;
+	}
+
+	num_engines = i;
+	for (i = 0; i < num_engines; i++) {
+		igt_debug("Busy wait for engine: %d\n", i);
+		igt_spin_busywait_until_started(spinner[i]);
+
+	}
+
+	for (i = 0; i < num_engines; i++)
+		igt_spin_free(fd, spinner[i]);
+
+	if (flags & PARALLEL_SPIN_NEW_CTX) {
+		for (i = 1; i < I915_EXEC_RING_MASK + 1; i++)
+			gem_context_destroy(fd, ctx[i]);
+	}
+	gem_context_destroy(fd, ctx[0]);
+}
+
 igt_main
 {
 	const struct intel_execution_engine2 *e2;
@@ -189,6 +237,11 @@ igt_main
 	igt_subtest("spin-each")
 		spin_on_all_engines(fd, 3);
 
+	igt_subtest("spin-all-parallel")
+		parallel_spin_all_engines(fd, 0);
+	igt_subtest("spin-all-parallel-new-ctx")
+		parallel_spin_all_engines(fd, PARALLEL_SPIN_NEW_CTX);
+
 	igt_fixture {
 		igt_stop_hang_detector();
 		close(fd);
-- 
2.23.0



More information about the igt-dev mailing list