XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 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 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 13 | #include <xnnpack/common.h> |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 14 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 15 | |
Marat Dukhan | f42facc | 2020-03-08 15:14:53 -0700 | [diff] [blame] | 16 | #if XNN_ARCH_WASMSIMD |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 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 | |
Marat Dukhan | 595e170 | 2020-07-31 10:12:52 -0700 | [diff] [blame] | 41 | #define TEST_REQUIRES_X86_SSSE3 \ |
| 42 | do { \ |
| 43 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_ssse3()) { \ |
| 44 | GTEST_SKIP(); \ |
| 45 | } \ |
| 46 | } while (0) |
| 47 | |
Marat Dukhan | 69c3f2c | 2019-11-06 12:30:01 -0800 | [diff] [blame] | 48 | #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 Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 55 | #define TEST_REQUIRES_X86_AVX \ |
| 56 | do { \ |
| 57 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx()) { \ |
| 58 | GTEST_SKIP(); \ |
| 59 | } \ |
| 60 | } while (0) |
| 61 | |
Marat Dukhan | 1566fee | 2020-08-02 21:55:41 -0700 | [diff] [blame] | 62 | #define TEST_REQUIRES_X86_XOP \ |
| 63 | do { \ |
| 64 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_xop()) { \ |
| 65 | GTEST_SKIP(); \ |
| 66 | } \ |
| 67 | } while (0) |
| 68 | |
Marat Dukhan | fda12b8 | 2019-11-21 12:27:59 -0800 | [diff] [blame] | 69 | #define TEST_REQUIRES_X86_FMA3 \ |
| 70 | do { \ |
| 71 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_fma3()) { \ |
| 72 | GTEST_SKIP(); \ |
| 73 | } \ |
| 74 | } while (0) |
| 75 | |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 76 | #define TEST_REQUIRES_X86_AVX2 \ |
| 77 | do { \ |
| 78 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx2()) { \ |
| 79 | GTEST_SKIP(); \ |
| 80 | } \ |
| 81 | } while (0) |
| 82 | |
| 83 | #define TEST_REQUIRES_X86_AVX512F \ |
| 84 | do { \ |
| 85 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f()) { \ |
| 86 | GTEST_SKIP(); \ |
| 87 | } \ |
| 88 | } while (0) |
| 89 | |
Marat Dukhan | bb00b1d | 2020-08-10 11:37:23 -0700 | [diff] [blame] | 90 | #define TEST_REQUIRES_X86_AVX512SKX \ |
| 91 | do { \ |
| 92 | if (!cpuinfo_initialize() || !cpuinfo_has_x86_avx512f() || !cpuinfo_has_x86_avx512cd() || !cpuinfo_has_x86_avx512dq() || !cpuinfo_has_x86_avx512bw() || !cpuinfo_has_x86_avx512vl()) { \ |
| 93 | GTEST_SKIP(); \ |
| 94 | } \ |
| 95 | } while (0) |
| 96 | |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 97 | #define TEST_REQUIRES_ARM_NEON \ |
| 98 | do { \ |
| 99 | if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon()) { \ |
| 100 | GTEST_SKIP(); \ |
| 101 | } \ |
| 102 | } while (0) |
| 103 | |
| 104 | #define TEST_REQUIRES_ARM_NEON_FMA \ |
| 105 | do { \ |
| 106 | if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fma()) { \ |
| 107 | GTEST_SKIP(); \ |
| 108 | } \ |
| 109 | } while (0) |
| 110 | |
Marat Dukhan | eecf8fd | 2020-06-09 08:59:37 -0700 | [diff] [blame] | 111 | #define TEST_REQUIRES_ARM_NEON_V8 \ |
| 112 | do { \ |
| 113 | if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_v8()) { \ |
| 114 | GTEST_SKIP(); \ |
| 115 | } \ |
| 116 | } while (0) |
| 117 | |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 118 | #define TEST_REQUIRES_ARM_NEON_FP16_ARITH \ |
| 119 | do { \ |
| 120 | if (!cpuinfo_initialize() || !cpuinfo_has_arm_neon_fp16_arith()) { \ |
| 121 | GTEST_SKIP(); \ |
| 122 | } \ |
| 123 | } while (0) |