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

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: 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
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 "webrtc/system_wrappers/include/cpu_features_wrapper.h"
14 #include "webrtc/test/gtest.h"
15 #include "webrtc/typedefs.h"
16
17 namespace webrtc {
18
19 #if defined(WEBRTC_ARCH_X86_FAMILY)
20
21 TEST(VectorMath, Sqrt) {
22 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
23 std::array<float, kFftLengthBy2Plus1> x;
24 std::array<float, kFftLengthBy2Plus1> z;
25 std::array<float, kFftLengthBy2Plus1> z_sse2;
26
27 for (size_t k = 0; k < x.size(); ++k) {
28 x[k] = 2.f / 3.f * k;
ivoc 2017/04/11 12:03:01 I would add some braces to make the order of opera
peah-webrtc 2017/04/11 13:09:26 Done.
29 }
30
31 std::copy(x.begin(), x.end(), z.begin());
32 aec3::VectorMath(Aec3Optimization::kNone).Sqrt(z);
33 std::copy(x.begin(), x.end(), z_sse2.begin());
34 aec3::VectorMath(Aec3Optimization::kSse2).Sqrt(z_sse2);
35 EXPECT_EQ(z, z_sse2);
ivoc 2017/04/11 12:03:01 Does this check the contents of the arrays as well
peah-webrtc 2017/04/11 13:09:26 No. That was not the intention, but since this is
36 for (size_t k = 0; k < z.size(); ++k) {
37 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
38 }
39 }
40 }
41
42 TEST(VectorMath, Multiply) {
43 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
44 std::array<float, kFftLengthBy2Plus1> x;
45 std::array<float, kFftLengthBy2Plus1> y;
46 std::array<float, kFftLengthBy2Plus1> z;
47 std::array<float, kFftLengthBy2Plus1> z_sse2;
48
49 for (size_t k = 0; k < x.size(); ++k) {
50 x[k] = k;
51 y[k] = 2.f / 3.f * k;
ivoc 2017/04/11 12:03:01 Braces would be nice.
peah-webrtc 2017/04/11 13:09:26 Done.
52 }
53
54 aec3::VectorMath(Aec3Optimization::kNone).Multiply(x, y, z);
55 aec3::VectorMath(Aec3Optimization::kSse2).Multiply(x, y, z_sse2);
56 for (size_t k = 0; k < z.size(); ++k) {
57 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
58 }
59 }
60 }
61
62 TEST(VectorMath, Accumulate) {
63 if (WebRtc_GetCPUInfo(kSSE2) != 0) {
64 std::array<float, kFftLengthBy2Plus1> x;
65 std::array<float, kFftLengthBy2Plus1> z;
66 std::array<float, kFftLengthBy2Plus1> z_sse2;
67
68 for (size_t k = 0; k < x.size(); ++k) {
69 x[k] = k;
70 z[k] = z_sse2[k] = 2.f * k;
71 }
72
73 aec3::VectorMath(Aec3Optimization::kNone).Accumulate(x, z);
74 aec3::VectorMath(Aec3Optimization::kSse2).Accumulate(x, z_sse2);
75 for (size_t k = 0; k < z.size(); ++k) {
76 EXPECT_FLOAT_EQ(z[k], z_sse2[k]);
77 }
78 }
79 }
80 #endif
81
82 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698