blob: 048a688cd4891fc6f3b005e6709772dbecf721a9 [file] [log] [blame]
XNNPACK Teamb455b122019-09-27 18:10:33 -07001// 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
Marat Dukhan1dadbf72019-10-01 10:46:20 -070013#include <xnnpack/common.h>
XNNPACK Teamb455b122019-09-27 18:10:33 -070014
Marat Dukhan1dadbf72019-10-01 10:46:20 -070015
Marat Dukhanf42facc2020-03-08 15:14:53 -070016#if XNN_ARCH_WASMSIMD
XNNPACK Teamb455b122019-09-27 18:10:33 -070017 #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
Marat Dukhan595e1702020-07-31 10:12:52 -070041#define TEST_REQUIRES_X86_SSSE3 \
42 do { \
43 if (!cpuinfo_initialize() || !cpuinfo_has_x86_ssse3()) { \
44 GTEST_SKIP(); \
45 } \
46 } while (0)
47
Marat Dukhan69c3f2c2019-11-06 12:30:01 -080048#define TEST_REQUIRES_X86_SSE41 \
49 do { \
50 if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse4_1()) { \
51 GTEST_SKIP(); \
52 } \
53 } while (0)
54
XNNPACK Teamb455b122019-09-27 18:10:33 -070055#define TEST_REQUIRES_X86_AVX \
56 do { \
57 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
58 GTEST_SKIP(); \
59 } \
60 } while (0)
61
Marat Dukhanfda12b82019-11-21 12:27:59 -080062#define TEST_REQUIRES_X86_FMA3 \
63 do { \
64 if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \
65 GTEST_SKIP(); \
66 } \
67 } while (0)
68
XNNPACK Teamb455b122019-09-27 18:10:33 -070069#define TEST_REQUIRES_X86_AVX2 \
70 do { \
71 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx2()) { \
72 GTEST_SKIP(); \
73 } \
74 } while (0)
75
76#define TEST_REQUIRES_X86_AVX512F \
77 do { \
78 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f()) { \
79 GTEST_SKIP(); \
80 } \
81 } while (0)
82
83#define TEST_REQUIRES_ARM_NEON \
84 do { \
85 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \
86 GTEST_SKIP(); \
87 } \
88 } while (0)
89
90#define TEST_REQUIRES_ARM_NEON_FMA \
91 do { \
92 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \
93 GTEST_SKIP(); \
94 } \
95 } while (0)
96
Marat Dukhaneecf8fd2020-06-09 08:59:37 -070097#define TEST_REQUIRES_ARM_NEON_V8 \
98 do { \
99 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_v8()) { \
100 GTEST_SKIP(); \
101 } \
102 } while (0)
103
XNNPACK Teamb455b122019-09-27 18:10:33 -0700104#define TEST_REQUIRES_ARM_NEON_FP16_ARITH \
105 do { \
106 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \
107 GTEST_SKIP(); \
108 } \
109 } while (0)