Skip to contentSkip to conversation

gem_fence_upload: Move to benchmarks

PATCH New Tvrtko Ursulin 1 participant 2 messages Jun 8, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gem_fence_upload: Move to benchmarks

From: Tvrtko Ursulin <[email protected]>

This is not a correctness test so move it to benchmarks and off the extended test list.

---
 benchmarks/.gitignore                    | 1 +
 benchmarks/Makefile.am                   | 3 +++
 benchmarks/Makefile.sources              | 1 +
 {tests => benchmarks}/gem_fence_upload.c | 0
 tests/Makefile.am                        | 2 --
 tests/Makefile.sources                   | 1 -
 tests/intel-ci/extended.testlist         | 5 -----
 7 files changed, 5 insertions(+), 8 deletions(-)
 rename {tests => benchmarks}/gem_fence_upload.c (100%)
benchmarks/.gitignore +1 -0
index 56daa1fd33f4..abd76ec9bf91 100644
@@ -7,6 +7,7 @@ gem_exec_fault
 gem_exec_nop
 gem_exec_reloc
 gem_exec_trace
+gem_fence_upload
 gem_latency
 gem_mmap
 gem_prw
benchmarks/Makefile.am +3 -0
index 767731f7d18f..fca023083a6e 100644
@@ -15,6 +15,9 @@ benchmarks_LTLIBRARIES = gem_exec_tracer.la
 gem_exec_tracer_la_LDFLAGS = -module -avoid-version -no-undefined
 gem_exec_tracer_la_LIBADD = -ldl
 
+gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
+gem_fence_upload_LDADD = $(LDADD) -lpthread
+
 gem_latency_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_latency_LDADD = $(LDADD) -lpthread
 gem_syslatency_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
benchmarks/Makefile.sources +1 -0
index d150035aa5db..e87a83876ef4 100644
@@ -9,6 +9,7 @@ benchmarks_prog_list =			\
 	gem_exec_nop			\
 	gem_exec_reloc			\
 	gem_exec_trace			\
+	gem_fence_upload		\
 	gem_latency			\
 	gem_mmap			\
 	gem_prw				\
benchmarks/gem_fence_upload.c renamed from tests/gem_fence_upload.c +0 -0
similarity index 100%
rename from tests/gem_fence_upload.c
rename to benchmarks/gem_fence_upload.c
tests/Makefile.am +0 -2
index 12cc6dc48c12..0596529c0d96 100644
@@ -89,8 +89,6 @@ gem_exec_parallel_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_exec_parallel_LDADD = $(LDADD) -lpthread
 gem_fence_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_fence_thrash_LDADD = $(LDADD) -lpthread
-gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
-gem_fence_upload_LDADD = $(LDADD) -lpthread
 gem_flink_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_flink_race_LDADD = $(LDADD) -lpthread
 gem_mmap_gtt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
tests/Makefile.sources +0 -1
index b3a680e9d75e..3e71582905e2 100644
@@ -63,7 +63,6 @@ TESTS_progs_M = \
 	gem_exec_whisper \
 	gem_fenced_exec_thrash \
 	gem_fence_thrash \
-	gem_fence_upload \
 	gem_flink_basic \
 	gem_flink_race \
 	gem_linear_blits \
tests/intel-ci/extended.testlist +0 -5
index a16c9c8487d6..24ec295faf66 100644
@@ -1446,11 +1446,6 @@ igt@gem_fence_thrash@bo-write-verify-threaded-x
 igt@gem_fence_thrash@bo-write-verify-threaded-y
 igt@gem_fence_thrash@bo-write-verify-x
 igt@gem_fence_thrash@bo-write-verify-y
-igt@gem_fence_upload@performance
-igt@gem_fence_upload@thread-contention
-igt@gem_fence_upload@thread-performance-both
-igt@gem_fence_upload@thread-performance-read
-igt@gem_fence_upload@thread-performance-write
 igt@gem_fenced_exec_thrash@2-spare-fences
 igt@gem_fenced_exec_thrash@no-spare-fences
 igt@gem_fenced_exec_thrash@no-spare-fences-busy
Signature · 6 lines
2.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 igt/gem_fence_upload: Stabilise results

From: Tvrtko Ursulin <[email protected]>

Most of the subtest were failing on my SKL GT2 and on the various CI systems as well. Try to fix that by different tweaks per subtests:

performance:

We cannot say how big the performance drop will be once the fences are contented, just that there will be one, so modify the assert accordingly.

thread-performance-*:

Similar to "performance", but also on some machine the peak performance to compare against seems to be num_cpu dependant which the biggest aggregate throughput with num_cpu clients.

On other machines the results are more stable so this change should not affect those.

Also, on some machines writes are much faster than reads which was making the "-write" subtest a bit unstable. Increased the number of iterations to hopefully stabilise this.

thread-contention:

Same as "performance" - we don't know how big the drop to expect.

wc-contention:

This subtest should not expect a tiled performance drop since CPU WC maps are under test. Change a few things:

1.
Number of iterations was to small causing result instability on some machines.

2.
There seems to be a performance valley with num_threads == num_cpus so do a pre-warm step in those cases which seem to fix it.

3.
Only assert that the final step is slower than the reference, and for the reference take the single thred result which looks to be the fastest.

4.
Check that linear vs tiled results in each step are within 15% tolerance to verify the above attempts to stabilise the test.

---
 benchmarks/gem_fence_upload.c | 51 ++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 18 deletions(-)
benchmarks/gem_fence_upload.c +33 -18
index 7d9acdc0fcb3..d656d4ea70f8 100644
@@ -103,7 +103,7 @@ static void performance(void)
 
 	errno = 0;
 	igt_assert(linear[1] > 0.75 * linear[0]);
-	igt_assert(tiled[1] > 0.75 * tiled[0]);
+	igt_assert(tiled[1] < tiled[0]);
 }
 
 struct thread_performance {
@@ -155,7 +155,8 @@ static const char *direction_string(unsigned mask)
 }
 static void thread_performance(unsigned mask)
 {
-	const int loops = 4096;
+	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+	const int loops = (mask & READ) ? 4096 : 32768;
 	int n, count;
 	int fd, num_fences;
 	double linear[2], tiled[2];
@@ -164,9 +165,11 @@ static void thread_performance(unsigned mask)
 
 	num_fences = gem_available_fences(fd);
 	igt_require(num_fences > 0);
+	igt_require(num_fences > ncpus);
 
 	for (count = 2; count < 4*num_fences; count *= 2) {
 		const int nthreads = (mask & READ ? count : 0) + (mask & WRITE ? count : 0);
+		const int idx = ncpus != count;
 		struct timeval start, end;
 		struct thread_performance readers[count];
 		struct thread_performance writers[count];
@@ -209,8 +212,8 @@ static void thread_performance(unsigned mask)
 		}
 		gettimeofday(&end, NULL);
 
-		linear[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
-		igt_info("%s rate for %d linear surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, linear[count != 2]);
+		linear[idx] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
+		igt_info("%s rate for %d linear surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, linear[idx]);
 
 		for (n = 0; n < count; n++)
 			gem_set_tiling(fd, handle[n], I915_TILING_X, 1024);
@@ -230,8 +233,8 @@ static void thread_performance(unsigned mask)
 		}
 		gettimeofday(&end, NULL);
 
-		tiled[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
-		igt_info("%s rate for %d tiled surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, tiled[count != 2]);
+		tiled[idx] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
+		igt_info("%s rate for %d tiled surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, tiled[idx]);
 
 		for (n = 0; n < count; n++) {
 			munmap(ptr[n], OBJECT_SIZE);
@@ -241,7 +244,7 @@ static void thread_performance(unsigned mask)
 
 	errno = 0;
 	igt_assert(linear[1] > 0.75 * linear[0]);
-	igt_assert(tiled[1] > 0.75 * tiled[0]);
+	igt_assert(tiled[1] < tiled[0]);
 }
 
 struct thread_contention {
@@ -329,13 +332,13 @@ static void thread_contention(void)
 
 	errno = 0;
 	igt_assert(linear[1] > 0.75 * linear[0]);
-	igt_assert(tiled[1] > 0.75 * tiled[0]);
+	igt_assert(tiled[1] < tiled[0]);
 }
 
 static void wc_contention(void)
 {
-	const int loops = 4096;
-	int n, count;
+	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
+	int n, count, order;
 	int fd, num_fences;
 	double linear[2], tiled[2];
 
@@ -344,8 +347,13 @@ static void wc_contention(void)
 
 	num_fences = gem_available_fences(fd);
 	igt_require(num_fences > 0);
+	igt_require(num_fences > ncpus);
 
-	for (count = 1; count < 4*num_fences; count *= 2) {
+	for (count = 1, order = log2(num_fences * 2) + 1;
+	     count < 4 * num_fences;
+	     count *= 2, order--) {
+		const int loops = 4096 * order * 2;
+		const int idx = 1 != count;
 		struct timeval start, end;
 		struct thread_contention threads[count];
 
@@ -355,15 +363,20 @@ static void wc_contention(void)
 			threads[n].fd = fd;
 		}
 
+		if (count <= ncpus / 2) {
+			for (n = 0; n < count; n++)
+				pthread_create(&threads[n].thread, NULL, wc_mmap, &threads[n]);
+			for (n = 0; n < count; n++)
+				pthread_join(threads[n].thread, NULL);
+		}
 		gettimeofday(&start, NULL);
 		for (n = 0; n < count; n++)
 			pthread_create(&threads[n].thread, NULL, wc_mmap, &threads[n]);
 		for (n = 0; n < count; n++)
 			pthread_join(threads[n].thread, NULL);
 		gettimeofday(&end, NULL);
-
-		linear[count != 2] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
-		igt_info("Contended upload rate for %d linear threads/wc:	%7.3fMiB/s\n", count, linear[count != 2]);
+		linear[idx] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
+		igt_info("Contended upload rate for %d linear threads/wc:	%7.3fMiB/s\n", count, linear[idx]);
 
 		for (n = 0; n < count; n++)
 			gem_set_tiling(fd, threads[n].handle, I915_TILING_X, 1024);
@@ -375,17 +388,19 @@ static void wc_contention(void)
 			pthread_join(threads[n].thread, NULL);
 		gettimeofday(&end, NULL);
 
-		tiled[count != 2] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
-		igt_info("Contended upload rate for %d tiled threads/wc:	%7.3fMiB/s\n", count, tiled[count != 2]);
+		tiled[idx] = count * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
+		igt_info("Contended upload rate for %d tiled threads/wc:	%7.3fMiB/s\n", count, tiled[idx]);
 
 		for (n = 0; n < count; n++) {
 			gem_close(fd, threads[n].handle);
 		}
+
+		igt_require(fabs((linear[idx] - tiled[idx]) / linear[idx]) < 0.15);
 	}
 
 	errno = 0;
-	igt_assert(linear[1] > 0.75 * linear[0]);
-	igt_assert(tiled[1] > 0.75 * tiled[0]);
+	igt_assert(linear[1] < linear[0]);
+	igt_assert(tiled[1] < tiled[0]);
 }
 
 igt_main
Signature · 6 lines
2.9.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx