blob: e5d1fc6caf296d4ff6ad491845b3ec91efd759c0 [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
16#if XNN_ARCH_PNACL || 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 Dukhan69c3f2c2019-11-06 12:30:01 -080041#define TEST_REQUIRES_X86_SSE41 \
42 do { \
43 if (!cpuinfo_initialize() || !cpuinfo_has_x86_sse4_1()) { \
44 GTEST_SKIP(); \
45 } \
46 } while (0)
47
XNNPACK Teamb455b122019-09-27 18:10:33 -070048#define TEST_REQUIRES_X86_AVX \
49 do { \
50 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
51 GTEST_SKIP(); \
52 } \
53 } while (0)
54
Marat Dukhanfda12b82019-11-21 12:27:59 -080055#define TEST_REQUIRES_X86_FMA3 \
56 do { \
57 if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \
58 GTEST_SKIP(); \
59 } \
60 } while (0)
61
XNNPACK Teamb455b122019-09-27 18:10:33 -070062#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)