You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
/*
|
|
* Copyright (C) 2020 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <audio_utils/intrinsic_utils.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
template <typename D>
|
|
class IntrisicUtilsTest : public ::testing::Test { };
|
|
|
|
// Basic intrinsic tests which are run on the simple scalar types (no NEON SIMD vector registers).
|
|
using FloatTypes = ::testing::Types<float, double>;
|
|
TYPED_TEST_CASE(IntrisicUtilsTest, FloatTypes);
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vdupn) {
|
|
constexpr TypeParam value = 1.f;
|
|
ASSERT_EQ(value, android::audio_utils::intrinsics::vdupn<TypeParam>(value));
|
|
}
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vld1) {
|
|
constexpr TypeParam value = 2.f;
|
|
ASSERT_EQ(value, android::audio_utils::intrinsics::vld1<TypeParam>(&value));
|
|
}
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vmla) {
|
|
constexpr TypeParam a = 2.125f;
|
|
constexpr TypeParam b = 2.25f;
|
|
constexpr TypeParam c = 2.5f;
|
|
constexpr TypeParam result = c + a * b;
|
|
ASSERT_EQ(result, android::audio_utils::intrinsics::vmla(c, a, b));
|
|
}
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vmul) {
|
|
constexpr TypeParam a = 2.25f;
|
|
constexpr TypeParam b = 2.5f;
|
|
constexpr TypeParam result = a * b;
|
|
ASSERT_EQ(result, android::audio_utils::intrinsics::vmul(a, b));
|
|
}
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vneg) {
|
|
constexpr TypeParam value = 3.125f;
|
|
ASSERT_EQ(-value, android::audio_utils::intrinsics::vneg(value));
|
|
}
|
|
|
|
TYPED_TEST(IntrisicUtilsTest, vst1) {
|
|
constexpr TypeParam value = 2.f;
|
|
TypeParam destination = 1.f;
|
|
android::audio_utils::intrinsics::vst1(
|
|
&destination, android::audio_utils::intrinsics::vdupn<TypeParam>(value));
|
|
ASSERT_EQ(value, destination);
|
|
}
|