[RFC] tests: add gem_fence_upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test demonstrates the performance cliff clients face when they
unwittingly use too many fenced surfaces in a looped upload.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
Note that pass/fail here is based on arbitrary value, and passing the test
is a wishlist item. Is it worthwhile pushing as is, or should distinguish
it a bit more?
---
 tests/Makefile.sources   |   1 +
 tests/gem_fence_upload.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)
 create mode 100644 tests/gem_fence_upload.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index a8c0c96..459c7c9 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -86,6 +86,7 @@ TESTS_progs = \
 	gem_exec_blt \
 	gem_exec_lut_handle \
 	gem_fd_exhaustion \
+	gem_fence_upload \
 	gem_gtt_cpu_tlb \
 	gem_gtt_hog \
 	gem_gtt_speed \
diff --git a/tests/gem_fence_upload.c b/tests/gem_fence_upload.c
new file mode 100644
index 0000000..e306cdf
--- /dev/null
+++ b/tests/gem_fence_upload.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+
+#define OBJECT_SIZE (1024*1024) /* restricted to 1MiB alignment on i915 fences */
+
+static double elapsed(const struct timeval *start,
+		      const struct timeval *end)
+{
+	return (end->tv_sec - start->tv_sec) + 1e-6*(end->tv_usec - start->tv_usec);
+}
+
+static void performance(void)
+{
+	int n, loop, count;
+	int fd, num_fences;
+	double linear[2], tiled[2];
+
+	fd = drm_open_any();
+
+	num_fences = gem_available_fences(fd);
+	assert (num_fences > 0);
+
+	for (count = 2; count < 4*num_fences; count *= 2) {
+		struct timeval start, end;
+		uint32_t handle[count];
+		void *ptr[count];
+
+		for (n = 0; n < count; n++) {
+			handle[n] = gem_create(fd, OBJECT_SIZE);
+			ptr[n] = gem_mmap(fd, handle[n], OBJECT_SIZE, PROT_READ | PROT_WRITE);
+			igt_assert(ptr[n]);
+		}
+
+		gettimeofday(&start, NULL);
+		for (loop = 0; loop < 1024; loop++) {
+			for (n = 0; n < count; n++)
+				memset(ptr[n], 0, OBJECT_SIZE);
+		}
+		gettimeofday(&end, NULL);
+
+		linear[count != 2] = count * loop / elapsed(&start, &end);
+		printf("Upload rate for %d linear surfaces:	%7.3fMiB/s\n",
+		       count, linear[count != 2]);
+
+		for (n = 0; n < count; n++)
+			gem_set_tiling(fd, handle[n], I915_TILING_X, 1024);
+
+		gettimeofday(&start, NULL);
+		for (loop = 0; loop < 1024; loop++) {
+			for (n = 0; n < count; n++)
+				memset(ptr[n], 0, OBJECT_SIZE);
+		}
+		gettimeofday(&end, NULL);
+
+		tiled[count != 2] = count * loop / elapsed(&start, &end);
+		printf("Upload rate for %d tiled surfaces:	%7.3fMiB/s\n",
+		       count, tiled[count != 2]);
+
+		for (n = 0; n < count; n++) {
+			munmap(ptr[n], OBJECT_SIZE);
+			gem_close(fd, handle[n]);
+		}
+
+	}
+
+	errno = 0;
+	igt_assert(linear[1] > 0.75 * linear[0]);
+	igt_assert(tiled[1] > 0.75 * tiled[0]);
+}
+
+igt_main
+{
+	igt_skip_on_simulation();
+
+	igt_subtest("performance")
+		performance();
+
+	igt_exit();
+}
-- 
1.9.rc1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux