From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [RFC i-g-t PATCH 2/3] igt/gem_wait: Use new igt_dummyload api
Date: Wed, 12 Oct 2016 14:59:53 +0300 [thread overview]
Message-ID: <20161012115954.16803-3-abdiel.janulgue@linux.intel.com> (raw)
In-Reply-To: <20161012115954.16803-1-abdiel.janulgue@linux.intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
---
tests/gem_wait.c | 77 +++++++++-----------------------------------------------
1 file changed, 12 insertions(+), 65 deletions(-)
diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index 461efdb..24a5f5e 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -54,36 +54,6 @@
#define BUF_PAGES ((8<<20)>>12)
drm_intel_bo *dst, *dst2;
-/* returns time diff in milliseconds */
-static int64_t
-do_time_diff(struct timespec *end, struct timespec *start)
-{
- int64_t ret;
- ret = (MSEC_PER_SEC * difftime(end->tv_sec, start->tv_sec)) +
- ((end->tv_nsec/NSEC_PER_MSEC) - (start->tv_nsec/NSEC_PER_MSEC));
- return ret;
-}
-
-static void blt_color_fill(struct intel_batchbuffer *batch,
- drm_intel_bo *buf,
- const unsigned int pages)
-{
- const unsigned short height = pages/4;
- const unsigned short width = 4096;
-
- COLOR_BLIT_COPY_BATCH_START(COLOR_BLT_WRITE_ALPHA |
- XY_COLOR_BLT_WRITE_RGB);
- OUT_BATCH((3 << 24) | /* 32 Bit Color */
- (0xF0 << 16) | /* Raster OP copy background register */
- 0); /* Dest pitch is 0 */
- OUT_BATCH(0);
- OUT_BATCH(width << 16 |
- height);
- OUT_RELOC_FENCED(buf, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(rand()); /* random pattern */
- ADVANCE_BATCH();
-}
-
static void render_timeout(int fd)
{
drm_intel_bufmgr *bufmgr;
@@ -91,10 +61,11 @@ static void render_timeout(int fd)
int64_t timeout = ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC;
int64_t negative_timeout = -1;
int ret;
+ const unsigned short height = BUF_PAGES/4;
+ const unsigned short width = 4096;
const bool do_signals = true; /* signals will seem to make the operation
* use less process CPU time */
- bool done = false;
- int i, iter = 1;
+ int iter = 1;
igt_skip_on_simulation();
@@ -112,30 +83,9 @@ static void render_timeout(int fd)
/* Figure out a rough number of fills required to consume 1 second of
* GPU work.
*/
- do {
- struct timespec start, end;
- long diff;
-
-#ifndef CLOCK_MONOTONIC_RAW
-#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
-#endif
-
- igt_assert(clock_gettime(CLOCK_MONOTONIC_RAW, &start) == 0);
- for (i = 0; i < iter; i++)
- blt_color_fill(batch, dst, BUF_PAGES);
- intel_batchbuffer_flush(batch);
- drm_intel_bo_wait_rendering(dst);
- igt_assert(clock_gettime(CLOCK_MONOTONIC_RAW, &end) == 0);
-
- diff = do_time_diff(&end, &start);
- igt_assert(diff >= 0);
-
- if ((diff / MSEC_PER_SEC) > ENOUGH_WORK_IN_SECONDS)
- done = true;
- else
- iter <<= 1;
- } while (!done && iter < 1000000);
-
+ iter = igt_calibrate_dummy_load(bufmgr, batch, fd,
+ dst->handle, 0,
+ width, height, 1, IGT_DUMMY_BLIT_FILL);
igt_assert_lt(iter, 1000000);
igt_debug("%d iters is enough work\n", iter);
@@ -146,10 +96,9 @@ static void render_timeout(int fd)
/* We should be able to do half as much work in the same amount of time,
* but because we might schedule almost twice as much as required, we
* might accidentally time out. Hence add some fudge. */
- for (i = 0; i < iter/3; i++)
- blt_color_fill(batch, dst2, BUF_PAGES);
- intel_batchbuffer_flush(batch);
+ igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0,
+ width, height, iter/3, 0, IGT_DUMMY_BLIT_FILL);
igt_assert(gem_bo_busy(fd, dst2->handle) == true);
igt_assert_eq(gem_wait(fd, dst2->handle, &timeout), 0);
@@ -168,10 +117,9 @@ static void render_timeout(int fd)
/* Now check that we correctly time out, twice the auto-tune load should
* be good enough. */
timeout = ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC;
- for (i = 0; i < iter*2; i++)
- blt_color_fill(batch, dst2, BUF_PAGES);
- intel_batchbuffer_flush(batch);
+ igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0,
+ width, height, iter*2, 0, IGT_DUMMY_BLIT_FILL);
ret = gem_wait(fd, dst2->handle, &timeout);
igt_assert_eq(ret, -ETIME);
@@ -186,10 +134,9 @@ static void render_timeout(int fd)
/* Now check that we can pass negative (infinite) timeouts. */
negative_timeout = -1;
- for (i = 0; i < iter; i++)
- blt_color_fill(batch, dst2, BUF_PAGES);
- intel_batchbuffer_flush(batch);
+ igt_emit_dummy_load(bufmgr, batch, fd, dst2->handle, 0,
+ width, height, iter, 0, IGT_DUMMY_BLIT_FILL);
igt_assert_eq(gem_wait(fd, dst2->handle, &negative_timeout), 0);
igt_assert_eq(negative_timeout, -1); /* infinity always remains */
--
2.7.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-10-12 12:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 11:59 [RFC i-g-t] Extract autotuned dummy load into lib Abdiel Janulgue
2016-10-12 11:59 ` [RFC i-g-t PATCH 1/3] lib: add igt_dummyload Abdiel Janulgue
2016-10-12 11:59 ` Abdiel Janulgue [this message]
2016-10-12 12:07 ` [RFC i-g-t PATCH 2/3] igt/gem_wait: Use new igt_dummyload api Chris Wilson
2016-10-13 9:31 ` Abdiel Janulgue
2016-10-13 9:49 ` Chris Wilson
2016-10-13 15:17 ` Daniel Vetter
2016-10-14 10:17 ` Abdiel Janulgue
2016-10-12 11:59 ` [RFC i-g-t PATCH 3/3] igt/kms_flip: " Abdiel Janulgue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161012115954.16803-3-abdiel.janulgue@linux.intel.com \
--to=abdiel.janulgue@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox