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

Side by Side Diff: webrtc/modules/audio_processing/aec3/vector_math_unittest.cc

Issue 2862573002: Reland of Added ARM Neon SIMD optimizations for AEC3 (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « webrtc/modules/audio_processing/aec3/vector_math.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/audio_processing/aec3/vector_math.h" 11 #include "webrtc/modules/audio_processing/aec3/vector_math.h"
12 12
13 #include <math.h> 13 #include <math.h>
14 14
15 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h" 15 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
16 #include "webrtc/test/gtest.h" 16 #include "webrtc/test/gtest.h"
17 #include "webrtc/typedefs.h" 17 #include "webrtc/typedefs.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 #if defined(WEBRTC_HAS_NEON)
22
23 TEST(VectorMath, Sqrt) {
24 std::array<float, kFftLengthBy2Plus1> x;
25 std::array<float, kFftLengthBy2Plus1> z;
26 std::array<float, kFftLengthBy2Plus1> z_neon;
27
28 for (size_t k = 0; k < x.size(); ++k) {
29 x[k] = (2.f / 3.f) * k;
30 }
31
32 std::copy(x.begin(), x.end(), z.begin());
33 aec3::VectorMath(Aec3Optimization::kNone).Sqrt(z);
34 std::copy(x.begin(), x.end(), z_neon.begin());
35 aec3::VectorMath(Aec3Optimization::kNeon).Sqrt(z_neon);
36 for (size_t k = 0; k < z.size(); ++k) {
37 EXPECT_NEAR(z[k], z_neon[k], 0.0001f);
38 EXPECT_NEAR(sqrtf(x[k]), z_neon[k], 0.0001f);
39 }
40 }
41
42 TEST(VectorMath, Multiply) {
43 std::array<float, kFftLengthBy2Plus1> x;
44 std::array<float, kFftLengthBy2Plus1> y;
45 std::array<float, kFftLengthBy2Plus1> z;
46 std::array<float, kFftLengthBy2Plus1> z_neon;
47
48 for (size_t k = 0; k < x.size(); ++k) {
49 x[k] = k;
50 y[k] = (2.f / 3.f) * k;
51 }
52
53 aec3::VectorMath(Aec3Optimization::kNone).Multiply(x, y, z);
54 aec3::VectorMath(Aec3Optimization::kNeon).Multiply(x, y, z_neon);
55 for (size_t k = 0; k < z.size(); ++k) {
56 EXPECT_FLOAT_EQ(z[k], z_neon[k]);
57 EXPECT_FLOAT_EQ(x[k] * y[k], z_neon[k]);
58 }
59 }
60
61 TEST(VectorMath, Accumulate) {
62 std::array<float, kFftLengthBy2Plus1> x;
63 std::array<float, kFftLengthBy2Plus1> z;
64 std::array<float, kFftLengthBy2Plus1> z_neon;
65
66 for (size_t k = 0; k < x.size(); ++k) {
67 x[k] = k;
68 z[k] = z_neon[k] = 2.f * k;
69 }
70
71 aec3::VectorMath(Aec3Optimization::kNone).Accumulate(x, z);
72 aec3::VectorMath(Aec3Optimization::kNeon).Accumulate(x, z_neon);
73 for (size_t k = 0; k < z.size(); ++k) {
74 EXPECT_FLOAT_EQ(z[k], z_neon[k]);
75 EXPECT_FLOAT_EQ(x[k] + 2.f * x[k], z_neon[k]);
76 }
77 }
78 #endif
79
21 #if defined(WEBRTC_ARCH_X86_FAMILY) 80 #if defined(WEBRTC_ARCH_X86_FAMILY)
22 81
23 TEST(VectorMath, Sqrt) { 82 TEST(VectorMath, Sqrt) {
24 if (WebRtc_GetCPUInfo(kSSE2) != 0) { 83 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
25 std::array<float, kFftLengthBy2Plus1> x; 84 std::array<float, kFftLengthBy2Plus1> x;
26 std::array<float, kFftLengthBy2Plus1> z; 85 std::array<float, kFftLengthBy2Plus1> z;
27 std::array<float, kFftLengthBy2Plus1> z_sse2; 86 std::array<float, kFftLengthBy2Plus1> z_sse2;
28 87
29 for (size_t k = 0; k < x.size(); ++k) { 88 for (size_t k = 0; k < x.size(); ++k) {
30 x[k] = (2.f / 3.f) * k; 89 x[k] = (2.f / 3.f) * k;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 aec3::VectorMath(Aec3Optimization::kSse2).Accumulate(x, z_sse2); 137 aec3::VectorMath(Aec3Optimization::kSse2).Accumulate(x, z_sse2);
79 for (size_t k = 0; k < z.size(); ++k) { 138 for (size_t k = 0; k < z.size(); ++k) {
80 EXPECT_FLOAT_EQ(z[k], z_sse2[k]); 139 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
81 EXPECT_FLOAT_EQ(x[k] + 2.f * x[k], z_sse2[k]); 140 EXPECT_FLOAT_EQ(x[k] + 2.f * x[k], z_sse2[k]);
82 } 141 }
83 } 142 }
84 } 143 }
85 #endif 144 #endif
86 145
87 } // namespace webrtc 146 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/vector_math.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698