[igt-dev] [PATCH i-g-t 6/6] benchmarks/gtt_speed: Add a subtest to compare post suspend speed
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Mon Feb 5 09:35:25 UTC 2018
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
benchmarks/gem_gtt_speed.c | 107 +++++++++++++++++++++++++++++----------------
1 file changed, 70 insertions(+), 37 deletions(-)
diff --git a/benchmarks/gem_gtt_speed.c b/benchmarks/gem_gtt_speed.c
index 3d726c4..ff42ab3 100644
--- a/benchmarks/gem_gtt_speed.c
+++ b/benchmarks/gem_gtt_speed.c
@@ -42,6 +42,7 @@
#include "drm.h"
#define OBJECT_SIZE 16384
+int size = OBJECT_SIZE;
static double elapsed(const struct timeval *start,
const struct timeval *end,
@@ -86,39 +87,13 @@ static void streaming_load(void *src, int len)
}
#endif
-int main(int argc, char **argv)
+static void run_test(int fd, uint32_t handle, unsigned cpu,
+ uint8_t *buf)
{
struct timeval start, end;
- uint8_t *buf;
- uint32_t handle;
- unsigned cpu = x86_64_features();
- int size = OBJECT_SIZE;
- int loop, i, tiling;
- int fd;
-
- igt_simple_init(argc, argv);
-
- igt_skip_on_simulation();
-
- if (argc > 1)
- size = atoi(argv[1]);
- if (size == 0) {
- igt_warn("Invalid object size specified\n");
- return 1;
- }
-
- if (cpu) {
- char str[1024];
- igt_info("Detected cpu faatures: %s\n",
- igt_x86_features_to_string(cpu, str));
- }
+ int i, tiling, loop;
- buf = malloc(size);
memset(buf, 0, size);
- fd = drm_open_driver(DRIVER_INTEL);
-
- handle = gem_create(fd, size);
- igt_assert(handle);
for (tiling = I915_TILING_NONE; tiling <= I915_TILING_Y; tiling++) {
if (tiling != I915_TILING_NONE) {
@@ -294,7 +269,7 @@ int main(int argc, char **argv)
}
gettimeofday(&end, NULL);
igt_info("Time to read %dk through a WC map: %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
{
uint32_t *base = gem_mmap__wc(fd, handle, 0, size, PROT_READ | PROT_WRITE);
@@ -372,7 +347,7 @@ int main(int argc, char **argv)
}
gettimeofday(&end, NULL);
igt_info("Time to write %dk through a WC map: %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
}
/* mmap clear */
@@ -396,7 +371,7 @@ int main(int argc, char **argv)
}
gettimeofday(&end, NULL);
igt_info("Time to clear %dk through a WC map: %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
}
gettimeofday(&start, NULL);{
@@ -416,7 +391,7 @@ int main(int argc, char **argv)
munmap(base, size);
} gettimeofday(&end, NULL);
igt_info("Time to clear %dk through a cached WC map: %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
}
/* mmap read */
@@ -487,7 +462,7 @@ int main(int argc, char **argv)
}
gettimeofday(&end, NULL);
igt_info("Time to pwrite %dk through the GTT (clflush): %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
/* partial GTT pread, including clflush */
gettimeofday(&start, NULL);
@@ -497,14 +472,72 @@ int main(int argc, char **argv)
}
gettimeofday(&end, NULL);
igt_info("Time to pread %dk through the GTT (clflush): %7.3fµs\n",
- size/1024, elapsed(&start, &end, loop));
+ size/1024, elapsed(&start, &end, loop));
size *= 4;
}
}
+}
+
+static int opt_handler(int option, int option_index, void *input)
+{
+ switch (option) {
+ case 's':
+ size = strtol(optarg, NULL, 0);
+ igt_fail_on_f(size == 0,
+ "Invalid object size specified\n");
+ break;
+ }
+
+ return 0;
+}
+int main(int argc, char **argv)
+{
+ uint8_t *buf;
+ uint32_t handle;
+ unsigned cpu = x86_64_features();
+ int fd;
+ struct option long_options[] = {
+ { "size", required_argument, NULL, 's'},
+ { 0, 0, 0, 0 }
+ };
+
+ const char *help_str =
+ " --size\tObject size\n";
+
+ igt_subtest_init_parse_opts(&argc, argv, "", long_options, help_str,
+ opt_handler, NULL);
+
+ igt_skip_on_simulation();
+
+ if (cpu) {
+ char str[1024];
+ igt_info("Detected cpu faatures: %s\n",
+ igt_x86_features_to_string(cpu, str));
+ }
- gem_close(fd, handle);
- close(fd);
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_INTEL);
+ handle = gem_create(fd, size);
+ igt_assert(handle);
+ buf = malloc(size);
+ igt_assert(buf);
+ }
+
+ igt_subtest("basic")
+ run_test(fd, handle, cpu, buf);
+
+ igt_subtest("post-suspend") {
+ igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
+ SUSPEND_TEST_NONE);
+ run_test(fd, handle, cpu, buf);
+ }
+
+ igt_fixture {
+ gem_close(fd, handle);
+ close(fd);
+ free(buf);
+ }
igt_exit();
}
--
2.7.4
More information about the igt-dev
mailing list