blob: e4aebd6d1b3ee0883e61901f34e3f37530579ce0 [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
41#define TEST_REQUIRES_X86_AVX \
42 do { \
43 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \
44 GTEST_SKIP(); \
45 } \
46 } while (0)
47
48#define TEST_REQUIRES_X86_AVX2 \
49 do { \
50 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx2()) { \
51 GTEST_SKIP(); \
52 } \
53 } while (0)
54
55#define TEST_REQUIRES_X86_AVX512F \
56 do { \
57 if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f()) { \
58 GTEST_SKIP(); \
59 } \
60 } while (0)
61
62#define TEST_REQUIRES_ARM_NEON \
63 do { \
64 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \
65 GTEST_SKIP(); \
66 } \
67 } while (0)
68
69#define TEST_REQUIRES_ARM_NEON_FMA \
70 do { \
71 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \
72 GTEST_SKIP(); \
73 } \
74 } while (0)
75
76#define TEST_REQUIRES_ARM_NEON_FP16_ARITH \
77 do { \
78 if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \
79 GTEST_SKIP(); \
80 } \
81 } while (0)