/* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
staticint FileExists(constchar* file_name) {
FILE* f = fopen(file_name, "r"); if (!f) { return 0;
}
fclose(f); return 1;
}
TEST_F(LibYUVBaseTest, TestLinuxArm) { if (FileExists("../../unit_test/testdata/arm_v7.txt")) {
printf("Note: testing to load \"../../unit_test/testdata/arm_v7.txt\"\n");
EXPECT_EQ(0, ArmCpuCaps("../../unit_test/testdata/arm_v7.txt"));
EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/tegra3.txt"));
} else {
printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n");
} #ifdefined(__linux__) && defined(__ARM_NEON__) && !defined(__aarch64__) if (FileExists("/proc/cpuinfo")) { if (kCpuHasNEON != ArmCpuCaps("/proc/cpuinfo")) { // This can happen on Arm emulator but /proc/cpuinfo is from host.
printf("WARNING: Neon build enabled but CPU does not have Neon\n");
}
} else {
printf("WARNING: unable to load \"/proc/cpuinfo\"\n");
} #endif
}
#ifdefined(__linux__) && defined(__aarch64__)
TEST_F(LibYUVBaseTest, TestLinuxAArch64) { // Values taken from a Cortex-A57 machine, only Neon available.
EXPECT_EQ(kCpuHasNEON, AArch64CpuCaps(0xffU, 0x0U));
// Values taken from a Google Pixel 7. int expected = kCpuHasNEON | kCpuHasNeonDotProd;
EXPECT_EQ(expected, AArch64CpuCaps(0x119fffU, 0x0U));
// Values taken from a Google Pixel 8.
expected = kCpuHasNEON | kCpuHasNeonDotProd | kCpuHasNeonI8MM | kCpuHasSVE |
kCpuHasSVE2;
EXPECT_EQ(expected, AArch64CpuCaps(0x3fffffffU, 0x2f33fU));
// Values taken from a Neoverse N2 machine.
EXPECT_EQ(expected, AArch64CpuCaps(0x3fffffffU, 0x2f3ffU));
// Check for SME feature detection.
expected |= kCpuHasSME;
EXPECT_EQ(expected, AArch64CpuCaps(0x3fffffffU, 0x82f3ffU));
} #endif
TEST_F(LibYUVBaseTest, TestLinuxMipsMsa) { if (FileExists("../../unit_test/testdata/mips.txt")) {
printf("Note: testing to load \"../../unit_test/testdata/mips.txt\"\n");
TEST_F(LibYUVBaseTest, TestLinuxRVV) { if (FileExists("../../unit_test/testdata/riscv64.txt")) {
printf("Note: testing to load \"../../unit_test/testdata/riscv64.txt\"\n");
EXPECT_EQ(0, RiscvCpuCaps("../../unit_test/testdata/riscv64.txt"));
EXPECT_EQ(kCpuHasRVV,
RiscvCpuCaps("../../unit_test/testdata/riscv64_rvv.txt"));
EXPECT_EQ(kCpuHasRVV | kCpuHasRVVZVFH,
RiscvCpuCaps("../../unit_test/testdata/riscv64_rvv_zvfh.txt"));
} else {
printf( "WARNING: unable to load " "\"../../unit_test/testdata/riscv64.txt\"\n");
} #ifdefined(__linux__) && defined(__riscv) if (FileExists("/proc/cpuinfo")) { if (!(kCpuHasRVV & RiscvCpuCaps("/proc/cpuinfo"))) { // This can happen on RVV emulator but /proc/cpuinfo is from host.
printf("WARNING: RVV build enabled but CPU does not have RVV\n");
}
} else {
printf("WARNING: unable to load \"/proc/cpuinfo\"\n");
} #endif
}
// TODO(fbarchard): Fix clangcl test of cpuflags. #ifdef _MSC_VER
TEST_F(LibYUVBaseTest, DISABLED_TestSetCpuFlags) { #else
TEST_F(LibYUVBaseTest, TestSetCpuFlags) { #endif // Reset any masked flags that may have been set so auto init is enabled.
MaskCpuFlags(0);
int original_cpu_flags = TestCpuFlag(-1);
// Test setting different CPU configurations. int cpu_flags = kCpuHasARM | kCpuHasNEON | kCpuInitialized;
SetCpuFlags(cpu_flags);
EXPECT_EQ(cpu_flags, TestCpuFlag(-1));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.