OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2012 The LibYuv 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 <stdlib.h> | 11 #include <stdlib.h> |
12 #include <string.h> | 12 #include <string.h> |
13 | 13 |
14 #include "libyuv/basic_types.h" | 14 #include "libyuv/basic_types.h" |
15 #include "libyuv/cpu_id.h" | 15 #include "libyuv/cpu_id.h" |
16 #include "libyuv/row.h" // For HAS_ARGBSHUFFLEROW_AVX2. | |
17 #include "libyuv/version.h" | 16 #include "libyuv/version.h" |
18 #include "../unit_test/unit_test.h" | 17 #include "../unit_test/unit_test.h" |
19 | 18 |
20 namespace libyuv { | 19 namespace libyuv { |
21 | 20 |
22 TEST_F(LibYUVBaseTest, TestCpuHas) { | 21 TEST_F(LibYUVBaseTest, TestCpuHas) { |
23 int cpu_flags = TestCpuFlag(-1); | 22 int cpu_flags = TestCpuFlag(-1); |
24 printf("Cpu Flags %x\n", cpu_flags); | 23 printf("Cpu Flags %x\n", cpu_flags); |
25 int has_arm = TestCpuFlag(kCpuHasARM); | 24 int has_arm = TestCpuFlag(kCpuHasARM); |
26 printf("Has ARM %x\n", has_arm); | 25 printf("Has ARM %x\n", has_arm); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #endif | 60 #endif |
62 #if defined(__x86_64__) || defined(_M_X64) | 61 #if defined(__x86_64__) || defined(_M_X64) |
63 printf("x64 build\n"); | 62 printf("x64 build\n"); |
64 #endif | 63 #endif |
65 #ifdef _MSC_VER | 64 #ifdef _MSC_VER |
66 printf("_MSC_VER %d\n", _MSC_VER); | 65 printf("_MSC_VER %d\n", _MSC_VER); |
67 #endif | 66 #endif |
68 #if !defined(LIBYUV_DISABLE_X86) && (defined(GCC_HAS_AVX2) || \ | 67 #if !defined(LIBYUV_DISABLE_X86) && (defined(GCC_HAS_AVX2) || \ |
69 defined(CLANG_HAS_AVX2) || defined(VISUALC_HAS_AVX2)) | 68 defined(CLANG_HAS_AVX2) || defined(VISUALC_HAS_AVX2)) |
70 printf("Has AVX2 1\n"); | 69 printf("Has AVX2 1\n"); |
71 // If compiler supports AVX2, the following function is expected to exist: | |
72 #if !defined(HAS_ARGBSHUFFLEROW_AVX2) | |
73 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was expected. | |
74 #endif | |
75 #else | 70 #else |
76 printf("Has AVX2 0\n"); | 71 printf("Has AVX2 0\n"); |
77 // If compiler does not support AVX2, the following function not expected: | 72 // If compiler does not support AVX2, the following function not expected: |
78 #if defined(HAS_ARGBSHUFFLEROW_AVX2) | |
79 EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was not expected. | |
80 #endif | |
81 #endif | 73 #endif |
82 } | 74 } |
83 | 75 |
84 #if defined(__i386__) || defined(__x86_64__) || \ | 76 #if defined(__i386__) || defined(__x86_64__) || \ |
85 defined(_M_IX86) || defined(_M_X64) | 77 defined(_M_IX86) || defined(_M_X64) |
86 TEST_F(LibYUVBaseTest, TestCpuId) { | 78 TEST_F(LibYUVBaseTest, TestCpuId) { |
87 int has_x86 = TestCpuFlag(kCpuHasX86); | 79 int has_x86 = TestCpuFlag(kCpuHasX86); |
88 if (has_x86) { | 80 if (has_x86) { |
89 uint32 cpu_info[4]; | 81 uint32 cpu_info[4]; |
90 // Vendor ID: | 82 // Vendor ID: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt")); | 130 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt")); |
139 } else { | 131 } else { |
140 printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n"); | 132 printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n"); |
141 } | 133 } |
142 #if defined(__linux__) && defined(__ARM_NEON__) | 134 #if defined(__linux__) && defined(__ARM_NEON__) |
143 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo")); | 135 EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo")); |
144 #endif | 136 #endif |
145 } | 137 } |
146 | 138 |
147 } // namespace libyuv | 139 } // namespace libyuv |
OLD | NEW |