All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] tests: add gem_fence_upload
@ 2014-02-04 13:28 Chris Wilson
  2014-06-12  7:38 ` [PATCH] tests/gem_fence_upload: Fix test wrapper Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2014-02-04 13:28 UTC (permalink / raw)
  To: intel-gfx

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@chris-wilson.co.uk>
---
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@chris-wilson.co.uk>
+ *
+ */
+
+#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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] tests/gem_fence_upload: Fix test wrapper
  2014-02-04 13:28 [RFC] tests: add gem_fence_upload Chris Wilson
@ 2014-06-12  7:38 ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2014-06-12  7:38 UTC (permalink / raw)
  To: Intel Graphics Development; +Cc: Daniel Vetter

- tests with subtests need to be in the _M target for correct
  enumeration.

- No need for igt_exit when using the igt_(simple_)main wrappers.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 tests/Makefile.sources   | 2 +-
 tests/gem_fence_upload.c | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 520566b3170e..b91b2b49cfa2 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -36,6 +36,7 @@ TESTS_progs_M = \
 	gem_exec_parse \
 	gem_fenced_exec_thrash \
 	gem_fence_thrash \
+	gem_fence_upload \
 	gem_flink \
 	gem_flink_race \
 	gem_linear_blits \
@@ -96,7 +97,6 @@ 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
index 9d8617eae18b..d712df751b0d 100644
--- a/tests/gem_fence_upload.c
+++ b/tests/gem_fence_upload.c
@@ -116,6 +116,4 @@ igt_main
 
 	igt_subtest("performance")
 		performance();
-
-	igt_exit();
 }
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-12  7:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-04 13:28 [RFC] tests: add gem_fence_upload Chris Wilson
2014-06-12  7:38 ` [PATCH] tests/gem_fence_upload: Fix test wrapper Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.