[Intel-gfx] [PATCH igt] igt/gem_exec_nop: Remove nop latency measurements

Chris Wilson chris at chris-wilson.co.uk
Fri Dec 4 02:21:26 PST 2015


Since commit c8beadb811bdc2b9c21f95144852f3e55867b546
Author: Derek Morton <derek.j.morton at intel.com>
Date:   Wed Nov 11 14:46:58 2015 +0000

    tests/gem_exec_nop: Improved test run time

the stablity of the measurement regressed and it is once again no longer
a reliable metric for detecting regressions. Give up.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Derek Morton <derek.j.morton at intel.com>
---
 benchmarks/gem_exec_nop.c |   1 +
 tests/gem_exec_nop.c      | 170 ++++------------------------------------------
 2 files changed, 15 insertions(+), 156 deletions(-)

diff --git a/benchmarks/gem_exec_nop.c b/benchmarks/gem_exec_nop.c
index c22e1da..ce845d5 100644
--- a/benchmarks/gem_exec_nop.c
+++ b/benchmarks/gem_exec_nop.c
@@ -102,6 +102,7 @@ static int loop(unsigned ring, int reps)
 		for (n = 0; n < reps; n++) {
 			struct timespec start, end;
 			int loops = count;
+			gem_set_domain(fd, gem_exec.handle, I915_GEM_DOMAIN_GTT, 0);
 			sleep(1); /* wait for the hw to go back to sleep */
 			clock_gettime(CLOCK_MONOTONIC, &start);
 			while (loops--)
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index cf69696..985b33f 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -48,64 +48,6 @@
 const uint32_t batch[2] = {MI_BATCH_BUFFER_END};
 int device;
 
-static int sysfs_read(const char *name)
-{
-	char buf[4096];
-	struct stat st;
-	int sysfd;
-	int len;
-
-	if (fstat(device, &st))
-		return -1;
-
-	sprintf(buf, "/sys/class/drm/card%d/%s",
-		(int)(st.st_rdev & 0x7f), name);
-	sysfd = open(buf, O_RDONLY);
-	if (sysfd < 0)
-		return -1;
-
-	len = read(sysfd, buf, sizeof(buf)-1);
-	close(sysfd);
-	if (len < 0)
-		return -1;
-
-	buf[len] = '\0';
-	return atoi(buf);
-}
-
-static int sysfs_write(const char *name, int value)
-{
-	char buf[4096];
-	struct stat st;
-	int sysfd;
-	int len;
-
-	if (fstat(device, &st))
-		return -1;
-
-	sprintf(buf, "/sys/class/drm/card%d/%s",
-		(int)(st.st_rdev & 0x7f), name);
-	sysfd = open(buf, O_WRONLY);
-	if (sysfd < 0)
-		return -1;
-
-	len = sprintf(buf, "%d", value);
-	len = write(sysfd, buf, len);
-	close(sysfd);
-
-	if (len < 0)
-		return len;
-
-	return 0;
-}
-
-static uint64_t elapsed(const struct timespec *start,
-		const struct timespec *end,
-		int loop)
-{
-	return (1000000000ULL*(end->tv_sec - start->tv_sec) + (end->tv_nsec - start->tv_nsec))/loop;
-}
-
 static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_name)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
@@ -113,9 +55,6 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
 	int count;
 
 	gem_require_ring(fd, ring_id);
-	igt_debug("RPS frequency range [%d, %d]\n",
-		  sysfs_read("gt_min_freq_mhz"),
-		  sysfs_read("gt_max_freq_mhz"));
 
 	memset(&gem_exec, 0, sizeof(gem_exec));
 	gem_exec[0].handle = handle;
@@ -132,120 +71,39 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
 	}
 	gem_sync(fd, handle);
 
-	for (count = 1; count <= SLOW_QUICK(1<<17, 1<<4); count <<= 1) {
-		const int reps = 7;
-		igt_stats_t stats;
-		int n;
-
-		igt_stats_init_with_size(&stats, reps);
-
-		for (n = 0; n < reps; n++) {
-			struct timespec start, end;
-			int loops = count;
-			usleep(200000); /* wait 200ms for the hw to go back to sleep */
-			clock_gettime(CLOCK_MONOTONIC, &start);
-			while (loops--)
-				do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
-			gem_sync(fd, handle);
-			clock_gettime(CLOCK_MONOTONIC, &end);
-			igt_stats_push(&stats, elapsed(&start, &end, count));
-		}
-
-		igt_info("Time to exec x %d:		%7.3fµs (ring=%s)\n",
-			 count, igt_stats_get_trimean(&stats)/1000, ring_name);
-		fflush(stdout);
-
-		igt_stats_fini(&stats);
+	for (count = 1; count <= 1<<17; count <<= 1) {
+		int loops = count;
+		gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0);
+		while (loops--)
+			do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+		gem_sync(fd, handle);
 	}
 }
 
-static void set_auto_freq(void)
-{
-	int min = sysfs_read("gt_RPn_freq_mhz");
-	int max = sysfs_read("gt_RP0_freq_mhz");
-	if (max <= min)
-		return;
-
-	igt_debug("Setting min to %dMHz, and max to %dMHz\n", min, max);
-	sysfs_write("gt_min_freq_mhz", min);
-	sysfs_write("gt_max_freq_mhz", max);
-}
-
-static void set_min_freq(void)
-{
-	int min = sysfs_read("gt_RPn_freq_mhz");
-	igt_require(min > 0);
-	igt_debug("Setting min/max to %dMHz\n", min);
-	(void)sysfs_write("gt_idle_freq_mhz", min);
-	(void)sysfs_write("gt_boost_freq_mhz", min);
-	igt_require(sysfs_write("gt_min_freq_mhz", min) == 0 &&
-		    sysfs_write("gt_max_freq_mhz", min) == 0);
-}
-
-static void set_max_freq(void)
-{
-	int max = sysfs_read("gt_RP0_freq_mhz");
-	igt_require(max > 0);
-	igt_debug("Setting min/max to %dMHz\n", max);
-	(void)sysfs_write("gt_idle_freq_mhz", max);
-	(void)sysfs_write("gt_boost_freq_mhz", max);
-	igt_require(sysfs_write("gt_max_freq_mhz", max) == 0 &&
-		    sysfs_write("gt_min_freq_mhz", max) == 0);
-}
-
 igt_main
 {
-	const struct {
-		const char *suffix;
-		void (*func)(void);
-	} rps[] = {
-		{ "", set_auto_freq },
-		{ "-min", set_min_freq },
-		{ "-max", set_max_freq },
-		{ NULL, NULL },
-	}, *r;
-	int min = -1, max = -1, boost = -1, idle = -1;
 	uint32_t handle = 0;
 
 	igt_fixture {
 		device = drm_open_driver(DRIVER_INTEL);
-
-		min = sysfs_read("gt_min_freq_mhz");
-		max = sysfs_read("gt_max_freq_mhz");
-		boost = sysfs_read("gt_boost_freq_mhz");
-		idle = sysfs_read("gt_idle_freq_mhz");
-
 		handle = gem_create(device, 4096);
 		gem_write(device, handle, 0, batch, sizeof(batch));
 	}
 
-	for (r = rps; r->suffix; r++) {
-		igt_fixture r->func();
+	igt_subtest("render")
+		loop(device, handle, I915_EXEC_RENDER, "render");
 
-		igt_subtest_f("render%s", r->suffix)
-			loop(device, handle, I915_EXEC_RENDER, "render");
+	igt_subtest("bsd")
+		loop(device, handle, I915_EXEC_BSD, "bsd");
 
-		igt_subtest_f("bsd%s", r->suffix)
-			loop(device, handle, I915_EXEC_BSD, "bsd");
+	igt_subtest("blt")
+		loop(device, handle, I915_EXEC_BLT, "blt");
 
-		igt_subtest_f("blt%s", r->suffix)
-			loop(device, handle, I915_EXEC_BLT, "blt");
-
-		igt_subtest_f("vebox%s", r->suffix)
-			loop(device, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
-	}
+	igt_subtest("vebox")
+		loop(device, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
 
 	igt_fixture {
 		gem_close(device, handle);
-
-		if (min > 0)
-			sysfs_write("gt_min_freq_mhz", min);
-		if (max > 0)
-			sysfs_write("gt_max_freq_mhz", max);
-		if (boost > 0)
-			sysfs_write("gt_boost_freq_mhz", boost);
-		if (idle > 0)
-			sysfs_write("gt_idle_freq_mhz", idle);
 		close(device);
 	}
 }
-- 
2.6.2



More information about the Intel-gfx mailing list