diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2016-12-14 17:56:13 +0000 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-01-30 15:57:18 +0000 |
commit | 7d0106040dbe9da5f4973024749b3ab1effe7998 (patch) | |
tree | f9ebdc2d7da33518f9e9ccb8fba54a03be4bef39 | |
parent | 385a9361bdabe2c32fdc9b06aacf063c7fd2b9bb (diff) |
gem_exec_nop: Test context concurrency and engine featurescontext-bb-balancing
Two new subtests, bsd-concurrent and bsd-concurrent-hevc to
verify the context concurrency and engine features API.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-rw-r--r-- | tests/gem_exec_nop.c | 94 |
1 files changed, 82 insertions, 12 deletions
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c index 78dccbbe..58b41bf8 100644 --- a/tests/gem_exec_nop.c +++ b/tests/gem_exec_nop.c @@ -49,22 +49,28 @@ #define ENGINE_FLAGS (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK) +#define LOCAL_I915_EXEC_ENGINE_CAP_SHIFT (18) +#define LOCAL_I915_EXEC_ENGINE_CAP_MASK (15 << LOCAL_I915_EXEC_ENGINE_CAP_SHIFT) +#define LOCAL_I915_EXEC_NEED_BSD_HEVC (1 << LOCAL_I915_EXEC_ENGINE_CAP_SHIFT) + static double elapsed(const struct timespec *start, const struct timespec *end) { return ((end->tv_sec - start->tv_sec) + (end->tv_nsec - start->tv_nsec)*1e-9); } -static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id, - int timeout, unsigned long *out) +static double nop_on_ring(int fd, uint32_t *handles, unsigned int num_handles, + unsigned ring_id, int timeout, unsigned long *out, + uint32_t ctx_id) { struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj; struct timespec start, now; unsigned long count; + unsigned int h = 0; memset(&obj, 0, sizeof(obj)); - obj.handle = handle; + obj.handle = handles[0]; memset(&execbuf, 0, sizeof(execbuf)); execbuf.buffers_ptr = to_user_pointer(&obj); @@ -72,6 +78,7 @@ static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id, execbuf.flags = ring_id; execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; + i915_execbuffer2_set_context_id(execbuf, ctx_id); if (__gem_execbuf(fd, &execbuf)) { execbuf.flags = ring_id; gem_execbuf(fd, &execbuf); @@ -81,8 +88,12 @@ static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id, count = 0; clock_gettime(CLOCK_MONOTONIC, &start); do { - for (int loop = 0; loop < 1024; loop++) + for (int loop = 0; loop < 1024; loop++) { + obj.handle = handles[h++]; + if (h == num_handles) + h = 0; gem_execbuf(fd, &execbuf); + } count += 1024; clock_gettime(CLOCK_MONOTONIC, &now); @@ -93,17 +104,21 @@ static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id, return elapsed(&start, &now); } -static void single(int fd, uint32_t handle, - unsigned ring_id, const char *ring_name) +static double single(int fd, uint32_t *handles, unsigned int num_handles, + unsigned ring_id, const char *ring_name, + int timeout, uint32_t ctx) { double time; unsigned long count; gem_require_ring(fd, ring_id); - time = nop_on_ring(fd, handle, ring_id, 20, &count); + time = nop_on_ring(fd, handles, num_handles, ring_id, timeout, + &count, ctx); igt_info("%s: %'lu cycles: %.3fus\n", ring_name, count, time*1e6 / count); + + return time; } static bool ignore_engine(int fd, unsigned engine) @@ -138,7 +153,7 @@ static void parallel(int fd, uint32_t handle, int timeout) names[nengine] = e__->name; nengine++; - time = nop_on_ring(fd, handle, engine, 1, &count) / count; + time = nop_on_ring(fd, &handle, 1, engine, 1, &count, 0) / count; sum += time; igt_debug("%s: %.3fus\n", e__->name, 1e6*time); } @@ -199,7 +214,8 @@ static void series(int fd, uint32_t handle, int timeout) if (ignore_engine(fd, engine)) continue; - time = nop_on_ring(fd, handle, engine, 1, &count) / count; + time = nop_on_ring(fd, &handle, 1, + engine, 1, &count, 0) / count; if (time > max) { name = e__->name; max = time; @@ -299,11 +315,17 @@ out: igt_main { const struct intel_execution_engine *e; - uint32_t handle = 0; - int device = -1; + uint32_t handle = 0, ctx; + const unsigned int num_handles = 8; + const unsigned int num_nop = 1000000; + uint32_t handles[num_handles]; + int device = -1, i; igt_fixture { const uint32_t bbe = MI_BATCH_BUFFER_END; + struct local_i915_gem_context_param arg; + unsigned int batch_size = num_nop * 4 + 4; + uint32_t *batch; device = drm_open_driver(DRIVER_INTEL); print_welcome(device); @@ -311,6 +333,22 @@ igt_main handle = gem_create(device, 4096); gem_write(device, handle, 0, &bbe, sizeof(bbe)); + batch = malloc(batch_size); + memset(batch, 0, batch_size); + batch[num_nop - 1] = bbe; + + for (i = 0; i < num_handles; i++) { + handles[i] = gem_create(device, batch_size); + gem_write(device, handles[i], 0, batch, batch_size); + } + + ctx = gem_context_create(device); + memset(&arg, 0, sizeof(arg)); + arg.context = ctx; + arg.param = LOCAL_CONTEXT_PARAM_CONCURRENCY; + arg.value = 1 << (I915_EXEC_BSD - 1); + gem_context_set_param(device, &arg); + igt_fork_hang_detector(device); } @@ -322,7 +360,39 @@ igt_main for (e = intel_execution_engines; e->name; e++) igt_subtest_f("%s", e->name) - single(device, handle, e->exec_id | e->flags, e->name); + single(device, &handle, 1, + e->exec_id | e->flags, e->name, 20, 0); + + igt_subtest("bsd-concurrent") { + double t1, t2; + +// igt_require(gem_has_bsd2(fd)); + + t1 = single(device, handles, num_handles, + I915_EXEC_BSD, "bsd-bb", 5, 0); + + t2 = single(device, handles, num_handles, + I915_EXEC_BSD, "bsd-bb-balance", 5, ctx); + + igt_assert(t2 < t1); + igt_assert((t1 - t2) < (0.6f * t1)); + } + + igt_subtest("bsd-concurrent-hevc") { + double t1, t2; + +// igt_require(gem_has_bsd2(fd)); + + t1 = single(device, handles, num_handles, + I915_EXEC_BSD | LOCAL_I915_EXEC_NEED_BSD_HEVC, + "bsd-bb-balance-hevc", 5, ctx); + + t2 = single(device, handles, num_handles, + I915_EXEC_BSD, "bsd-bb-balance", 5, ctx); + + igt_assert(t2 < t1); + igt_assert((t1 - t2) < (0.6f * t1)); + } igt_subtest("series") series(device, handle, 150); |