Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: media/base/vector_math_perftest.cc

Issue 308003004: Remove runtime CPU detection for SSE optimized media/ methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more salty fix. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/vector_math.cc ('k') | media/base/vector_math_testing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/cpu.h"
6 #include "base/memory/aligned_memory.h" 5 #include "base/memory/aligned_memory.h"
7 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h" 7 #include "base/time/time.h"
9 #include "media/base/vector_math.h" 8 #include "media/base/vector_math.h"
10 #include "media/base/vector_math_testing.h" 9 #include "media/base/vector_math_testing.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/perf/perf_test.h" 11 #include "testing/perf/perf_test.h"
13 12
14 using base::TimeTicks; 13 using base::TimeTicks;
15 using std::fill; 14 using std::fill;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 true); 72 true);
74 } 73 }
75 74
76 protected: 75 protected:
77 scoped_ptr<float, base::AlignedFreeDeleter> input_vector_; 76 scoped_ptr<float, base::AlignedFreeDeleter> input_vector_;
78 scoped_ptr<float, base::AlignedFreeDeleter> output_vector_; 77 scoped_ptr<float, base::AlignedFreeDeleter> output_vector_;
79 78
80 DISALLOW_COPY_AND_ASSIGN(VectorMathPerfTest); 79 DISALLOW_COPY_AND_ASSIGN(VectorMathPerfTest);
81 }; 80 };
82 81
83 // Define platform independent function name for FMAC* perf tests. 82 // Define platform dependent function names for SIMD optimized methods.
84 #if defined(ARCH_CPU_X86_FAMILY) 83 #if defined(ARCH_CPU_X86_FAMILY)
85 #define FMAC_FUNC FMAC_SSE 84 #define FMAC_FUNC FMAC_SSE
85 #define FMUL_FUNC FMUL_SSE
86 #define EWMAAndMaxPower_FUNC EWMAAndMaxPower_SSE
86 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 87 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
87 #define FMAC_FUNC FMAC_NEON 88 #define FMAC_FUNC FMAC_NEON
89 #define FMUL_FUNC FMUL_NEON
90 #define EWMAAndMaxPower_FUNC EWMAAndMaxPower_NEON
88 #endif 91 #endif
89 92
90 // Benchmark for each optimized vector_math::FMAC() method. 93 // Benchmark for each optimized vector_math::FMAC() method.
91 TEST_F(VectorMathPerfTest, FMAC) { 94 TEST_F(VectorMathPerfTest, FMAC) {
92 // Benchmark FMAC_C(). 95 // Benchmark FMAC_C().
93 RunBenchmark( 96 RunBenchmark(
94 vector_math::FMAC_C, true, "vector_math_fmac", "unoptimized"); 97 vector_math::FMAC_C, true, "vector_math_fmac", "unoptimized");
95 #if defined(FMAC_FUNC) 98 #if defined(FMAC_FUNC)
96 #if defined(ARCH_CPU_X86_FAMILY)
97 ASSERT_TRUE(base::CPU().has_sse());
98 #endif
99 // Benchmark FMAC_FUNC() with unaligned size. 99 // Benchmark FMAC_FUNC() with unaligned size.
100 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment / 100 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment /
101 sizeof(float)), 0U); 101 sizeof(float)), 0U);
102 RunBenchmark( 102 RunBenchmark(
103 vector_math::FMAC_FUNC, false, "vector_math_fmac", "optimized_unaligned"); 103 vector_math::FMAC_FUNC, false, "vector_math_fmac", "optimized_unaligned");
104 // Benchmark FMAC_FUNC() with aligned size. 104 // Benchmark FMAC_FUNC() with aligned size.
105 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)), 105 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)),
106 0U); 106 0U);
107 RunBenchmark( 107 RunBenchmark(
108 vector_math::FMAC_FUNC, true, "vector_math_fmac", "optimized_aligned"); 108 vector_math::FMAC_FUNC, true, "vector_math_fmac", "optimized_aligned");
109 #endif 109 #endif
110 } 110 }
111 111
112 #undef FMAC_FUNC
113
114 // Define platform independent function name for FMULBenchmark* tests.
115 #if defined(ARCH_CPU_X86_FAMILY)
116 #define FMUL_FUNC FMUL_SSE
117 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
118 #define FMUL_FUNC FMUL_NEON
119 #endif
120
121 // Benchmark for each optimized vector_math::FMUL() method. 112 // Benchmark for each optimized vector_math::FMUL() method.
122 TEST_F(VectorMathPerfTest, FMUL) { 113 TEST_F(VectorMathPerfTest, FMUL) {
123 // Benchmark FMUL_C(). 114 // Benchmark FMUL_C().
124 RunBenchmark( 115 RunBenchmark(
125 vector_math::FMUL_C, true, "vector_math_fmul", "unoptimized"); 116 vector_math::FMUL_C, true, "vector_math_fmul", "unoptimized");
126 #if defined(FMUL_FUNC) 117 #if defined(FMUL_FUNC)
127 #if defined(ARCH_CPU_X86_FAMILY)
128 ASSERT_TRUE(base::CPU().has_sse());
129 #endif
130 // Benchmark FMUL_FUNC() with unaligned size. 118 // Benchmark FMUL_FUNC() with unaligned size.
131 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment / 119 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment /
132 sizeof(float)), 0U); 120 sizeof(float)), 0U);
133 RunBenchmark( 121 RunBenchmark(
134 vector_math::FMUL_FUNC, false, "vector_math_fmul", "optimized_unaligned"); 122 vector_math::FMUL_FUNC, false, "vector_math_fmul", "optimized_unaligned");
135 // Benchmark FMUL_FUNC() with aligned size. 123 // Benchmark FMUL_FUNC() with aligned size.
136 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)), 124 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)),
137 0U); 125 0U);
138 RunBenchmark( 126 RunBenchmark(
139 vector_math::FMUL_FUNC, true, "vector_math_fmul", "optimized_aligned"); 127 vector_math::FMUL_FUNC, true, "vector_math_fmul", "optimized_aligned");
140 #endif 128 #endif
141 } 129 }
142 130
143 #undef FMUL_FUNC
144
145 #if defined(ARCH_CPU_X86_FAMILY)
146 #define EWMAAndMaxPower_FUNC EWMAAndMaxPower_SSE
147 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
148 #define EWMAAndMaxPower_FUNC EWMAAndMaxPower_NEON
149 #endif
150
151 // Benchmark for each optimized vector_math::EWMAAndMaxPower() method. 131 // Benchmark for each optimized vector_math::EWMAAndMaxPower() method.
152 TEST_F(VectorMathPerfTest, EWMAAndMaxPower) { 132 TEST_F(VectorMathPerfTest, EWMAAndMaxPower) {
153 // Benchmark EWMAAndMaxPower_C(). 133 // Benchmark EWMAAndMaxPower_C().
154 RunBenchmark(vector_math::EWMAAndMaxPower_C, 134 RunBenchmark(vector_math::EWMAAndMaxPower_C,
155 kVectorSize, 135 kVectorSize,
156 "vector_math_ewma_and_max_power", 136 "vector_math_ewma_and_max_power",
157 "unoptimized"); 137 "unoptimized");
158 #if defined(EWMAAndMaxPower_FUNC) 138 #if defined(EWMAAndMaxPower_FUNC)
159 #if defined(ARCH_CPU_X86_FAMILY)
160 ASSERT_TRUE(base::CPU().has_sse());
161 #endif
162 // Benchmark EWMAAndMaxPower_FUNC() with unaligned size. 139 // Benchmark EWMAAndMaxPower_FUNC() with unaligned size.
163 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment / 140 ASSERT_NE((kVectorSize - 1) % (vector_math::kRequiredAlignment /
164 sizeof(float)), 0U); 141 sizeof(float)), 0U);
165 RunBenchmark(vector_math::EWMAAndMaxPower_FUNC, 142 RunBenchmark(vector_math::EWMAAndMaxPower_FUNC,
166 kVectorSize - 1, 143 kVectorSize - 1,
167 "vector_math_ewma_and_max_power", 144 "vector_math_ewma_and_max_power",
168 "optimized_unaligned"); 145 "optimized_unaligned");
169 // Benchmark EWMAAndMaxPower_FUNC() with aligned size. 146 // Benchmark EWMAAndMaxPower_FUNC() with aligned size.
170 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)), 147 ASSERT_EQ(kVectorSize % (vector_math::kRequiredAlignment / sizeof(float)),
171 0U); 148 0U);
172 RunBenchmark(vector_math::EWMAAndMaxPower_FUNC, 149 RunBenchmark(vector_math::EWMAAndMaxPower_FUNC,
173 kVectorSize, 150 kVectorSize,
174 "vector_math_ewma_and_max_power", 151 "vector_math_ewma_and_max_power",
175 "optimized_aligned"); 152 "optimized_aligned");
176 #endif 153 #endif
177 } 154 }
178 155
179 #undef EWMAAndMaxPower_FUNC
180
181 } // namespace media 156 } // namespace media
OLDNEW
« no previous file with comments | « media/base/vector_math.cc ('k') | media/base/vector_math_testing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698