blob: a08d46e5490373c8df006f974f42b74baa519b47 [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
XNNPACK Teamb455b122019-09-27 18:10:33 -070016#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
Marat Dukhan595e1702020-07-31 10:12:52 -070030#define TEST_REQUIRES_X86_SSSE3 \
31 do { \
32 if (!cpuinfo_initialize() || !cpuinfo_has_x86_ssse3()) { \
33 GTEST_SKIP(); \
34 } \
35 } while (0)
36
Marat Dukhan69c3f2c2019-11-06 12:30:01 -080037#define TEST_REQUIRES_X86_SSE41 \
38 do { \
39 if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse4_1()) { \
40 GTEST_SKIP(); \
41 } \
42 } while (0)
43
XNNPACK Teamb455b122019-09-27 18:10:33 -070044#define TEST_REQUIRES_X86_AVX \
45 do { \
46 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
47 GTEST_SKIP(); \
48 } \
49 } while (0)
50
Marat Dukhanf1a6ed32021-09-26 13:40:19 -070051#define TEST_REQUIRES_X86_F16C \
52 do { \
53 if (!cpuinfo_initialize() || !cpuinfo_has_x86_f16c()) { \
54 GTEST_SKIP(); \
55 } \
56 } while (0)
57
Marat Dukhan1566fee2020-08-02 21:55:41 -070058#define TEST_REQUIRES_X86_XOP \
59 do { \
60 if (!cpuinfo_initialize() || !cpuinfo_has_x86_xop()) { \
61 GTEST_SKIP(); \
62 } \
63 } while (0)
64
Marat Dukhanfda12b82019-11-21 12:27:59 -080065#define TEST_REQUIRES_X86_FMA3 \
66 do { \
67 if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \
68 GTEST_SKIP(); \
69 } \
70 } while (0)
71
XNNPACK Teamb455b122019-09-27 18:10:33 -070072#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
Marat Dukhanbb00b1d2020-08-10 11:37:23 -070086#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
XNNPACK Teamb455b122019-09-27 18:10:33 -070093#define TEST_REQUIRES_ARM_NEON \
94 do { \
95 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \
96 GTEST_SKIP(); \
97 } \
98 } while (0)
99
Marat Dukhan8ff372c2021-09-28 14:43:17 -0700100#define TEST_REQUIRES_ARM_NEON_FP16 \
101 do { \
102 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16()) { \
103 GTEST_SKIP(); \
104 } \
105 } while (0)
106
XNNPACK Teamb455b122019-09-27 18:10:33 -0700107#define TEST_REQUIRES_ARM_NEON_FMA \
108 do { \
109 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \
110 GTEST_SKIP(); \
111 } \
112 } while (0)
113
Marat Dukhaneecf8fd2020-06-09 08:59:37 -0700114#define TEST_REQUIRES_ARM_NEON_V8 \
115 do { \
116 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_v8()) { \
117 GTEST_SKIP(); \
118 } \
119 } while (0)
120
XNNPACK Teamb455b122019-09-27 18:10:33 -0700121#define TEST_REQUIRES_ARM_NEON_FP16_ARITH \
122 do { \
123 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \
124 GTEST_SKIP(); \
125 } \
126 } while (0)
Benoit Jacoba9644732020-08-13 12:48:55 -0700127
128#define TEST_REQUIRES_ARM_NEON_DOT \
129 do { \
130 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_dot()) { \
131 GTEST_SKIP(); \
132 } \
133 } while (0)