[PATCH i-g-t] Establish relative engine speeds

Anna Karas anna.karas at intel.com
Mon Oct 28 13:10:41 UTC 2019


Log calibrations per engine to test if there are platforms
which need per engine nop calibration. Move gem_nop_speed.c
from /benchmarks to /tests.

Signed-off-by: Anna Karas <anna.karas at intel.com>
---
 benchmarks/Makefile.sources           |   1 -
 benchmarks/gem_nop_speed.c            |  13 +--
 benchmarks/gem_wsim.c                 |   2 +-
 benchmarks/meson.build                |   1 -
 tests/gem_nop_speed.c                 | 122 ++++++++++++++++++++++++++
 tests/intel-ci/fast-feedback.testlist |   1 +
 6 files changed, 131 insertions(+), 9 deletions(-)
 create mode 100644 tests/gem_nop_speed.c

diff --git a/benchmarks/Makefile.sources b/benchmarks/Makefile.sources
index 83171c3d..86928df5 100644
--- a/benchmarks/Makefile.sources
+++ b/benchmarks/Makefile.sources
@@ -11,7 +11,6 @@ benchmarks_prog_list =			\
 	gem_exec_trace			\
 	gem_latency			\
 	gem_mmap			\
-	gem_nop_speed		\
 	gem_prw				\
 	gem_set_domain			\
 	gem_syslatency			\
diff --git a/benchmarks/gem_nop_speed.c b/benchmarks/gem_nop_speed.c
index 19084faa..35889ca0 100644
--- a/benchmarks/gem_nop_speed.c
+++ b/benchmarks/gem_nop_speed.c
@@ -20,8 +20,12 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  * IN THE SOFTWARE.
  *
+ * Authors:
+ *    Anna Karas <anna.karas at intel.com>
+ *
  */
 
+#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -53,11 +57,10 @@
 #include "igt_perf.h"
 #include "sw_sync.h"
 #include "i915/gem_mman.h"
-
-#include "ewma.h"
-
 #include "i915/gem_engine_topology.h"
 
+IGT_TEST_DESCRIPTION("Tests nop speed on various platforms.");
+
 static double elapsed(const struct timespec *start, const struct timespec *end)
 {
 	return (end->tv_sec - start->tv_sec) +
@@ -107,7 +110,7 @@ static unsigned long calibrate_nop(int fd, struct intel_execution_engine2 *engin
 	return size / sizeof(uint32_t);
 }
 
-int main(int argc, char **argv)
+igt_simple_main
 {
 	struct intel_execution_engine2 *engine;
 	int fd = __drm_open_driver(DRIVER_INTEL);
@@ -117,6 +120,4 @@ int main(int argc, char **argv)
 		unsigned long nop_calibration = calibrate_nop(fd, engine);
 		printf("%s: %lu\n", engine->name, nop_calibration);
 	}
-
-	return 0;
 }
\ No newline at end of file
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index 87f873b0..4a3163da 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -2903,7 +2903,7 @@ static unsigned long calibrate_nop(unsigned int tolerance_pct)
 {
 	const uint32_t bbe = 0xa << 23;
 	unsigned int loops = 17;
-	unsigned int usecs = nop_calibration_us;
+	unsigned int usecs = nop_calibration_us; // == 1000
 	struct drm_i915_gem_exec_object2 obj = {};
 	struct drm_i915_gem_execbuffer2 eb =
 		{ .buffer_count = 1, .buffers_ptr = (uintptr_t)&obj};
diff --git a/benchmarks/meson.build b/benchmarks/meson.build
index fb602bee..397f3b8d 100644
--- a/benchmarks/meson.build
+++ b/benchmarks/meson.build
@@ -9,7 +9,6 @@ benchmark_progs = [
 	'gem_exec_trace',
 	'gem_latency',
 	'gem_mmap',
-	'gem_nop_speed',
 	'gem_prw',
 	'gem_set_domain',
 	'gem_syslatency',
diff --git a/tests/gem_nop_speed.c b/tests/gem_nop_speed.c
new file mode 100644
index 00000000..19084faa
--- /dev/null
+++ b/tests/gem_nop_speed.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2019 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.
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <poll.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <assert.h>
+#include <limits.h>
+#include <pthread.h>
+
+#include "intel_chipset.h"
+#include "intel_reg.h"
+#include "drm.h"
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+
+#include "intel_io.h"
+#include "igt_aux.h"
+#include "igt_rand.h"
+#include "igt_perf.h"
+#include "sw_sync.h"
+#include "i915/gem_mman.h"
+
+#include "ewma.h"
+
+#include "i915/gem_engine_topology.h"
+
+static double elapsed(const struct timespec *start, const struct timespec *end)
+{
+	return (end->tv_sec - start->tv_sec) +
+	       (end->tv_nsec - start->tv_nsec) / 1e9;
+}
+
+static unsigned long calibrate_nop(int fd, struct intel_execution_engine2 *engine) 
+{
+	const uint32_t bbe = 0xa << 23;
+	unsigned int steps = 17;
+	unsigned int usecs = 1000;
+	struct drm_i915_gem_exec_object2 obj = {};
+	struct drm_i915_gem_execbuffer2 eb = { 
+		.buffer_count = 1, 
+		.buffers_ptr = (uintptr_t)&obj, 
+		.flags = engine->flags
+	};
+	long size, last_size;
+	struct timespec t_0, t_end;
+
+	clock_gettime(CLOCK_MONOTONIC, &t_0);
+
+	size = 256 * 1024;
+	do {
+		struct timespec t_start;
+
+		obj.handle = gem_create(fd, size);
+		gem_write(fd, obj.handle, size - sizeof(bbe), &bbe,
+			  sizeof(bbe));
+		gem_execbuf(fd, &eb);
+		gem_sync(fd, obj.handle);
+
+		clock_gettime(CLOCK_MONOTONIC, &t_start);
+		for (int i = 0; i < steps; i++)
+			gem_execbuf(fd, &eb);
+		gem_sync(fd, obj.handle);
+		clock_gettime(CLOCK_MONOTONIC, &t_end);
+
+		gem_close(fd, obj.handle);
+
+		last_size = size;
+		size = steps * size / elapsed(&t_start, &t_end) / 1e6 * usecs;
+		size = ALIGN(size, sizeof(uint32_t));
+	} while (elapsed(&t_0, &t_end) < 5 ||
+		 labs(size - last_size) > (size / 100));
+
+	return size / sizeof(uint32_t);
+}
+
+int main(int argc, char **argv)
+{
+	struct intel_execution_engine2 *engine;
+	int fd = __drm_open_driver(DRIVER_INTEL);
+	igt_require(fd);
+
+	__for_each_physical_engine(fd, engine) {
+		unsigned long nop_calibration = calibrate_nop(fd, engine);
+		printf("%s: %lu\n", engine->name, nop_calibration);
+	}
+
+	return 0;
+}
\ No newline at end of file
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index e78e7fd0..51e99102 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -85,6 +85,7 @@ igt at gem_mmap_gtt@basic-write-gtt-no-prefault
 igt at gem_mmap_gtt@basic-write-no-prefault
 igt at gem_mmap_gtt@basic-write-read
 igt at gem_mmap_gtt@basic-write-read-distinct
+igt at gem_nop_speed
 igt at gem_render_linear_blits@basic
 igt at gem_render_tiled_blits@basic
 igt at gem_ringfill@basic-default
-- 
2.19.0



More information about the Intel-gfx-trybot mailing list