summaryrefslogtreecommitdiffstats
path: root/third_party/msgpack/include/msgpack/predef/hardware/simd.h
blob: 30489d22b949694431e2e33ca99991ac3d779d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
Copyright Charly Chevalier 2015
Copyright Joel Falcou 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/

#include <msgpack/predef/hardware/simd/x86.h>
#include <msgpack/predef/hardware/simd/x86_amd.h>
#include <msgpack/predef/hardware/simd/arm.h>
#include <msgpack/predef/hardware/simd/ppc.h>

#ifndef MSGPACK_PREDEF_HARDWARE_SIMD_H
#define MSGPACK_PREDEF_HARDWARE_SIMD_H

#include <msgpack/predef/version_number.h>

/*`
 [section Using the `MSGPACK_HW_SIMD_*` predefs]
 [include ../doc/hardware_simd.qbk]
 [endsect]

 [/ --------------------------- ]

 [section `MSGPACK_HW_SIMD_*`]

 [heading `MSGPACK_HW_SIMD`]

 The SIMD extension detected for a specific architectures.
 Version number depends on the detected extension.

 [table
     [[__predef_symbol__] [__predef_version__]]

     [[`MSGPACK_HW_SIMD_X86_AVAILABLE`] [__predef_detection__]]
     [[`MSGPACK_HW_SIMD_X86_AMD_AVAILABLE`] [__predef_detection__]]
     [[`MSGPACK_HW_SIMD_ARM_AVAILABLE`] [__predef_detection__]]
     [[`MSGPACK_HW_SIMD_PPC_AVAILABLE`] [__predef_detection__]]
     ]

 [include ../include/msgpack/predef/hardware/simd/x86.h]
 [include ../include/msgpack/predef/hardware/simd/x86_amd.h]
 [include ../include/msgpack/predef/hardware/simd/arm.h]
 [include ../include/msgpack/predef/hardware/simd/ppc.h]

 [endsect]

 [/ --------------------------- ]

 [section `MSGPACK_HW_SIMD_X86_*_VERSION`]
 [include ../include/msgpack/predef/hardware/simd/x86/versions.h]
 [endsect]

 [section `MSGPACK_HW_SIMD_X86_AMD_*_VERSION`]
 [include ../include/msgpack/predef/hardware/simd/x86_amd/versions.h]
 [endsect]

 [section `MSGPACK_HW_SIMD_ARM_*_VERSION`]
 [include ../include/msgpack/predef/hardware/simd/arm/versions.h]
 [endsect]

 [section `MSGPACK_HW_SIMD_PPC_*_VERSION`]
 [include ../include/msgpack/predef/hardware/simd/ppc/versions.h]
 [endsect]

 */

// We check if SIMD extension of multiples architectures have been detected,
// if yes, then this is an error!
//
// NOTE: _X86_AMD implies _X86, so there is no need to check for it here!
//
#if defined(MSGPACK_HW_SIMD_ARM_AVAILABLE) && defined(MSGPACK_HW_SIMD_PPC_AVAILABLE) ||\
    defined(MSGPACK_HW_SIMD_ARM_AVAILABLE) && defined(MSGPACK_HW_SIMD_X86_AVAILABLE) ||\
    defined(MSGPACK_HW_SIMD_PPC_AVAILABLE) && defined(MSGPACK_HW_SIMD_X86_AVAILABLE)
#   error "Multiple SIMD architectures detected, this cannot happen!"
#endif

#if defined(MSGPACK_HW_SIMD_X86_AVAILABLE) && defined(MSGPACK_HW_SIMD_X86_AMD_AVAILABLE)
    // If both standard _X86 and _X86_AMD are available,
    // then take the biggest version of the two!
#   if MSGPACK_HW_SIMD_X86 >= MSGPACK_HW_SIMD_X86_AMD
#      define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_X86
#   else
#      define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_X86_AMD
#   endif
#endif

#if !defined(MSGPACK_HW_SIMD)
    // At this point, only one of these two is defined
#   if defined(MSGPACK_HW_SIMD_X86_AVAILABLE)
#      define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_X86
#   endif
#   if defined(MSGPACK_HW_SIMD_X86_AMD_AVAILABLE)
#      define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_X86_AMD
#   endif
#endif

#if defined(MSGPACK_HW_SIMD_ARM_AVAILABLE)
#   define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_ARM
#endif

#if defined(MSGPACK_HW_SIMD_PPC_AVAILABLE)
#   define MSGPACK_HW_SIMD MSGPACK_HW_SIMD_PPC
#endif

#if defined(MSGPACK_HW_SIMD)
#   define MSGPACK_HW_SIMD_AVAILABLE
#else
#   define MSGPACK_HW_SIMD MSGPACK_VERSION_NUMBER_NOT_AVAILABLE
#endif

#define MSGPACK_HW_SIMD_NAME "Hardware SIMD"

#endif

#include <msgpack/predef/detail/test.h>
MSGPACK_PREDEF_DECLARE_TEST(MSGPACK_HW_SIMD, MSGPACK_HW_SIMD_NAME)