summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-08-01 12:58:13 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-08-01 13:04:29 +0100
commit12f052b5604fffb852bf66250b89fec56641733c (patch)
tree2d0e716994c0c8ca7a409d835140c3462c05557c
parent29eac70683fb15188c595e6e7e7fdb4085a7eb06 (diff)
igt/gem_mmap_gtt/wc: Reduce test runtime
Add a new iterator macro to run for a specified number of milliseconds. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/igt_aux.h13
-rw-r--r--tests/gem_mmap_gtt.c16
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 5627cb04..7f5a7cfd 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -85,6 +85,19 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt);
#define igt_until_timeout(timeout) \
for (struct timespec t__={}; igt_seconds_elapsed(&t__) < (timeout); )
+/**
+ * igt_for_milliseconds:
+ * @time: how long to run the loop in milliseconds
+ *
+ * Convenience macro loop to run the provided code block in a loop until the
+ * target interval has expired. Of course when an individual execution takes
+ * too long, the actual execution time could be a lot longer.
+ *
+ * The code block will be executed at least once.
+ */
+#define igt_for_milliseconds(t) \
+ for (struct timespec t__={}; igt_nsec_elapsed(&t__)>>20 < (t); )
+
void igt_exchange_int(void *array, unsigned i, unsigned j);
void igt_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index ef41bcc0..60034df3 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -248,26 +248,26 @@ test_wc(int fd)
gem_close(fd, handle);
gtt_reads = 0;
- igt_until_timeout(1) {
+ igt_for_milliseconds(200) {
memcpy(cpu, gtt, 4096);
gtt_reads++;
}
- igt_debug("%lu GTT reads in 1s\n", gtt_reads);
+ igt_debug("%lu GTT reads in 200us\n", gtt_reads);
gtt_writes = 0;
- igt_until_timeout(1) {
+ igt_for_milliseconds(200) {
memcpy(gtt, cpu, 4096);
gtt_writes++;
}
- igt_debug("%lu GTT writes in 1s\n", gtt_writes);
+ igt_debug("%lu GTT writes in 200us\n", gtt_writes);
if (igt_setup_clflush()) {
cpu_writes = 0;
- igt_until_timeout(1) {
+ igt_for_milliseconds(200) {
igt_clflush_range(cpu, 4096);
cpu_writes++;
}
- igt_debug("%lu CPU writes in 1s\n", cpu_writes);
+ igt_debug("%lu CPU writes in 200us\n", cpu_writes);
} else
cpu_writes = gtt_writes;
@@ -276,11 +276,11 @@ test_wc(int fd)
igt_assert_f(gtt_writes > 2*gtt_reads,
"Write-Combined writes are expected to be much faster than reads: read=%.2fMiB/s, write=%.2fMiB/s\n",
- gtt_reads/256., gtt_writes/256.);
+ 5*gtt_reads/256., 5*gtt_writes/256.);
igt_assert_f(gtt_writes > cpu_writes/2,
"Write-Combined writes are expected to be roughly equivalent to WB writes: WC (gtt)=%.2fMiB/s, WB (cpu)=%.2fMiB/s\n",
- gtt_writes/256., cpu_writes/256.);
+ 5*gtt_writes/256., 5*cpu_writes/256.);
}
static void