From 7b4e1073226e07d279d6f28883f8aa4b27ade183 Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Fri, 3 Jun 2011 19:16:56 +0000 Subject:
Rietveld Code Review Tool
tomhudson@google.com (TomH) | Settings | Help | Bug tracker | Discussion group | Source code | Sign out
(691)

Issue 4571045: New matrix benchmarks to evaluate ::setConcat implementation options

Created:
16 minutes ago by me
Modified:
0 minutes ago
Reviewers:
reed1
CC:
Base URL:
http://skia.googlecode.com/svn/trunk/
Visibility:
Public.

Description

On platforms that use Float (instead of Fixed), SkMatrix stores its internal
																																																																																																																																																																															values as floats, but setConcat() needs extra precision and so uses doubles to
																																																																																																																																																																															contain intermediate values.
																																																																																																																																																																															These three benchmarks compare the speed of float-only, double-only, and
																																																																																																																																																																															float-cast-to-double implementations of a chunk of code extracted from the
																																																																																																																																																																															non-perspective case of setConcat().
																																																																																																																																																																															

Patch Set 1

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
M bench/MatrixBench.cpp View 4 chunks +114 lines, -3 lines 0 comments Download

Messages

Total messages: 3
me
13 minutes ago
reed1
1. lets remove the "fix" from the function name. just muladdmul I think 2. we ...
10 minutes ago
me
0 minutes ago
> 4. what are the results like?

																																																																																																																																																																																																																																																																																																																																																																																																																															       For posterity:

																																																																																																																																																																																																																																																																																																																																																																																																																															       tomhudson@tomhudson-zx600-linux:/usr/local/google/src/skia3$ out/bench/bench
																																																																																																																																																																																																																																																																																																																																																																																																																															       -match matrix_concat -repeat 1000
																																																																																																																																																																																																																																																																																																																																																																																																																															       skia bench: alpha=0xFF antialias=1 filter=0
																																																																																																																																																																																																																																																																																																																																																																																																																															       running bench [640 480]         matrix_concat_double  8888: msecs =  0.79   565:
																																																																																																																																																																																																																																																																																																																																																																																																																															       msecs =  0.79   GPU: msecs =  0.79
																																																																																																																																																																																																																																																																																																																																																																																																																															       running bench [640 480]    matrix_concat_floatdouble  8888: msecs =  0.97   565:
																																																																																																																																																																																																																																																																																																																																																																																																																															       msecs =  0.97   GPU: msecs =  0.97
																																																																																																																																																																																																																																																																																																																																																																																																																															       running bench [640 480]          matrix_concat_float  8888: msecs =  0.74   565:
																																																																																																																																																																																																																																																																																																																																																																																																																															       msecs =  0.73   GPU: msecs =  0.74

Powered by Google App Engine
RSS Feeds Recent Issues | My Issues | My Reviews | My Closed | This issue
This is Rietveld r756
On platforms that use Float (instead of Fixed), SkMatrix stores its internal values as floats, but setConcat() needs extra precision and so uses doubles to contain intermediate values. These three benchmarks compare the speed of float-only, double-only, and float-cast-to-double implementations of a chunk of code extracted from the non-perspective case of setConcat(). git-svn-id: http://skia.googlecode.com/svn/trunk@1497 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/MatrixBench.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 3 deletions(-) (limited to 'bench/MatrixBench.cpp') diff --git a/bench/MatrixBench.cpp b/bench/MatrixBench.cpp index 1c99ab433e..72dfe8b7a7 100644 --- a/bench/MatrixBench.cpp +++ b/bench/MatrixBench.cpp @@ -1,5 +1,6 @@ #include "SkBenchmark.h" #include "SkMatrix.h" +#include "SkRandom.h" #include "SkString.h" class MatrixBench : public SkBenchmark { @@ -45,7 +46,7 @@ public: protected: virtual void performTest() { SkMatrix m0, m1, m2; - + m0.reset(); m1.reset(); m2.reset(); @@ -63,7 +64,7 @@ private: class ScaleMatrixBench : public MatrixBench { public: ScaleMatrixBench(void* param) : INHERITED(param, "scale") { - + fM0.reset(); fM1.setScale(fSX, fSY); fM2.setTranslate(fSX, fSY); @@ -82,9 +83,116 @@ private: typedef MatrixBench INHERITED; }; +// Test the performance of setConcat() non-perspective case: +// using floating point precision only. +class FloatConcatMatrixBench : public MatrixBench { +public: + FloatConcatMatrixBench(void* param) + : INHERITED(param, "concat_float") { + } +protected: + static inline void muladdmul(float a, float b, float c, float d, + float* result) { + *result = a * b + c * d; + } + virtual void performTest() { + float a[9]; + float b[9]; + float r[9]; + a[0] = rnd.nextS(); + a[3] = rnd.nextS(); + muladdmul(a[0], b[0], a[1], b[3], &r[0]); + muladdmul(a[0], b[1], a[1], b[4], &r[1]); + muladdmul(a[0], b[2], a[1], b[5], &r[2]); + muladdmul(a[3], b[0], a[4], b[3], &r[3]); + muladdmul(a[3], b[1], a[4], b[4], &r[4]); + muladdmul(a[3], b[2], a[4], b[5], &r[5]); + always_do(r[0] + r[1] + r[2] + r[3] + r[4] + r[5] + + r[6] + r[7] + r[8] > 0.0f); + } +private: + SkRandom rnd; + typedef MatrixBench INHERITED; +}; + +static inline float SkDoubleToFloat(double x) { + return static_cast(x); +} + +// Test the performance of setConcat() non-perspective case: +// using floating point precision but casting up to float for +// intermediate results during computations. +class FloatDoubleConcatMatrixBench : public MatrixBench { +public: + FloatDoubleConcatMatrixBench(void* param) + : INHERITED(param, "concat_floatdouble") { + } +protected: + static inline void muladdmul(float a, float b, float c, float d, + float* result) { + *result = SkDoubleToFloat((double)a * b + (double)c * d); + } + virtual void performTest() { + float a[9]; + float b[9]; + float r[9]; + a[0] = rnd.nextS(); + a[3] = rnd.nextS(); + muladdmul(a[0], b[0], a[1], b[3], &r[0]); + muladdmul(a[0], b[1], a[1], b[4], &r[1]); + muladdmul(a[0], b[2], a[1], b[5], &r[2]); + muladdmul(a[3], b[0], a[4], b[3], &r[3]); + muladdmul(a[3], b[1], a[4], b[4], &r[4]); + muladdmul(a[3], b[2], a[4], b[5], &r[5]); + always_do(r[0] + r[1] + r[2] + r[3] + r[4] + r[5] + + r[6] + r[7] + r[8] > 0.0f); + } +private: + SkRandom rnd; + typedef MatrixBench INHERITED; +}; + +// Test the performance of setConcat() non-perspective case: +// using double precision only. +class DoubleConcatMatrixBench : public MatrixBench { +public: + DoubleConcatMatrixBench(void* param) + : INHERITED(param, "concat_double") { + } +protected: + static inline void muladdmul(double a, double b, double c, double d, + double* result) { + *result = a * b + c * d; + } + virtual void performTest() { + double a[9]; + double b[9]; + double r[9]; + a[0] = rnd.nextS(); + a[3] = rnd.nextS(); + muladdmul(a[0], b[0], a[1], b[3], &r[0]); + muladdmul(a[0], b[1], a[1], b[4], &r[1]); + muladdmul(a[0], b[2], a[1], b[5], &r[2]); + muladdmul(a[3], b[0], a[4], b[3], &r[3]); + muladdmul(a[3], b[1], a[4], b[4], &r[4]); + muladdmul(a[3], b[2], a[4], b[5], &r[5]); + always_do(r[0] + r[1] + r[2] + r[3] + r[4] + r[5] + + r[6] + r[7] + r[8] > 0.0f); + } +private: + SkRandom rnd; + typedef MatrixBench INHERITED; +}; + + static SkBenchmark* M0(void* p) { return new EqualsMatrixBench(p); } static SkBenchmark* M1(void* p) { return new ScaleMatrixBench(p); } +static SkBenchmark* M2(void* p) { return new FloatConcatMatrixBench(p); } +static SkBenchmark* M3(void* p) { return new FloatDoubleConcatMatrixBench(p); } +static SkBenchmark* M4(void* p) { return new DoubleConcatMatrixBench(p); } static BenchRegistry gReg0(M0); static BenchRegistry gReg1(M1); - +static BenchRegistry gReg2(M2); +static BenchRegistry gReg3(M3); +static BenchRegistry gReg4(M4); -- cgit v1.2.3