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

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

Issue 2813823002: Adding new functionality for SIMD optimizations in AEC3 (Closed)
Patch Set: Fixed build error on windows Created 3 years, 8 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
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/audio_processing/aec3/vector_math.h"
12
13 #include <math.h>
14
15 #include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
16 #include "webrtc/test/gtest.h"
17 #include "webrtc/typedefs.h"
18
19 namespace webrtc {
20
21 #if defined(WEBRTC_ARCH_X86_FAMILY)
22
23 TEST(VectorMath, Sqrt) {
24 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
25 std::array<float, kFftLengthBy2Plus1> x;
26 std::array<float, kFftLengthBy2Plus1> z;
27 std::array<float, kFftLengthBy2Plus1> z_sse2;
28
29 for (size_t k = 0; k < x.size(); ++k) {
30 x[k] = (2.f / 3.f) * k;
31 }
32
33 std::copy(x.begin(), x.end(), z.begin());
34 aec3::VectorMath(Aec3Optimization::kNone).Sqrt(z);
35 std::copy(x.begin(), x.end(), z_sse2.begin());
36 aec3::VectorMath(Aec3Optimization::kSse2).Sqrt(z_sse2);
37 EXPECT_EQ(z, z_sse2);
38 for (size_t k = 0; k < z.size(); ++k) {
39 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
40 EXPECT_FLOAT_EQ(sqrtf(x[k]), z_sse2[k]);
41 }
42 }
43 }
44
45 TEST(VectorMath, Multiply) {
46 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
47 std::array<float, kFftLengthBy2Plus1> x;
48 std::array<float, kFftLengthBy2Plus1> y;
49 std::array<float, kFftLengthBy2Plus1> z;
50 std::array<float, kFftLengthBy2Plus1> z_sse2;
51
52 for (size_t k = 0; k < x.size(); ++k) {
53 x[k] = k;
54 y[k] = (2.f / 3.f) * k;
55 }
56
57 aec3::VectorMath(Aec3Optimization::kNone).Multiply(x, y, z);
58 aec3::VectorMath(Aec3Optimization::kSse2).Multiply(x, y, z_sse2);
59 for (size_t k = 0; k < z.size(); ++k) {
60 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
61 EXPECT_FLOAT_EQ(x[k] * y[k], z_sse2[k]);
62 }
63 }
64 }
65
66 TEST(VectorMath, Accumulate) {
67 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
68 std::array<float, kFftLengthBy2Plus1> x;
69 std::array<float, kFftLengthBy2Plus1> z;
70 std::array<float, kFftLengthBy2Plus1> z_sse2;
71
72 for (size_t k = 0; k < x.size(); ++k) {
73 x[k] = k;
74 z[k] = z_sse2[k] = 2.f * k;
75 }
76
77 aec3::VectorMath(Aec3Optimization::kNone).Accumulate(x, z);
78 aec3::VectorMath(Aec3Optimization::kSse2).Accumulate(x, z_sse2);
79 for (size_t k = 0; k < z.size(); ++k) {
80 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
81 EXPECT_FLOAT_EQ(x[k] + 2.f * x[k], z_sse2[k]);
82 }
83 }
84 }
85 #endif
86
87 } // 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