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

Unified Diff: media/base/sinc_resampler_unittest.cc

Issue 10960023: Add ARM NEON intrinsic optimizations for SincResampler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/base/sinc_resampler_unittest.cc
diff --git a/media/base/sinc_resampler_unittest.cc b/media/base/sinc_resampler_unittest.cc
index 77a963e2ca5db9db11d1d08416abb804aac8caed..c7add8e3def250af2e2faf34b12258b7999babcf 100644
--- a/media/base/sinc_resampler_unittest.cc
+++ b/media/base/sinc_resampler_unittest.cc
@@ -95,7 +95,6 @@ TEST(SincResamplerTest, Flush) {
// Ensure various optimized Convolve() methods return the same value. Only run
// this test if other optimized methods exist, otherwise the default Convolve()
// will be tested by the parameterized SincResampler tests below.
-#if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__)
TEST(SincResamplerTest, Convolve) {
// Initialize a dummy resampler.
MockSource mock_source;
@@ -112,21 +111,34 @@ TEST(SincResamplerTest, Convolve) {
double result = resampler.Convolve_C(
resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
- double result2 = resampler.Convolve_SSE(
+
+ double result2 = result;
Ami GONE FROM CHROMIUM 2012/09/21 04:41:41 I don't like this b/c it'll make the test claim to
DaleCurtis 2012/09/24 19:54:37 Done.
+#if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__)
+ result2 = resampler.Convolve_SSE(
+ resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
+ resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+#elif defined(ARCH_CPU_ARM_FAMILY) && defined(__ARM_NEON__) && defined(USE_NEON)
Ami GONE FROM CHROMIUM 2012/09/21 04:41:41 Here and elsewhere, I think __ARM_NEON__ is unnece
DaleCurtis 2012/09/24 19:54:37 Done.
+ result2 = resampler.Convolve_NEON(
resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+#endif
EXPECT_NEAR(result2, result, kEpsilon);
- // Test Convolve_SSE() w/ unaligned input pointer.
+ // Test Convolve() w/ unaligned input pointer.
result = resampler.Convolve_C(
resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+#if defined(ARCH_CPU_X86_FAMILY) && defined(__SSE__)
result2 = resampler.Convolve_SSE(
resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(),
resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+#elif defined(ARCH_CPU_ARM_FAMILY) && defined(__ARM_NEON__) && defined(USE_NEON)
+ result2 = resampler.Convolve_NEON(
+ resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(),
+ resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+#endif
EXPECT_NEAR(result2, result, kEpsilon);
}
-#endif
// Benchmark for the various Convolve() methods. Make sure to build with
// branding=Chrome so that DCHECKs are compiled out when benchmarking. Original
@@ -139,7 +151,7 @@ TEST(SincResamplerTest, ConvolveBenchmark) {
base::Bind(&MockSource::ProvideInput, base::Unretained(&mock_source)));
// Retrieve benchmark iterations from command line.
- int convolve_iterations = 10;
+ int convolve_iterations = 50000000;
Ami GONE FROM CHROMIUM 2012/09/21 04:41:41 what now?
DaleCurtis 2012/09/24 19:54:37 Was just for benchmarking on the try bot, but sadl
std::string iterations(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
kConvolveIterations));
if (!iterations.empty())
@@ -185,6 +197,33 @@ TEST(SincResamplerTest, ConvolveBenchmark) {
" Convolve_C and %.2fx faster than Convolve_SSE (unaligned).\n",
total_time_sse_aligned_ms, total_time_c_ms / total_time_sse_aligned_ms,
total_time_sse_unaligned_ms / total_time_sse_aligned_ms);
+#elif defined(ARCH_CPU_ARM_FAMILY) && defined(__ARM_NEON__) && defined(USE_NEON)
Ami GONE FROM CHROMIUM 2012/09/21 04:41:41 Like with the original SSE CL, IWBN to include ben
DaleCurtis 2012/09/24 19:54:37 Done.
+ // Benchmark Convolve_NEON() with unaligned input pointer.
+ start = base::TimeTicks::HighResNow();
+ for (int j = 0; j < convolve_iterations; ++j) {
+ resampler.Convolve_NEON(
+ resampler.kernel_storage_.get() + 1, resampler.kernel_storage_.get(),
+ resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+ }
+ double total_time_sse_unaligned_ms =
Ami GONE FROM CHROMIUM 2012/09/22 02:38:27 there are a bunch of variables here and below that
DaleCurtis 2012/09/24 19:54:37 Done.
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("Convolve_NEON (unaligned) took %.2fms; which is %.2fx faster than"
+ " Convolve_C.\n", total_time_sse_unaligned_ms,
+ total_time_c_ms / total_time_sse_unaligned_ms);
+
+ // Benchmark Convolve_NEON() with aligned input pointer.
+ start = base::TimeTicks::HighResNow();
+ for (int j = 0; j < convolve_iterations; ++j) {
+ resampler.Convolve_NEON(
+ resampler.kernel_storage_.get(), resampler.kernel_storage_.get(),
+ resampler.kernel_storage_.get(), kKernelInterpolationFactor);
+ }
+ double total_time_sse_aligned_ms =
+ (base::TimeTicks::HighResNow() - start).InMillisecondsF();
+ printf("Convolve_NEON (aligned) took %.2fms; which is %.2fx faster than"
+ " Convolve_C and %.2fx faster than Convolve_SSE (unaligned).\n",
Ami GONE FROM CHROMIUM 2012/09/22 02:38:27 s/SSE/NEON/, I think :)
DaleCurtis 2012/09/24 19:54:37 Done.
+ total_time_sse_aligned_ms, total_time_c_ms / total_time_sse_aligned_ms,
+ total_time_sse_unaligned_ms / total_time_sse_aligned_ms);
#endif
}
« no previous file with comments | « media/base/sinc_resampler.cc ('k') | media/media.gyp » ('j') | media/media.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698