• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8 
9 #pragma once
10 
11 #include <cpuinfo.h>
12 
13 #include <xnnpack/common.h>
14 
15 
16 #define TEST_REQUIRES_X86_SSE \
17   do { \
18     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse()) { \
19       GTEST_SKIP(); \
20     } \
21   } while (0)
22 
23 #define TEST_REQUIRES_X86_SSE2 \
24   do { \
25     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse2()) { \
26       GTEST_SKIP(); \
27     } \
28   } while (0)
29 
30 #define TEST_REQUIRES_X86_SSSE3 \
31   do { \
32     if (!cpuinfo_initialize() || !cpuinfo_has_x86_ssse3()) { \
33       GTEST_SKIP(); \
34     } \
35   } while (0)
36 
37 #define TEST_REQUIRES_X86_SSE41 \
38   do { \
39     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse4_1()) { \
40       GTEST_SKIP(); \
41     } \
42   } while (0)
43 
44 #define TEST_REQUIRES_X86_AVX \
45   do { \
46     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
47       GTEST_SKIP(); \
48     } \
49   } while (0)
50 
51 #define TEST_REQUIRES_X86_F16C \
52   do { \
53     if (!cpuinfo_initialize() || !cpuinfo_has_x86_f16c()) { \
54       GTEST_SKIP(); \
55     } \
56   } while (0)
57 
58 #define TEST_REQUIRES_X86_XOP \
59   do { \
60     if (!cpuinfo_initialize() || !cpuinfo_has_x86_xop()) { \
61       GTEST_SKIP(); \
62     } \
63   } while (0)
64 
65 #define TEST_REQUIRES_X86_FMA3 \
66   do { \
67     if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \
68       GTEST_SKIP(); \
69     } \
70   } while (0)
71 
72 #define TEST_REQUIRES_X86_AVX2 \
73   do { \
74     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx2()) { \
75       GTEST_SKIP(); \
76     } \
77   } while (0)
78 
79 #define TEST_REQUIRES_X86_AVX512F \
80   do { \
81     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f()) { \
82       GTEST_SKIP(); \
83     } \
84   } while (0)
85 
86 #define TEST_REQUIRES_X86_AVX512SKX \
87   do { \
88     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f() || !cpuinfo_has_x86_avx512cd() || !cpuinfo_has_x86_avx512dq() || !cpuinfo_has_x86_avx512bw() || !cpuinfo_has_x86_avx512vl()) { \
89       GTEST_SKIP(); \
90     } \
91   } while (0)
92 
93 #define TEST_REQUIRES_ARM_SIMD32 \
94   do { \
95     if (!cpuinfo_initialize() || !cpuinfo_has_arm_v6()) { \
96       GTEST_SKIP(); \
97     } \
98   } while (0)
99 
100 #define TEST_REQUIRES_ARM_NEON \
101   do { \
102     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \
103       GTEST_SKIP(); \
104     } \
105   } while (0)
106 
107 #define TEST_REQUIRES_ARM_NEON_FP16 \
108   do { \
109     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16()) { \
110       GTEST_SKIP(); \
111     } \
112   } while (0)
113 
114 #define TEST_REQUIRES_ARM_NEON_FMA \
115   do { \
116     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \
117       GTEST_SKIP(); \
118     } \
119   } while (0)
120 
121 #define TEST_REQUIRES_ARM_NEON_V8 \
122   do { \
123     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_v8()) { \
124       GTEST_SKIP(); \
125     } \
126   } while (0)
127 
128 #define TEST_REQUIRES_ARM_NEON_FP16_ARITH \
129   do { \
130     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \
131       GTEST_SKIP(); \
132     } \
133   } while (0)
134 
135 #define TEST_REQUIRES_ARM_NEON_BF16 \
136   do { \
137     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_bf16()) { \
138       GTEST_SKIP(); \
139     } \
140   } while (0)
141 
142 #define TEST_REQUIRES_ARM_NEON_DOT \
143   do { \
144     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_dot()) { \
145       GTEST_SKIP(); \
146     } \
147   } while (0)
148