Vector Optimized Library of Kernels  2.0
Architecture-tuned implementations of math kernels
volk_common.h
Go to the documentation of this file.
1 #ifndef INCLUDED_LIBVOLK_COMMON_H
2 #define INCLUDED_LIBVOLK_COMMON_H
3 
5 // Cross-platform attribute macros
7 #if defined __GNUC__
8 # define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x)))
9 # define __VOLK_ATTR_UNUSED __attribute__((unused))
10 # define __VOLK_ATTR_INLINE __attribute__((always_inline))
11 # define __VOLK_ATTR_DEPRECATED __attribute__((deprecated))
12 # define __VOLK_ASM __asm__
13 # define __VOLK_VOLATILE __volatile__
14 # if __GNUC__ >= 4
15 # define __VOLK_ATTR_EXPORT __attribute__((visibility("default")))
16 # define __VOLK_ATTR_IMPORT __attribute__((visibility("default")))
17 # else
18 # define __VOLK_ATTR_EXPORT
19 # define __VOLK_ATTR_IMPORT
20 # endif
21 # define __VOLK_PREFETCH(addr) __builtin_prefetch(addr)
22 #elif _MSC_VER
23 # define __VOLK_ATTR_ALIGNED(x) __declspec(align(x))
24 # define __VOLK_ATTR_UNUSED
25 # define __VOLK_ATTR_INLINE __forceinline
26 # define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
27 # define __VOLK_ATTR_EXPORT __declspec(dllexport)
28 # define __VOLK_ATTR_IMPORT __declspec(dllimport)
29 # define __VOLK_PREFETCH(addr)
30 # define __VOLK_ASM __asm
31 # define __VOLK_VOLATILE
32 #else
33 # define __VOLK_ATTR_ALIGNED(x)
34 # define __VOLK_ATTR_UNUSED
35 # define __VOLK_ATTR_INLINE
36 # define __VOLK_ATTR_DEPRECATED
37 # define __VOLK_ATTR_EXPORT
38 # define __VOLK_ATTR_IMPORT
39 # define __VOLK_PREFETCH(addr)
40 # define __VOLK_ASM __asm__
41 # define __VOLK_VOLATILE __volatile__
42 #endif
43 
45 // Ignore annoying warnings in MSVC
47 #if defined(_MSC_VER)
48 # pragma warning(disable: 4244) //'conversion' conversion from 'type1' to 'type2', possible loss of data
49 # pragma warning(disable: 4305) //'identifier' : truncation from 'type1' to 'type2'
50 #endif
51 
53 // C-linkage declaration macros
54 // FIXME: due to the usage of complex.h, require gcc for c-linkage
56 #if defined(__cplusplus) && (__GNUC__)
57 # define __VOLK_DECL_BEGIN extern "C" {
58 # define __VOLK_DECL_END }
59 #else
60 # define __VOLK_DECL_BEGIN
61 # define __VOLK_DECL_END
62 #endif
63 
65 // Define VOLK_API for library symbols
66 // http://gcc.gnu.org/wiki/Visibility
68 #ifdef volk_EXPORTS
69 # define VOLK_API __VOLK_ATTR_EXPORT
70 #else
71 # define VOLK_API __VOLK_ATTR_IMPORT
72 #endif
73 
75 // The bit128 union used by some
77 #include <inttypes.h>
78 
79 #ifdef LV_HAVE_SSE
80 #ifdef _WIN32
81 #include <intrin.h>
82 #else
83 #include <x86intrin.h>
84 #endif
85 #endif
86 
87 union bit128{
88  uint8_t i8[16];
89  uint16_t i16[8];
90  uint32_t i[4];
91  float f[4];
92  double d[2];
93 
94  #ifdef LV_HAVE_SSE
95  __m128 float_vec;
96  #endif
97 
98  #ifdef LV_HAVE_SSE2
99  __m128i int_vec;
100  __m128d double_vec;
101  #endif
102 };
103 
104 union bit256{
105  uint8_t i8[32];
106  uint16_t i16[16];
107  uint32_t i[8];
108  float f[8];
109  double d[4];
110 
111  #ifdef LV_HAVE_AVX
112  __m256 float_vec;
113  __m256i int_vec;
114  __m256d double_vec;
115  #endif
116 };
117 
118 #define bit128_p(x) ((union bit128 *)(x))
119 #define bit256_p(x) ((union bit256 *)(x))
120 
121 #endif /*INCLUDED_LIBVOLK_COMMON_H*/
uint8_t i8[16]
Definition: volk_common.h:88
uint16_t i16[8]
Definition: volk_common.h:89
__m256d double_vec
Definition: volk_common.h:114
__m256i int_vec
Definition: volk_common.h:113
__m128i int_vec
Definition: volk_common.h:99
__m128d double_vec
Definition: volk_common.h:100
Definition: volk_common.h:104
__m128 float_vec
Definition: volk_common.h:95
__m256 float_vec
Definition: volk_common.h:112
double d[2]
Definition: volk_common.h:92
float f[4]
Definition: volk_common.h:91
Definition: volk_common.h:87
uint32_t i[4]
Definition: volk_common.h:90