|
1 | | -#if NET |
| 1 | +#if NET |
2 | 2 | using System.Runtime.Intrinsics.X86; |
3 | 3 | using System.Runtime.Intrinsics.Arm; |
4 | | -#endif |
5 | | - |
6 | | -namespace BitFaster.Caching |
7 | | -{ |
8 | | - /// <summary> |
9 | | - /// Represents a marker interface to enable instruction set hardware intrinsics. |
10 | | - /// </summary> |
11 | | - public interface IsaProbe |
12 | | - { |
13 | | - /// <summary> |
14 | | - /// Gets a value indicating whether AVX2 is supported. |
15 | | - /// </summary> |
| 4 | +#endif |
| 5 | + |
| 6 | +namespace BitFaster.Caching |
| 7 | +{ |
| 8 | + /// <summary> |
| 9 | + /// Represents a marker interface to enable instruction set hardware intrinsics. |
| 10 | + /// </summary> |
| 11 | + public interface IsaProbe |
| 12 | + { |
| 13 | + /// <summary> |
| 14 | + /// Gets a value indicating whether AVX2 is supported. |
| 15 | + /// </summary> |
16 | 16 | bool IsAvx2Supported { get; } |
17 | 17 |
|
18 | 18 | #if NET |
19 | | - /// <summary> |
20 | | - /// Gets a value indicating whether Arm64 is supported. |
21 | | - /// </summary> |
22 | | - bool IsArm64Supported { get => false; } |
23 | | -#endif |
24 | | - } |
25 | | - |
26 | | - /// <summary> |
27 | | - /// Detect support for hardware instructions via intrinsics. |
28 | | - /// </summary> |
29 | | - public readonly struct DetectIsa : IsaProbe |
30 | | - { |
31 | | -#if NET |
32 | | - /// <inheritdoc/> |
33 | | - public bool IsAvx2Supported => Avx2.IsSupported; |
34 | | -#else |
35 | | - /// <inheritdoc/> |
| 19 | + /// <summary> |
| 20 | + /// Gets a value indicating whether Arm64 is supported. |
| 21 | + /// </summary> |
| 22 | + bool IsArm64Supported { get => false; } |
| 23 | +#endif |
| 24 | + } |
| 25 | + |
| 26 | + /// <summary> |
| 27 | + /// Detect support for hardware instructions via intrinsics. |
| 28 | + /// </summary> |
| 29 | + public readonly struct DetectIsa : IsaProbe |
| 30 | + { |
| 31 | +#if NET |
| 32 | + /// <inheritdoc/> |
| 33 | + public bool IsAvx2Supported => Avx2.IsSupported; |
| 34 | +#else |
| 35 | + /// <inheritdoc/> |
36 | 36 | public bool IsAvx2Supported => false; |
37 | | -#endif |
38 | | - |
| 37 | +#endif |
| 38 | + |
39 | 39 | #if NET |
40 | 40 | /// <inheritdoc/> |
41 | 41 | public bool IsArm64Supported => AdvSimd.Arm64.IsSupported; |
42 | 42 | #else |
43 | 43 | /// <inheritdoc/> |
44 | 44 | public bool IsArm64Supported => false; |
45 | | -#endif |
46 | | - } |
47 | | - |
48 | | - /// <summary> |
49 | | - /// Force disable hardware instructions via intrinsics. |
50 | | - /// </summary> |
51 | | - public readonly struct DisableHardwareIntrinsics : IsaProbe |
52 | | - { |
53 | | - /// <inheritdoc/> |
| 45 | +#endif |
| 46 | + } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Force disable hardware instructions via intrinsics. |
| 50 | + /// </summary> |
| 51 | + public readonly struct DisableHardwareIntrinsics : IsaProbe |
| 52 | + { |
| 53 | + /// <inheritdoc/> |
54 | 54 | public bool IsAvx2Supported => false; |
55 | 55 |
|
56 | 56 | /// <inheritdoc/> |
57 | | - public bool IsArm64Supported => false; |
58 | | - } |
59 | | -} |
| 57 | + public bool IsArm64Supported => false; |
| 58 | + } |
| 59 | +} |
0 commit comments