summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-benchmark
diff options
context:
space:
mode:
authorRoy Li <rongqing.li@windriver.com>2016-05-05 09:52:01 +0800
committerMartin Jansa <Martin.Jansa@gmail.com>2016-05-10 20:18:30 +0200
commit4adec181e7303c0afd7fca08fec6ddc5532237a1 (patch)
treea4d004f2a6858974c3496a76001f7e21bf3681e9 /meta-oe/recipes-benchmark
parent35c7a5b63b24ecfa616dacc45c9d0415da1ca5ca (diff)
downloadmeta-openembedded-4adec181e7303c0afd7fca08fec6ddc5532237a1.tar.gz
lmbench: avoid gcc optimize-away multiplication
Change expression used in do_integer_mul and do_uint64_mul benchmarks so GCC doesn't optimize-away the loops, Signed-off-by: Roy Li <rongqing.li@windriver.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-oe/recipes-benchmark')
-rw-r--r--meta-oe/recipes-benchmark/lmbench/lmbench/0001-avoid-gcc-optimize-away-the-loops.patch79
-rw-r--r--meta-oe/recipes-benchmark/lmbench/lmbench_3.0-a9.bb1
2 files changed, 80 insertions, 0 deletions
diff --git a/meta-oe/recipes-benchmark/lmbench/lmbench/0001-avoid-gcc-optimize-away-the-loops.patch b/meta-oe/recipes-benchmark/lmbench/lmbench/0001-avoid-gcc-optimize-away-the-loops.patch
new file mode 100644
index 000000000..2d8a2468a
--- /dev/null
+++ b/meta-oe/recipes-benchmark/lmbench/lmbench/0001-avoid-gcc-optimize-away-the-loops.patch
@@ -0,0 +1,79 @@
1[PATCH] avoid gcc optimize-away the loops
2
3Upstream-Status: pending
4
5Change expression used in do_integer_mul and do_uint64_mul
6benchmarks so GCC doesn't optimize-away the loops, other
7things are same:
8- TEN(r *= s;); r -= t;
9+ i = 0;
10+ while ( i++ < 10)
11+ r *= s;
12+ r -= t;
13
14and TEN is macro:
15 #define TEN(a) a a a a a a a a a a
16
17Signed-off-by: Roy Li <rongqing.li@windriver.com>
18---
19 src/lat_ops.c | 30 +++++++++++++++++++++++++-----
20 1 file changed, 25 insertions(+), 5 deletions(-)
21
22diff --git a/src/lat_ops.c b/src/lat_ops.c
23index d343ff3..457072b 100644
24--- a/src/lat_ops.c
25+++ b/src/lat_ops.c
26@@ -126,11 +126,23 @@ do_integer_mul(iter_t iterations, void* cookie)
27 struct _state *pState = (struct _state*)cookie;
28 register int r = pState->N + 37431;
29 register int s = pState->N + 4;
30- register int t = r * s * s * s * s * s * s * s * s * s * s - r;
31+ register int t = r;
32+ int i = 0;
33+
34+ while ( i++ < 10)
35+ t *= s;
36+ t -= r;
37
38 while (iterations-- > 0) {
39- TEN(r *= s;); r -= t;
40- TEN(r *= s;); r -= t;
41+ i = 0;
42+ while ( i++ < 10)
43+ r *= s;
44+ r -= t;
45+
46+ i = 0;
47+ while ( i++ < 10)
48+ r *= s;
49+ r -= t;
50 }
51 use_int(r);
52 }
53@@ -207,13 +219,21 @@ do_int64_mul(iter_t iterations, void* cookie)
54 register int64 r = (int64)pState->N + 37420;
55 register int64 s = (int64)pState->N + 4;
56 register int64 t;
57+ int i = 0;
58
59 r += (int64)(pState->N + 6)<<32;
60 t = r * s * s * s * s * s * s * s * s * s * s - r;
61
62 while (iterations-- > 0) {
63- TEN(r *= s;); r -= t;
64- TEN(r *= s;); r -= t;
65+ i = 0;
66+ while ( i++ < 10)
67+ r *= s;
68+ r -= t;
69+
70+ i = 0;
71+ while ( i++ < 10)
72+ r *= s;
73+ r -= t;
74 }
75 use_int((int)r);
76 }
77--
782.8.1
79
diff --git a/meta-oe/recipes-benchmark/lmbench/lmbench_3.0-a9.bb b/meta-oe/recipes-benchmark/lmbench/lmbench_3.0-a9.bb
index 5459bf9cb..a62389d09 100644
--- a/meta-oe/recipes-benchmark/lmbench/lmbench_3.0-a9.bb
+++ b/meta-oe/recipes-benchmark/lmbench/lmbench_3.0-a9.bb
@@ -18,6 +18,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/lmbench/lmbench-${PV}.tgz \
18 file://use-base_libdir-instead-of-hardcoded-lib.patch \ 18 file://use-base_libdir-instead-of-hardcoded-lib.patch \
19 file://lmbench_result_html_report.patch \ 19 file://lmbench_result_html_report.patch \
20 file://fix-lmbench-memory-check-failure.patch \ 20 file://fix-lmbench-memory-check-failure.patch \
21 file://0001-avoid-gcc-optimize-away-the-loops.patch \
21" 22"
22SRC_URI[md5sum] = "b3351a3294db66a72e2864a199d37cbf" 23SRC_URI[md5sum] = "b3351a3294db66a72e2864a199d37cbf"
23SRC_URI[sha256sum] = "cbd5777d15f44eab7666dcac418054c3c09df99826961a397d9acf43d8a2a551" 24SRC_URI[sha256sum] = "cbd5777d15f44eab7666dcac418054c3c09df99826961a397d9acf43d8a2a551"