• 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 #if XNN_ARCH_PNACL || XNN_ARCH_WASMSIMD
17   #define TEST_REQUIRES_PSIMD
18 #else
19   #define TEST_REQUIRES_PSIMD \
20     do { \
21       if (!cpuinfo_initialize() || !(cpuinfo_has_arm_neon() || cpuinfo_has_x86_sse2())) { \
22         GTEST_SKIP(); \
23       } \
24     } while (0)
25 #endif
26 
27 #define TEST_REQUIRES_X86_SSE \
28   do { \
29     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse()) { \
30       GTEST_SKIP(); \
31     } \
32   } while (0)
33 
34 #define TEST_REQUIRES_X86_SSE2 \
35   do { \
36     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse2()) { \
37       GTEST_SKIP(); \
38     } \
39   } while (0)
40 
41 #define TEST_REQUIRES_X86_SSE41 \
42   do { \
43     if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse4_1()) { \
44       GTEST_SKIP(); \
45     } \
46   } while (0)
47 
48 #define TEST_REQUIRES_X86_AVX \
49   do { \
50     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
51       GTEST_SKIP(); \
52     } \
53   } while (0)
54 
55 #define TEST_REQUIRES_X86_FMA3 \
56   do { \
57     if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \
58       GTEST_SKIP(); \
59     } \
60   } while (0)
61 
62 #define TEST_REQUIRES_X86_AVX2 \
63   do { \
64     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx2()) { \
65       GTEST_SKIP(); \
66     } \
67   } while (0)
68 
69 #define TEST_REQUIRES_X86_AVX512F \
70   do { \
71     if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f()) { \
72       GTEST_SKIP(); \
73     } \
74   } while (0)
75 
76 #define TEST_REQUIRES_ARM_NEON \
77   do { \
78     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \
79       GTEST_SKIP(); \
80     } \
81   } while (0)
82 
83 #define TEST_REQUIRES_ARM_NEON_FMA \
84   do { \
85     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \
86       GTEST_SKIP(); \
87     } \
88   } while (0)
89 
90 #define TEST_REQUIRES_ARM_NEON_FP16_ARITH \
91   do { \
92     if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \
93       GTEST_SKIP(); \
94     } \
95   } while (0)
96