]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/jerasure/jerasure/m4/ax_ext.m4
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / erasure-code / jerasure / jerasure / m4 / ax_ext.m4
1 #
2 # Updated by KMG to support -DINTEL_SSE for GF-Complete
3 #
4 # ===========================================================================
5 # http://www.gnu.org/software/autoconf-archive/ax_ext.html
6 # ===========================================================================
7 #
8 # SYNOPSIS
9 #
10 # AX_EXT
11 #
12 # DESCRIPTION
13 #
14 # Find supported SIMD extensions by requesting cpuid. When an SIMD
15 # extension is found, the -m"simdextensionname" is added to SIMD_FLAGS if
16 # compiler supports it. For example, if "sse2" is available, then "-msse2"
17 # is added to SIMD_FLAGS.
18 #
19 # This macro calls:
20 #
21 # AC_SUBST(SIMD_FLAGS)
22 #
23 # And defines:
24 #
25 # HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 / HAVE_SSE4.1 / HAVE_SSE4.2 / HAVE_AVX
26 #
27 # LICENSE
28 #
29 # Copyright (c) 2007 Christophe Tournayre <turn3r@users.sourceforge.net>
30 # Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
31 #
32 # Copying and distribution of this file, with or without modification, are
33 # permitted in any medium without royalty provided the copyright notice
34 # and this notice are preserved. This file is offered as-is, without any
35 # warranty.
36
37 #serial 12
38
39 AC_DEFUN([AX_EXT],
40 [
41 AC_REQUIRE([AC_CANONICAL_HOST])
42
43 case $host_cpu in
44 powerpc*)
45 AC_CACHE_CHECK([whether altivec is supported], [ax_cv_have_altivec_ext],
46 [
47 if test `/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.optional.altivec` != 0; then
48 if test `/usr/sbin/sysctl -n hw.optional.altivec` = 1; then
49 ax_cv_have_altivec_ext=yes
50 fi
51 fi
52 ])
53
54 if test "$ax_cv_have_altivec_ext" = yes; then
55 AC_DEFINE(HAVE_ALTIVEC,,[Support Altivec instructions])
56 AX_CHECK_COMPILE_FLAG(-faltivec, SIMD_FLAGS="$SIMD_FLAGS -faltivec", [])
57 fi
58 ;;
59
60
61 i[[3456]]86*|x86_64*|amd64*)
62
63 AC_REQUIRE([AX_GCC_X86_CPUID])
64 AC_REQUIRE([AX_GCC_X86_AVX_XGETBV])
65
66 AX_GCC_X86_CPUID(0x00000001)
67 ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
68 edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
69
70 AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
71 [
72 ax_cv_have_mmx_ext=no
73 if test "$((0x$edx>>23&0x01))" = 1; then
74 ax_cv_have_mmx_ext=yes
75 fi
76 ])
77
78 AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
79 [
80 ax_cv_have_sse_ext=no
81 if test "$((0x$edx>>25&0x01))" = 1; then
82 ax_cv_have_sse_ext=yes
83 fi
84 ])
85
86 AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
87 [
88 ax_cv_have_sse2_ext=no
89 if test "$((0x$edx>>26&0x01))" = 1; then
90 ax_cv_have_sse2_ext=yes
91 fi
92 ])
93
94 AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
95 [
96 ax_cv_have_sse3_ext=no
97 if test "$((0x$ecx&0x01))" = 1; then
98 ax_cv_have_sse3_ext=yes
99 fi
100 ])
101
102 AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
103 [
104 ax_cv_have_ssse3_ext=no
105 if test "$((0x$ecx>>9&0x01))" = 1; then
106 ax_cv_have_ssse3_ext=yes
107 fi
108 ])
109
110 AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
111 [
112 ax_cv_have_sse41_ext=no
113 if test "$((0x$ecx>>19&0x01))" = 1; then
114 ax_cv_have_sse41_ext=yes
115 fi
116 ])
117
118 AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
119 [
120 ax_cv_have_sse42_ext=no
121 if test "$((0x$ecx>>20&0x01))" = 1; then
122 ax_cv_have_sse42_ext=yes
123 fi
124 ])
125
126 AC_CACHE_CHECK([whether avx is supported by processor], [ax_cv_have_avx_cpu_ext],
127 [
128 ax_cv_have_avx_cpu_ext=no
129 if test "$((0x$ecx>>28&0x01))" = 1; then
130 ax_cv_have_avx_cpu_ext=yes
131 fi
132 ])
133
134 if test x"$ax_cv_have_avx_cpu_ext" = x"yes"; then
135 AX_GCC_X86_AVX_XGETBV(0x00000000)
136
137 xgetbv_eax="0"
138 if test x"$ax_cv_gcc_x86_avx_xgetbv_0x00000000" != x"unknown"; then
139 xgetbv_eax=`echo $ax_cv_gcc_x86_avx_xgetbv_0x00000000 | cut -d ":" -f 1`
140 fi
141
142 AC_CACHE_CHECK([whether avx is supported by operating system], [ax_cv_have_avx_ext],
143 [
144 ax_cv_have_avx_ext=no
145
146 if test "$((0x$ecx>>27&0x01))" = 1; then
147 if test "$((0x$xgetbv_eax&0x6))" = 6; then
148 ax_cv_have_avx_ext=yes
149 fi
150 fi
151 ])
152 if test x"$ax_cv_have_avx_ext" = x"no"; then
153 AC_MSG_WARN([Your processor supports AVX, but your operating system doesn't])
154 fi
155 fi
156
157 if test "$ax_cv_have_mmx_ext" = yes; then
158 AX_CHECK_COMPILE_FLAG(-mmmx, ax_cv_support_mmx_ext=yes, [])
159 if test x"$ax_cv_support_mmx_ext" = x"yes"; then
160 SIMD_FLAGS="$SIMD_FLAGS -mmmx"
161 AC_DEFINE(HAVE_MMX,,[Support mmx instructions])
162 else
163 AC_MSG_WARN([Your processor supports mmx instructions but not your compiler, can you try another compiler?])
164 fi
165 fi
166
167 if test "$ac_cv_sizeof_long" -eq 8; then
168 SIMD_FLAGS="$SIMD_FLAGS -DARCH_64"
169 fi
170
171 if test "$ax_cv_have_sse_ext" = yes; then
172 AX_CHECK_COMPILE_FLAG(-msse, ax_cv_support_sse_ext=yes, [])
173 if test x"$ax_cv_support_sse_ext" = x"yes"; then
174 SIMD_FLAGS="$SIMD_FLAGS -msse -DINTEL_SSE"
175 AC_DEFINE(HAVE_SSE,,[Support SSE (Streaming SIMD Extensions) instructions])
176 else
177 AC_MSG_WARN([Your processor supports sse instructions but not your compiler, can you try another compiler?])
178 fi
179 fi
180
181 if test "$ax_cv_have_sse2_ext" = yes; then
182 AX_CHECK_COMPILE_FLAG(-msse2, ax_cv_support_sse2_ext=yes, [])
183 if test x"$ax_cv_support_sse2_ext" = x"yes"; then
184 SIMD_FLAGS="$SIMD_FLAGS -msse2 -DINTEL_SSE2"
185 AC_DEFINE(HAVE_SSE2,,[Support SSE2 (Streaming SIMD Extensions 2) instructions])
186 else
187 AC_MSG_WARN([Your processor supports sse2 instructions but not your compiler, can you try another compiler?])
188 fi
189 fi
190
191 if test "$ax_cv_have_sse3_ext" = yes; then
192 AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
193 if test x"$ax_cv_support_sse3_ext" = x"yes"; then
194 SIMD_FLAGS="$SIMD_FLAGS -msse3 -DINTEL_SSE3"
195 AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions])
196 else
197 AC_MSG_WARN([Your processor supports sse3 instructions but not your compiler, can you try another compiler?])
198 fi
199 fi
200
201 if test "$ax_cv_have_ssse3_ext" = yes; then
202 AX_CHECK_COMPILE_FLAG(-mssse3, ax_cv_support_ssse3_ext=yes, [])
203 if test x"$ax_cv_support_ssse3_ext" = x"yes"; then
204 SIMD_FLAGS="$SIMD_FLAGS -mssse3"
205 AC_DEFINE(HAVE_SSSE3,,[Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
206 else
207 AC_MSG_WARN([Your processor supports ssse3 instructions but not your compiler, can you try another compiler?])
208 fi
209 fi
210
211 if test "$ax_cv_have_sse41_ext" = yes; then
212 AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
213 if test x"$ax_cv_support_sse41_ext" = x"yes"; then
214 SIMD_FLAGS="$SIMD_FLAGS -msse4.1 -DINTEL_SSE4"
215 AC_DEFINE(HAVE_SSE4_1,,[Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions])
216 else
217 AC_MSG_WARN([Your processor supports sse4.1 instructions but not your compiler, can you try another compiler?])
218 fi
219 fi
220
221 if test "$ax_cv_have_sse42_ext" = yes; then
222 AX_CHECK_COMPILE_FLAG(-msse4.2, ax_cv_support_sse42_ext=yes, [])
223 if test x"$ax_cv_support_sse42_ext" = x"yes"; then
224 SIMD_FLAGS="$SIMD_FLAGS -msse4.2 -DINTEL_SSE4"
225 AC_DEFINE(HAVE_SSE4_2,,[Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions])
226 else
227 AC_MSG_WARN([Your processor supports sse4.2 instructions but not your compiler, can you try another compiler?])
228 fi
229 fi
230
231 if test "$ax_cv_have_avx_ext" = yes; then
232 AX_CHECK_COMPILE_FLAG(-mavx, ax_cv_support_avx_ext=yes, [])
233 if test x"$ax_cv_support_avx_ext" = x"yes"; then
234 SIMD_FLAGS="$SIMD_FLAGS -mavx"
235 AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
236 else
237 AC_MSG_WARN([Your processor supports avx instructions but not your compiler, can you try another compiler?])
238 fi
239 fi
240
241 ;;
242 esac
243
244 AC_SUBST(SIMD_FLAGS)
245 ])