Browse code

update bam_tally, mostly to fix memory leaks but we are also moving towards a decent indel realigner

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/gmapR@89723 bc3139a8-67e5-0310-9ffc-ced21a209358

Michael Lawrence authored on 30/04/2014 17:04:17
Showing 28 changed files

... ...
@@ -92,8 +92,13 @@ DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
92 92
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
93 93
 am__aclocal_m4_deps = $(top_srcdir)/config/acx_mmap_fixed.m4 \
94 94
 	$(top_srcdir)/config/acx_mmap_variable.m4 \
95
-	$(top_srcdir)/config/expand.m4 $(top_srcdir)/config/fopen.m4 \
96
-	$(top_srcdir)/config/libtool.m4 \
95
+	$(top_srcdir)/config/asm-bsr.m4 \
96
+	$(top_srcdir)/config/ax_check_compile_flag.m4 \
97
+	$(top_srcdir)/config/ax_ext.m4 \
98
+	$(top_srcdir)/config/ax_gcc_x86_avx_xgetbv.m4 \
99
+	$(top_srcdir)/config/ax_gcc_x86_cpuid.m4 \
100
+	$(top_srcdir)/config/builtin.m4 $(top_srcdir)/config/expand.m4 \
101
+	$(top_srcdir)/config/fopen.m4 $(top_srcdir)/config/libtool.m4 \
97 102
 	$(top_srcdir)/config/ltoptions.m4 \
98 103
 	$(top_srcdir)/config/ltsugar.m4 \
99 104
 	$(top_srcdir)/config/ltversion.m4 \
... ...
@@ -101,6 +106,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/acx_mmap_fixed.m4 \
101 106
 	$(top_srcdir)/config/madvise-flags.m4 \
102 107
 	$(top_srcdir)/config/mmap-flags.m4 \
103 108
 	$(top_srcdir)/config/pagesize.m4 $(top_srcdir)/config/perl.m4 \
109
+	$(top_srcdir)/config/sse2_shift_defect.m4 \
104 110
 	$(top_srcdir)/config/struct-stat64.m4 \
105 111
 	$(top_srcdir)/configure.ac
106 112
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
... ...
@@ -287,6 +293,7 @@ SAMTOOLS_LIBS = @SAMTOOLS_LIBS@
287 293
 SED = @SED@
288 294
 SET_MAKE = @SET_MAKE@
289 295
 SHELL = @SHELL@
296
+SIMD_FLAGS = @SIMD_FLAGS@
290 297
 STATIC_LDFLAG = @STATIC_LDFLAG@
291 298
 STRIP = @STRIP@
292 299
 UNIQSCAN = @UNIQSCAN@
... ...
@@ -1185,6 +1185,12 @@ AC_SUBST([am__untar])
1185 1185
 
1186 1186
 m4_include([config/acx_mmap_fixed.m4])
1187 1187
 m4_include([config/acx_mmap_variable.m4])
1188
+m4_include([config/asm-bsr.m4])
1189
+m4_include([config/ax_check_compile_flag.m4])
1190
+m4_include([config/ax_ext.m4])
1191
+m4_include([config/ax_gcc_x86_avx_xgetbv.m4])
1192
+m4_include([config/ax_gcc_x86_cpuid.m4])
1193
+m4_include([config/builtin.m4])
1188 1194
 m4_include([config/expand.m4])
1189 1195
 m4_include([config/fopen.m4])
1190 1196
 m4_include([config/libtool.m4])
... ...
@@ -1196,4 +1202,5 @@ m4_include([config/madvise-flags.m4])
1196 1202
 m4_include([config/mmap-flags.m4])
1197 1203
 m4_include([config/pagesize.m4])
1198 1204
 m4_include([config/perl.m4])
1205
+m4_include([config/sse2_shift_defect.m4])
1199 1206
 m4_include([config/struct-stat64.m4])
1200 1207
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+
2
+AC_DEFUN([ACX_ASM_BSR], [
3
+AC_LANG_SAVE
4
+AC_LANG(C)
5
+
6
+AC_MSG_CHECKING(for bsr instruction in assembly)
7
+AC_COMPILE_IFELSE(
8
+  [AC_LANG_PROGRAM([[ ]],
9
+                   [[int msb; unsigned int x = rand(); asm("bsr %1,%0" : "=r"(msb) : "r"(x));]])],
10
+  [AC_MSG_RESULT(yes)
11
+   AC_DEFINE([HAVE_ASM_BSR],[1],[Define to 1 if bsr command is available in assembly])],
12
+  [AC_MSG_RESULT(no)])
13
+
14
+AC_LANG_RESTORE
15
+])
16
+
0 17
new file mode 100644
... ...
@@ -0,0 +1,72 @@
1
+# ===========================================================================
2
+#   http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
3
+# ===========================================================================
4
+#
5
+# SYNOPSIS
6
+#
7
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
8
+#
9
+# DESCRIPTION
10
+#
11
+#   Check whether the given FLAG works with the current language's compiler
12
+#   or gives an error.  (Warnings, however, are ignored)
13
+#
14
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15
+#   success/failure.
16
+#
17
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
18
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
19
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
20
+#   force the compiler to issue an error when a bad flag is given.
21
+#
22
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
23
+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
24
+#
25
+# LICENSE
26
+#
27
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
28
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
29
+#
30
+#   This program is free software: you can redistribute it and/or modify it
31
+#   under the terms of the GNU General Public License as published by the
32
+#   Free Software Foundation, either version 3 of the License, or (at your
33
+#   option) any later version.
34
+#
35
+#   This program is distributed in the hope that it will be useful, but
36
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
37
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
38
+#   Public License for more details.
39
+#
40
+#   You should have received a copy of the GNU General Public License along
41
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
42
+#
43
+#   As a special exception, the respective Autoconf Macro's copyright owner
44
+#   gives unlimited permission to copy, distribute and modify the configure
45
+#   scripts that are the output of Autoconf when processing the Macro. You
46
+#   need not follow the terms of the GNU General Public License when using
47
+#   or distributing such scripts, even though portions of the text of the
48
+#   Macro appear in them. The GNU General Public License (GPL) does govern
49
+#   all other use of the material that constitutes the Autoconf Macro.
50
+#
51
+#   This special exception to the GPL applies to versions of the Autoconf
52
+#   Macro released by the Autoconf Archive. When you make and distribute a
53
+#   modified version of the Autoconf Macro, you may extend this special
54
+#   exception to the GPL to apply to your modified version as well.
55
+
56
+#serial 2
57
+
58
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
59
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
60
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
61
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
62
+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
63
+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
64
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
65
+    [AS_VAR_SET(CACHEVAR,[yes])],
66
+    [AS_VAR_SET(CACHEVAR,[no])])
67
+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
68
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
69
+  [m4_default([$2], :)],
70
+  [m4_default([$3], :)])
71
+AS_VAR_POPDEF([CACHEVAR])dnl
72
+])dnl AX_CHECK_COMPILE_FLAGS
0 73
new file mode 100644
... ...
@@ -0,0 +1,346 @@
1
+# ===========================================================================
2
+#          http://www.gnu.org/software/autoconf-archive/ax_ext.html
3
+# ===========================================================================
4
+#
5
+# SYNOPSIS
6
+#
7
+#   AX_EXT
8
+#
9
+# DESCRIPTION
10
+#
11
+#   Find supported SIMD extensions by requesting cpuid. When an SIMD
12
+#   extension is found, the -m"simdextensionname" is added to SIMD_FLAGS if
13
+#   compiler supports it. For example, if "sse2" is available, then "-msse2"
14
+#   is added to SIMD_FLAGS.
15
+#
16
+#   This macro calls:
17
+#
18
+#     AC_SUBST(SIMD_FLAGS)
19
+#
20
+#   And defines:
21
+#
22
+#     HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 / HAVE_SSE4.1 / HAVE_SSE4.2 / HAVE_AVX
23
+#
24
+# LICENSE
25
+#
26
+#   Copyright (c) 2007 Christophe Tournayre <turn3r@users.sourceforge.net>
27
+#   Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
28
+#
29
+#   Copying and distribution of this file, with or without modification, are
30
+#   permitted in any medium without royalty provided the copyright notice
31
+#   and this notice are preserved. This file is offered as-is, without any
32
+#   warranty.
33
+
34
+#serial 13
35
+
36
+AC_DEFUN([AX_EXT],
37
+[
38
+  AC_REQUIRE([AC_CANONICAL_HOST])
39
+
40
+  case $host_cpu in
41
+    powerpc*)
42
+      AC_CACHE_CHECK([whether altivec is enabled and supported], [ax_cv_have_altivec_ext],
43
+          [
44
+            if test `/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.optional.altivec` != 0; then
45
+                if test `/usr/sbin/sysctl -n hw.optional.altivec` = 1; then
46
+                  ax_cv_have_altivec_ext=yes
47
+                fi
48
+            fi
49
+          ])
50
+
51
+          if test "$ax_cv_have_altivec_ext" = yes; then
52
+            AC_DEFINE(HAVE_ALTIVEC,1,[Define to 1 if you support Altivec instructions])
53
+            AX_CHECK_COMPILE_FLAG(-faltivec, SIMD_FLAGS="$SIMD_FLAGS -faltivec", [])
54
+          fi
55
+    ;;
56
+
57
+
58
+    i[[3456]]86*|x86_64*|amd64*)
59
+
60
+      AC_REQUIRE([AX_GCC_X86_CPUID])
61
+      AC_REQUIRE([AX_GCC_X86_AVX_XGETBV])
62
+
63
+      AX_GCC_X86_CPUID(0x00000001)
64
+      ecx=0
65
+      edx=0
66
+      if test "$ax_cv_gcc_x86_cpuid_0x00000001" != "unknown";
67
+      then
68
+        ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
69
+        edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
70
+      fi
71
+
72
+      AC_CACHE_CHECK([whether mmx is enabled and supported], [ax_cv_have_mmx_ext],
73
+      [
74
+        ax_cv_have_mmx_ext=no
75
+        if test "$((0x$edx>>23&0x01))" = 1; then
76
+          ax_cv_have_mmx_ext=yes
77
+        fi
78
+      ])
79
+
80
+      AC_CACHE_CHECK([whether sse is enabled and supported], [ax_cv_have_sse_ext],
81
+      [
82
+        ax_cv_have_sse_ext=no
83
+        if test "$((0x$edx>>25&0x01))" = 1; then
84
+          ax_cv_have_sse_ext=yes
85
+        fi
86
+      ])
87
+
88
+      AC_CACHE_CHECK([whether sse2 is enabled and supported], [ax_cv_have_sse2_ext],
89
+      [
90
+        ax_cv_have_sse2_ext=no
91
+        if test "$ax_cv_want_sse2_ext" = yes; then
92
+          if test "$((0x$edx>>26&0x01))" = 1; then
93
+            ax_cv_have_sse2_ext=yes
94
+          fi
95
+        fi
96
+      ])
97
+
98
+      AC_CACHE_CHECK([whether sse3 is enabled and supported], [ax_cv_have_sse3_ext],
99
+      [
100
+        ax_cv_have_sse3_ext=no
101
+        if test "$((0x$ecx&0x01))" = 1; then
102
+          ax_cv_have_sse3_ext=yes
103
+        fi
104
+      ])
105
+
106
+      AC_CACHE_CHECK([whether ssse3 is enabled and supported], [ax_cv_have_ssse3_ext],
107
+      [
108
+        ax_cv_have_ssse3_ext=no
109
+        if test "$((0x$ecx>>9&0x01))" = 1; then
110
+          ax_cv_have_ssse3_ext=yes
111
+        fi
112
+      ])
113
+
114
+      AC_CACHE_CHECK([whether sse4.1 is enabled and supported], [ax_cv_have_sse41_ext],
115
+      [
116
+        ax_cv_have_sse41_ext=no
117
+        if test "$ax_cv_want_sse41_ext" = yes; then
118
+          if test "$((0x$ecx>>19&0x01))" = 1; then
119
+            ax_cv_have_sse41_ext=yes
120
+          fi
121
+        fi
122
+      ])
123
+
124
+      AC_CACHE_CHECK([whether sse4.2 is enabled and supported], [ax_cv_have_sse42_ext],
125
+      [
126
+        ax_cv_have_sse42_ext=no
127
+        if test "$((0x$ecx>>20&0x01))" = 1; then
128
+          ax_cv_have_sse42_ext=yes
129
+        fi
130
+      ])
131
+
132
+      AC_CACHE_CHECK([whether avx is enabled and supported by processor], [ax_cv_have_avx_cpu_ext],
133
+      [
134
+        ax_cv_have_avx_cpu_ext=no
135
+        if test "$((0x$ecx>>28&0x01))" = 1; then
136
+          ax_cv_have_avx_cpu_ext=yes
137
+        fi
138
+      ])
139
+
140
+      if test x"$ax_cv_have_avx_cpu_ext" = x"yes"; then
141
+        AX_GCC_X86_AVX_XGETBV(0x00000000)
142
+
143
+        xgetbv_eax="0"
144
+        if test x"$ax_cv_gcc_x86_avx_xgetbv_0x00000000" != x"unknown"; then
145
+          xgetbv_eax=`echo $ax_cv_gcc_x86_avx_xgetbv_0x00000000 | cut -d ":" -f 1`
146
+        fi
147
+
148
+        AC_CACHE_CHECK([whether avx is supported by operating system], [ax_cv_have_avx_ext],
149
+        [
150
+          ax_cv_have_avx_ext=no
151
+
152
+          if test "$((0x$ecx>>27&0x01))" = 1; then
153
+            if test "$((0x$xgetbv_eax&0x6))" = 6; then
154
+              ax_cv_have_avx_ext=yes
155
+            fi
156
+          fi
157
+        ])
158
+        if test x"$ax_cv_have_avx_ext" = x"no"; then
159
+          AC_MSG_WARN([Your processor supports AVX, but your operating system doesn't])
160
+        fi
161
+      fi
162
+
163
+
164
+      AC_CACHE_CHECK([whether popcnt is enabled and supported], [ax_cv_have_popcnt_ext],
165
+      [
166
+        ax_cv_have_popcnt_ext=no
167
+        if test "$((0x$ecx>>23&0x01))" = 1; then
168
+          ax_cv_have_popcnt_ext=yes
169
+        fi
170
+      ])
171
+
172
+
173
+      AX_GCC_X86_CPUID(0x80000001)
174
+      ecx=`echo $ax_cv_gcc_x86_cpuid_0x80000001 | cut -d ":" -f 3`
175
+      edx=`echo $ax_cv_gcc_x86_cpuid_0x80000001 | cut -d ":" -f 4`
176
+
177
+      AC_CACHE_CHECK([whether lzcnt is enabled and supported], [ax_cv_have_lzcnt_ext],
178
+      [
179
+        ax_cv_have_lzcnt_ext=no
180
+        if test "$((0x$ecx>>5&0x01))" = 1; then
181
+          ax_cv_have_lzcnt_ext=yes
182
+        fi
183
+      ])
184
+
185
+
186
+      AX_GCC_X86_CPUID(0x00000007)
187
+      ebx=`echo $ax_cv_gcc_x86_cpuid_0x00000007 | cut -d ":" -f 2`
188
+      ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000007 | cut -d ":" -f 3`
189
+      edx=`echo $ax_cv_gcc_x86_cpuid_0x00000007 | cut -d ":" -f 4`
190
+
191
+      AC_CACHE_CHECK([whether avx2 is enabled and supported], [ax_cv_have_avx2_ext],
192
+      [
193
+        ax_cv_have_avx2_ext=no
194
+        if test "$((0x$ebx>>5&0x01))" = 1; then
195
+          ax_cv_have_avx2_ext=yes
196
+        fi
197
+      ])
198
+
199
+      AC_CACHE_CHECK([whether bmi1 is enabled and supported], [ax_cv_have_bmi1_ext],
200
+      [
201
+        ax_cv_have_bmi1_ext=no
202
+        if test "$((0x$ebx>>3&0x01))" = 1; then
203
+          ax_cv_have_bmi1_ext=yes
204
+        fi
205
+      ])
206
+
207
+      AC_CACHE_CHECK([whether bmi2 is enabled and supported], [ax_cv_have_bmi2_ext],
208
+      [
209
+        ax_cv_have_bmi2_ext=no
210
+        if test "$((0x$ebx>>8&0x01))" = 1; then
211
+          ax_cv_have_bmi2_ext=yes
212
+        fi
213
+      ])
214
+
215
+
216
+
217
+      if test "$ax_cv_have_mmx_ext" = yes; then
218
+        AX_CHECK_COMPILE_FLAG(-mmmx, ax_cv_support_mmx_ext=yes, [])
219
+        if test x"$ax_cv_support_mmx_ext" = x"yes"; then
220
+          SIMD_FLAGS="$SIMD_FLAGS -mmmx"
221
+          AC_DEFINE(HAVE_MMX,1,[Define to 1 if you support mmx instructions])
222
+        else
223
+          AC_MSG_WARN([Your processor supports mmx instructions but not your compiler.  Can you try another compiler or update yours?])
224
+        fi
225
+      fi
226
+
227
+      if test "$ax_cv_have_sse_ext" = yes; then
228
+        AX_CHECK_COMPILE_FLAG(-msse, ax_cv_support_sse_ext=yes, [])
229
+        if test x"$ax_cv_support_sse_ext" = x"yes"; then
230
+          SIMD_FLAGS="$SIMD_FLAGS -msse"
231
+          AC_DEFINE(HAVE_SSE,1,[Define to 1 if you support SSE (Streaming SIMD Extensions) instructions])
232
+        else
233
+          AC_MSG_WARN([Your processor supports sse instructions but not your compiler.  Can you try another compiler or update yours?])
234
+        fi
235
+      fi
236
+
237
+      if test "$ax_cv_have_sse2_ext" = yes; then
238
+	AX_CHECK_COMPILE_FLAG(-msse2, ax_cv_support_sse2_ext=yes, [])
239
+	if test x"$ax_cv_support_sse2_ext" = x"yes"; then
240
+	  SIMD_FLAGS="$SIMD_FLAGS -msse2"
241
+	  AC_DEFINE(HAVE_SSE2,1,[Define to 1 if you support SSE2 (Streaming SIMD Extensions 2) instructions])
242
+	else
243
+	  AC_MSG_WARN([Your processor supports sse2 instructions but not your compiler.  Can you try another compiler or update yours?])
244
+	fi
245
+      fi
246
+
247
+      if test "$ax_cv_have_sse3_ext" = yes; then
248
+        AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, [])
249
+        if test x"$ax_cv_support_sse3_ext" = x"yes"; then
250
+          SIMD_FLAGS="$SIMD_FLAGS -msse3"
251
+          AC_DEFINE(HAVE_SSE3,1,[Define to 1 if you support SSE3 (Streaming SIMD Extensions 3) instructions])
252
+        else
253
+          AC_MSG_WARN([Your processor supports sse3 instructions but not your compiler.  Can you try another compiler or update yours?])
254
+        fi
255
+      fi
256
+
257
+      if test "$ax_cv_have_ssse3_ext" = yes; then
258
+        AX_CHECK_COMPILE_FLAG(-mssse3, ax_cv_support_ssse3_ext=yes, [])
259
+        if test x"$ax_cv_support_ssse3_ext" = x"yes"; then
260
+          SIMD_FLAGS="$SIMD_FLAGS -mssse3"
261
+          AC_DEFINE(HAVE_SSSE3,1,[Define to 1 if you support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
262
+        else
263
+          AC_MSG_WARN([Your processor supports ssse3 instructions but not your compiler.  Can you try another compiler or update yours?])
264
+        fi
265
+      fi
266
+
267
+      if test "$ax_cv_have_sse41_ext" = yes; then
268
+	AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, [])
269
+	if test x"$ax_cv_support_sse41_ext" = x"yes"; then
270
+	  SIMD_FLAGS="$SIMD_FLAGS -msse4.1"
271
+	  AC_DEFINE(HAVE_SSE4_1,1,[Define to 1 if you support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
272
+	else
273
+	  AC_MSG_WARN([Your processor supports sse4.1 instructions but not your compiler.  Can you try another compiler or update yours?])
274
+	fi
275
+      fi
276
+
277
+      if test "$ax_cv_have_sse42_ext" = yes; then
278
+        AX_CHECK_COMPILE_FLAG(-msse4.2, ax_cv_support_sse42_ext=yes, [])
279
+        if test x"$ax_cv_support_sse42_ext" = x"yes"; then
280
+          SIMD_FLAGS="$SIMD_FLAGS -msse4.2"
281
+          AC_DEFINE(HAVE_SSE4_2,1,[Define to 1 if you support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
282
+        else
283
+          AC_MSG_WARN([Your processor supports sse4.2 instructions but not your compiler.  Can you try another compiler or update yours?])
284
+        fi
285
+      fi
286
+
287
+#      if test "$ax_cv_have_avx_ext" = yes; then
288
+#        AX_CHECK_COMPILE_FLAG(-mavx, ax_cv_support_avx_ext=yes, [])
289
+#        if test x"$ax_cv_support_avx_ext" = x"yes"; then
290
+#          SIMD_FLAGS="$SIMD_FLAGS -mavx"
291
+#          AC_DEFINE(HAVE_AVX,1,[Define to 1 if you support AVX (Advanced Vector Extensions) instructions])
292
+#        else
293
+#          AC_MSG_WARN([Your processor supports avx instructions but not your compiler.  Can you try another compiler or update yours?])
294
+#        fi
295
+#      fi
296
+
297
+      AC_MSG_CHECKING(for immintrin.h header file)
298
+      AC_TRY_LINK([#include <immintrin.h>],
299
+                  [ ],
300
+                  [ax_cv_have_immintrin_h=yes])
301
+
302
+      if test x"$a_cv_have_immintrin_h" = x"yes"; then
303
+        AC_MSG_RESULT([yes])
304
+        if test "$ax_cv_have_popcnt_ext" = yes; then
305
+          AC_DEFINE(HAVE_POPCNT,1,[Define to 1 if you support Intel intrinsic _popcnt instruction])
306
+        fi
307
+
308
+        if test "$ax_cv_have_lzcnt_ext" = yes; then
309
+          AC_DEFINE(HAVE_LZCNT,1,[Define to 1 if you support Intel intrinsic _lzcnt instruction])
310
+        fi
311
+
312
+        if test "$ax_cv_have_bmi1_ext" = yes; then
313
+          AC_DEFINE(HAVE_BMI1,1,[Define to 1 if you support BMI1 (Bit Manipulation Instruction set 1)])
314
+        fi
315
+      else
316
+        AC_MSG_RESULT([no])
317
+        if test "$ax_cv_have_popcnt_ext" = yes; then
318
+          AC_MSG_WARN([Your processor supports _popcnt instructions but your compiler cannot find immintrin.h.  Will try another method.])
319
+        fi
320
+        if test "$ax_cv_have_lzcnt_ext" = yes; then
321
+          AC_MSG_WARN([Your processor supports _lzcnt instructions but your compiler cannot find immintrin.h.  Will try another method.])
322
+        fi
323
+        if test "$ax_cv_have_bmi1_ext" = yes; then
324
+          AC_MSG_WARN([Your processor supports bmi instructions but your compiler cannot find immintrin.h.  Will try another method.])
325
+        fi
326
+      fi
327
+
328
+      if test "$ax_cv_have_bmi2_ext" = yes; then
329
+        AC_DEFINE(HAVE_BMI2,1,[Define to 1 if you support BMI2 (Bit Manipulation Instruction set 2)])
330
+      fi
331
+
332
+#      if test "$ax_cv_have_avx2_ext" = yes; then
333
+#        AX_CHECK_COMPILE_FLAG(-mavx2, ax_cv_support_avx2_ext=yes, [])
334
+#        if test x"$ax_cv_support_avx2_ext" = x"yes"; then
335
+#          SIMD_FLAGS="$SIMD_FLAGS -mavx2"
336
+#          AC_DEFINE(HAVE_AVX2,1,[Define to 1 if you support AVX2 (Advanced Vector Extensions 2) instructions])
337
+#        else
338
+#          AC_MSG_WARN([Your processor supports avx2 instructions but not your compiler.  Can you try another compiler or update yours?])
339
+#        fi
340
+#      fi
341
+
342
+  ;;
343
+  esac
344
+
345
+  AC_SUBST(SIMD_FLAGS)
346
+])
0 347
new file mode 100644
... ...
@@ -0,0 +1,79 @@
1
+# ===========================================================================
2
+#   http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_avx_xgetbv.html
3
+# ===========================================================================
4
+#
5
+# SYNOPSIS
6
+#
7
+#   AX_GCC_X86_AVX_XGETBV
8
+#
9
+# DESCRIPTION
10
+#
11
+#   On later x86 processors with AVX SIMD support, with gcc or a compiler
12
+#   that has a compatible syntax for inline assembly instructions, run a
13
+#   small program that executes the xgetbv instruction with input OP. This
14
+#   can be used to detect if the OS supports AVX instruction usage.
15
+#
16
+#   On output, the values of the eax and edx registers are stored as
17
+#   hexadecimal strings as "eax:edx" in the cache variable
18
+#   ax_cv_gcc_x86_avx_xgetbv.
19
+#
20
+#   If the xgetbv instruction fails (because you are running a
21
+#   cross-compiler, or because you are not using gcc, or because you are on
22
+#   a processor that doesn't have this instruction),
23
+#   ax_cv_gcc_x86_avx_xgetbv_OP is set to the string "unknown".
24
+#
25
+#   This macro mainly exists to be used in AX_EXT.
26
+#
27
+# LICENSE
28
+#
29
+#   Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com>
30
+#
31
+#   This program is free software: you can redistribute it and/or modify it
32
+#   under the terms of the GNU General Public License as published by the
33
+#   Free Software Foundation, either version 3 of the License, or (at your
34
+#   option) any later version.
35
+#
36
+#   This program is distributed in the hope that it will be useful, but
37
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
38
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
39
+#   Public License for more details.
40
+#
41
+#   You should have received a copy of the GNU General Public License along
42
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
43
+#
44
+#   As a special exception, the respective Autoconf Macro's copyright owner
45
+#   gives unlimited permission to copy, distribute and modify the configure
46
+#   scripts that are the output of Autoconf when processing the Macro. You
47
+#   need not follow the terms of the GNU General Public License when using
48
+#   or distributing such scripts, even though portions of the text of the
49
+#   Macro appear in them. The GNU General Public License (GPL) does govern
50
+#   all other use of the material that constitutes the Autoconf Macro.
51
+#
52
+#   This special exception to the GPL applies to versions of the Autoconf
53
+#   Macro released by the Autoconf Archive. When you make and distribute a
54
+#   modified version of the Autoconf Macro, you may extend this special
55
+#   exception to the GPL to apply to your modified version as well.
56
+
57
+#serial 1
58
+
59
+AC_DEFUN([AX_GCC_X86_AVX_XGETBV],
60
+[AC_REQUIRE([AC_PROG_CC])
61
+AC_LANG_PUSH([C])
62
+AC_CACHE_CHECK(for x86-AVX xgetbv $1 output, ax_cv_gcc_x86_avx_xgetbv_$1,
63
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
64
+     int op = $1, eax, edx;
65
+     FILE *f;
66
+      /* Opcodes for xgetbv */
67
+      __asm__(".byte 0x0f, 0x01, 0xd0"
68
+        : "=a" (eax), "=d" (edx)
69
+        : "c" (op));
70
+     f = fopen("conftest_xgetbv", "w"); if (!f) return 1;
71
+     fprintf(f, "%x:%x\n", eax, edx);
72
+     fclose(f);
73
+     return 0;
74
+])],
75
+     [ax_cv_gcc_x86_avx_xgetbv_$1=`cat conftest_xgetbv`; rm -f conftest_xgetbv],
76
+     [ax_cv_gcc_x86_avx_xgetbv_$1=unknown; rm -f conftest_xgetbv],
77
+     [ax_cv_gcc_x86_avx_xgetbv_$1=unknown])])
78
+AC_LANG_POP([C])
79
+])
0 80
new file mode 100644
... ...
@@ -0,0 +1,79 @@
1
+# ===========================================================================
2
+#     http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
3
+# ===========================================================================
4
+#
5
+# SYNOPSIS
6
+#
7
+#   AX_GCC_X86_CPUID(OP)
8
+#
9
+# DESCRIPTION
10
+#
11
+#   On Pentium and later x86 processors, with gcc or a compiler that has a
12
+#   compatible syntax for inline assembly instructions, run a small program
13
+#   that executes the cpuid instruction with input OP. This can be used to
14
+#   detect the CPU type.
15
+#
16
+#   On output, the values of the eax, ebx, ecx, and edx registers are stored
17
+#   as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
18
+#   ax_cv_gcc_x86_cpuid_OP.
19
+#
20
+#   If the cpuid instruction fails (because you are running a
21
+#   cross-compiler, or because you are not using gcc, or because you are on
22
+#   a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
23
+#   is set to the string "unknown".
24
+#
25
+#   This macro mainly exists to be used in AX_GCC_ARCHFLAG.
26
+#
27
+# LICENSE
28
+#
29
+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
30
+#   Copyright (c) 2008 Matteo Frigo
31
+#
32
+#   This program is free software: you can redistribute it and/or modify it
33
+#   under the terms of the GNU General Public License as published by the
34
+#   Free Software Foundation, either version 3 of the License, or (at your
35
+#   option) any later version.
36
+#
37
+#   This program is distributed in the hope that it will be useful, but
38
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
39
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
40
+#   Public License for more details.
41
+#
42
+#   You should have received a copy of the GNU General Public License along
43
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
44
+#
45
+#   As a special exception, the respective Autoconf Macro's copyright owner
46
+#   gives unlimited permission to copy, distribute and modify the configure
47
+#   scripts that are the output of Autoconf when processing the Macro. You
48
+#   need not follow the terms of the GNU General Public License when using
49
+#   or distributing such scripts, even though portions of the text of the
50
+#   Macro appear in them. The GNU General Public License (GPL) does govern
51
+#   all other use of the material that constitutes the Autoconf Macro.
52
+#
53
+#   This special exception to the GPL applies to versions of the Autoconf
54
+#   Macro released by the Autoconf Archive. When you make and distribute a
55
+#   modified version of the Autoconf Macro, you may extend this special
56
+#   exception to the GPL to apply to your modified version as well.
57
+
58
+#serial 7
59
+
60
+AC_DEFUN([AX_GCC_X86_CPUID],
61
+[AC_REQUIRE([AC_PROG_CC])
62
+AC_LANG_PUSH([C])
63
+AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
64
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
65
+     int op = $1, eax, ebx, ecx, edx;
66
+     FILE *f;
67
+      __asm__("cpuid"
68
+        : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
69
+        : "a" (op));
70
+     f = fopen("conftest_cpuid", "w"); if (!f) return 1;
71
+     fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
72
+     fclose(f);
73
+     return 0;
74
+])],
75
+     [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
76
+     [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
77
+     [ax_cv_gcc_x86_cpuid_$1=unknown])])
78
+AC_LANG_POP([C])
79
+])
0 80
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+
2
+AC_DEFUN([ACX_BUILTIN], [
3
+AC_LANG_SAVE
4
+AC_LANG(C)
5
+
6
+AC_MSG_CHECKING(for __builtin_popcount)
7
+AC_RUN_IFELSE(
8
+  [AC_LANG_PROGRAM([[]],
9
+                   [[return (__builtin_popcount(0xffffffffu) == 32) ? 0 : 9;]])],
10
+  [AC_MSG_RESULT(yes)
11
+   AC_DEFINE([HAVE_BUILTIN_POPCOUNT],[1],[Define to 1 if __builtin_popcount works.])],
12
+  [AC_MSG_RESULT(no)])
13
+
14
+AC_MSG_CHECKING(for __builtin_clz)
15
+AC_RUN_IFELSE(
16
+  [AC_LANG_PROGRAM([[]],
17
+                   [[return (__builtin_clz(0x1u) == 31) ? 0 : 9;]])],
18
+  [AC_MSG_RESULT(yes)
19
+   AC_DEFINE([HAVE_BUILTIN_CLZ],[1],[Define to 1 if __builtin_clz works.])],
20
+  [AC_MSG_RESULT(no)])
21
+
22
+AC_MSG_CHECKING(for __builtin_ctz)
23
+AC_RUN_IFELSE(
24
+  [AC_LANG_PROGRAM([[]],
25
+                   [[return (__builtin_ctz(0x80000000u) == 31) ? 0 : 9;]])],
26
+  [AC_MSG_RESULT(yes)
27
+   AC_DEFINE([HAVE_BUILTIN_CTZ],[1],[Define to 1 if __builtin_ctz works.])],
28
+  [AC_MSG_RESULT(no)])
29
+
30
+AC_LANG_RESTORE
31
+])
32
+
33
+
... ...
@@ -30,6 +30,15 @@ AC_COMPILE_IFELSE(
30 30
    AC_DEFINE([HAVE_MADVISE_MADV_RANDOM],[1],[Define to 1 if MADV_RANDOM available for madvise])],
31 31
   [AC_MSG_RESULT(no)])
32 32
 
33
+AC_MSG_CHECKING(for MADV_SEQUENTIAL in madvise)
34
+AC_COMPILE_IFELSE(
35
+  [AC_LANG_PROGRAM([[#include <sys/types.h>
36
+#include <sys/mman.h>]],
37
+                   [[int flags = MADV_SEQUENTIAL;]])],
38
+  [AC_MSG_RESULT(yes)
39
+   AC_DEFINE([HAVE_MADVISE_MADV_SEQUENTIAL],[1],[Define to 1 if MADV_SEQUENTIAL available for madvise])],
40
+  [AC_MSG_RESULT(no)])
41
+
33 42
 AC_LANG_RESTORE
34 43
 ])
35 44
 
36 45
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+
2
+AC_DEFUN([ACX_SSE2_SHIFT_DEFECT], [
3
+  AC_REQUIRE([AC_CANONICAL_HOST])
4
+  AC_LANG_SAVE
5
+  AC_LANG_C
6
+
7
+  AC_MSG_CHECKING(compiler is defective and requires an immediate in sse2 shift commands)
8
+  AC_COMPILE_IFELSE(
9
+  [AC_LANG_PROGRAM([[#include <stdio.h>
10
+#include <stdlib.h>
11
+#include <emmintrin.h>]],
12
+                   [[int nshift = rand() % 32;
13
+__m128i shifted;
14
+shifted = _mm_slli_epi32(_mm_set1_epi32(1),nshift);
15
+]])],
16
+  [ax_cv_sse2_shift_defect=no],
17
+  [ax_cv_sse2_shift_defect=yes])
18
+
19
+  AC_MSG_RESULT($ax_cv_sse2_shift_defect)
20
+  if test "$ax_cv_sse2_shift_defect" = yes; then
21
+    AC_DEFINE(DEFECTIVE_SSE2_COMPILER,1,[Define to 1 if your compiler is defective and requires an immediate in sse2 shift commands.])
22
+  fi
23
+
24
+AC_LANG_RESTORE
25
+])dnl
26
+
... ...
@@ -646,6 +646,7 @@ ZLIB_LIBS
646 646
 MAKE_BINARIES_FALSE
647 647
 MAKE_BINARIES_TRUE
648 648
 GMAPDB
649
+SIMD_FLAGS
649 650
 UNIQSCAN
650 651
 GSNAP
651 652
 GMAP
... ...
@@ -801,6 +802,10 @@ with_gnu_ld
801 802
 with_sysroot
802 803
 enable_libtool_lock
803 804
 with_gmap
805
+enable_popcnt
806
+enable_sse2
807
+enable_sse4_1
808
+enable_simd
804 809
 with_gmapdb
805 810
 enable_binaries
806 811
 enable_zlib
... ...
@@ -1452,6 +1457,15 @@ Optional Features:
1452 1457
   --enable-fast-install[=PKGS]
1453 1458
                           optimize for fast installation [default=yes]
1454 1459
   --disable-libtool-lock  avoid locking (might break parallel builds)
1460
+  --enable-popcnt         Enable -mpopcnt if it compiles and runs
1461
+                          (default=yes). May want to disable if compiling on
1462
+                          one machine and running on another.
1463
+  --enable-sse2           Enable sse2 simd commands if they compile and run
1464
+                          (default=yes).
1465
+  --enable-sse4.1         Enable sse4.1 simd commands if they compile and run
1466
+                          (default=yes). Requires that sse2 be enabled.
1467
+  --enable-simd           Enable simd commands in general if they compile and
1468
+                          run (default=yes).
1455 1469
   --enable-binaries       Enable building of binaries (default=yes)
1456 1470
   --enable-zlib           Enable zlib support (option needed for uncompressing
1457 1471
                           gzip files) (default=yes)
... ...
@@ -14657,6 +14671,32 @@ $as_echo "no" >&6; }
14657 14671
 fi
14658 14672
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14659 14673
 
14674
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MADV_SEQUENTIAL in madvise" >&5
14675
+$as_echo_n "checking for MADV_SEQUENTIAL in madvise... " >&6; }
14676
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14677
+/* end confdefs.h.  */
14678
+#include <sys/types.h>
14679
+#include <sys/mman.h>
14680
+int
14681
+main ()
14682
+{
14683
+int flags = MADV_SEQUENTIAL;
14684
+  ;
14685
+  return 0;
14686
+}
14687
+_ACEOF
14688
+if ac_fn_c_try_compile "$LINENO"; then :
14689
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
14690
+$as_echo "yes" >&6; }
14691
+
14692
+$as_echo "#define HAVE_MADVISE_MADV_SEQUENTIAL 1" >>confdefs.h
14693
+
14694
+else
14695
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14696
+$as_echo "no" >&6; }
14697
+fi
14698
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14699
+
14660 14700
 ac_ext=c
14661 14701
 ac_cpp='$CPP $CPPFLAGS'
14662 14702
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
... ...
@@ -14866,6 +14906,2477 @@ $as_echo "#define USE_FOPEN_TEXT 1" >>confdefs.h
14866 14906
 fi
14867 14907
 
14868 14908
 
14909
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for popcnt feature" >&5
14910
+$as_echo_n "checking for popcnt feature... " >&6; }
14911
+# Check whether --enable-popcnt was given.
14912
+if test "${enable_popcnt+set}" = set; then :
14913
+  enableval=$enable_popcnt; answer="$enableval"
14914
+else
14915
+  answer=""
14916
+fi
14917
+
14918
+case x"$answer" in
14919
+	xyes)
14920
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
14921
+$as_echo "enabled" >&6; }
14922
+
14923
+
14924
+ac_ext=c
14925
+ac_cpp='$CPP $CPPFLAGS'
14926
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
14927
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
14928
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
14929
+
14930
+
14931
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5
14932
+$as_echo_n "checking for __builtin_popcount... " >&6; }
14933
+if test "$cross_compiling" = yes; then :
14934
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
14935
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
14936
+as_fn_error $? "cannot run test program while cross compiling
14937
+See \`config.log' for more details" "$LINENO" 5; }
14938
+else
14939
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14940
+/* end confdefs.h.  */
14941
+
14942
+int
14943
+main ()
14944
+{
14945
+return (__builtin_popcount(0xffffffffu) == 32) ? 0 : 9;
14946
+  ;
14947
+  return 0;
14948
+}
14949
+_ACEOF
14950
+if ac_fn_c_try_run "$LINENO"; then :
14951
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
14952
+$as_echo "yes" >&6; }
14953
+
14954
+$as_echo "#define HAVE_BUILTIN_POPCOUNT 1" >>confdefs.h
14955
+
14956
+else
14957
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14958
+$as_echo "no" >&6; }
14959
+fi
14960
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
14961
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
14962
+fi
14963
+
14964
+
14965
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clz" >&5
14966
+$as_echo_n "checking for __builtin_clz... " >&6; }
14967
+if test "$cross_compiling" = yes; then :
14968
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
14969
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
14970
+as_fn_error $? "cannot run test program while cross compiling
14971
+See \`config.log' for more details" "$LINENO" 5; }
14972
+else
14973
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14974
+/* end confdefs.h.  */
14975
+
14976
+int
14977
+main ()
14978
+{
14979
+return (__builtin_clz(0x1u) == 31) ? 0 : 9;
14980
+  ;
14981
+  return 0;
14982
+}
14983
+_ACEOF
14984
+if ac_fn_c_try_run "$LINENO"; then :
14985
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
14986
+$as_echo "yes" >&6; }
14987
+
14988
+$as_echo "#define HAVE_BUILTIN_CLZ 1" >>confdefs.h
14989
+
14990
+else
14991
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14992
+$as_echo "no" >&6; }
14993
+fi
14994
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
14995
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
14996
+fi
14997
+
14998
+
14999
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ctz" >&5
15000
+$as_echo_n "checking for __builtin_ctz... " >&6; }
15001
+if test "$cross_compiling" = yes; then :
15002
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
15003
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
15004
+as_fn_error $? "cannot run test program while cross compiling
15005
+See \`config.log' for more details" "$LINENO" 5; }
15006
+else
15007
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15008
+/* end confdefs.h.  */
15009
+
15010
+int
15011
+main ()
15012
+{
15013
+return (__builtin_ctz(0x80000000u) == 31) ? 0 : 9;
15014
+  ;
15015
+  return 0;
15016
+}
15017
+_ACEOF
15018
+if ac_fn_c_try_run "$LINENO"; then :
15019
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15020
+$as_echo "yes" >&6; }
15021
+
15022
+$as_echo "#define HAVE_BUILTIN_CTZ 1" >>confdefs.h
15023
+
15024
+else
15025
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15026
+$as_echo "no" >&6; }
15027
+fi
15028
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15029
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15030
+fi
15031
+
15032
+
15033
+ac_ext=c
15034
+ac_cpp='$CPP $CPPFLAGS'
15035
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15036
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15037
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15038
+
15039
+
15040
+	;;
15041
+
15042
+	xno)
15043
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
15044
+$as_echo "disabled" >&6; }
15045
+	;;
15046
+
15047
+	x)
15048
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not specified so enabled by default" >&5
15049
+$as_echo "not specified so enabled by default" >&6; }
15050
+
15051
+
15052
+ac_ext=c
15053
+ac_cpp='$CPP $CPPFLAGS'
15054
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15055
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15056
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15057
+
15058
+
15059
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5
15060
+$as_echo_n "checking for __builtin_popcount... " >&6; }
15061
+if test "$cross_compiling" = yes; then :
15062
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
15063
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
15064
+as_fn_error $? "cannot run test program while cross compiling
15065
+See \`config.log' for more details" "$LINENO" 5; }
15066
+else
15067
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15068
+/* end confdefs.h.  */
15069
+
15070
+int
15071
+main ()
15072
+{
15073
+return (__builtin_popcount(0xffffffffu) == 32) ? 0 : 9;
15074
+  ;
15075
+  return 0;
15076
+}
15077
+_ACEOF
15078
+if ac_fn_c_try_run "$LINENO"; then :
15079
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15080
+$as_echo "yes" >&6; }
15081
+
15082
+$as_echo "#define HAVE_BUILTIN_POPCOUNT 1" >>confdefs.h
15083
+
15084
+else
15085
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15086
+$as_echo "no" >&6; }
15087
+fi
15088
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15089
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15090
+fi
15091
+
15092
+
15093
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clz" >&5
15094
+$as_echo_n "checking for __builtin_clz... " >&6; }
15095
+if test "$cross_compiling" = yes; then :
15096
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
15097
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
15098
+as_fn_error $? "cannot run test program while cross compiling
15099
+See \`config.log' for more details" "$LINENO" 5; }
15100
+else
15101
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15102
+/* end confdefs.h.  */
15103
+
15104
+int
15105
+main ()
15106
+{
15107
+return (__builtin_clz(0x1u) == 31) ? 0 : 9;
15108
+  ;
15109
+  return 0;
15110
+}
15111
+_ACEOF
15112
+if ac_fn_c_try_run "$LINENO"; then :
15113
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15114
+$as_echo "yes" >&6; }
15115
+
15116
+$as_echo "#define HAVE_BUILTIN_CLZ 1" >>confdefs.h
15117
+
15118
+else
15119
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15120
+$as_echo "no" >&6; }
15121
+fi
15122
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15123
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15124
+fi
15125
+
15126
+
15127
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ctz" >&5
15128
+$as_echo_n "checking for __builtin_ctz... " >&6; }
15129
+if test "$cross_compiling" = yes; then :
15130
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
15131
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
15132
+as_fn_error $? "cannot run test program while cross compiling
15133
+See \`config.log' for more details" "$LINENO" 5; }
15134
+else
15135
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15136
+/* end confdefs.h.  */
15137
+
15138
+int
15139
+main ()
15140
+{
15141
+return (__builtin_ctz(0x80000000u) == 31) ? 0 : 9;
15142
+  ;
15143
+  return 0;
15144
+}
15145
+_ACEOF
15146
+if ac_fn_c_try_run "$LINENO"; then :
15147
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15148
+$as_echo "yes" >&6; }
15149
+
15150
+$as_echo "#define HAVE_BUILTIN_CTZ 1" >>confdefs.h
15151
+
15152
+else
15153
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15154
+$as_echo "no" >&6; }
15155
+fi
15156
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15157
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15158
+fi
15159
+
15160
+
15161
+ac_ext=c
15162
+ac_cpp='$CPP $CPPFLAGS'
15163
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15164
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15165
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15166
+
15167
+
15168
+	;;
15169
+esac
15170
+
15171
+
15172
+
15173
+ac_ext=c
15174
+ac_cpp='$CPP $CPPFLAGS'
15175
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15176
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15177
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15178
+
15179
+
15180
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bsr instruction in assembly" >&5
15181
+$as_echo_n "checking for bsr instruction in assembly... " >&6; }
15182
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15183
+/* end confdefs.h.  */
15184
+
15185
+int
15186
+main ()
15187
+{
15188
+int msb; unsigned int x = rand(); asm("bsr %1,%0" : "=r"(msb) : "r"(x));
15189
+  ;
15190
+  return 0;
15191
+}
15192
+_ACEOF
15193
+if ac_fn_c_try_compile "$LINENO"; then :
15194
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15195
+$as_echo "yes" >&6; }
15196
+
15197
+$as_echo "#define HAVE_ASM_BSR 1" >>confdefs.h
15198
+
15199
+else
15200
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15201
+$as_echo "no" >&6; }
15202
+fi
15203
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15204
+
15205
+ac_ext=c
15206
+ac_cpp='$CPP $CPPFLAGS'
15207
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15208
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15209
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15210
+
15211
+
15212
+
15213
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sse2 is enabled" >&5
15214
+$as_echo_n "checking whether sse2 is enabled... " >&6; }
15215
+# Check whether --enable-sse2 was given.
15216
+if test "${enable_sse2+set}" = set; then :
15217
+  enableval=$enable_sse2; answer="$enableval"
15218
+else
15219
+  answer=""
15220
+fi
15221
+
15222
+case x"$answer" in
15223
+     xyes)
15224
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
15225
+$as_echo "enabled" >&6; }
15226
+     ax_cv_want_sse2_ext=yes
15227
+     ;;
15228
+
15229
+     xno)
15230
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
15231
+$as_echo "disabled" >&6; }
15232
+     ax_cv_want_sse2_ext=no
15233
+     ;;
15234
+
15235
+     x)
15236
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: not specified so enabled by default" >&5
15237
+$as_echo "not specified so enabled by default" >&6; }
15238
+     ax_cv_want_sse2_ext=yes
15239
+     ;;
15240
+esac
15241
+
15242
+ax_cv_sse2_shift_defect=no
15243
+if test "$ax_cv_want_sse2_ext" = yes; then
15244
+
15245
+
15246
+
15247
+  ac_ext=c
15248
+ac_cpp='$CPP $CPPFLAGS'
15249
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15250
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15251
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15252
+
15253
+
15254
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler is defective and requires an immediate in sse2 shift commands" >&5
15255
+$as_echo_n "checking compiler is defective and requires an immediate in sse2 shift commands... " >&6; }
15256
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15257
+/* end confdefs.h.  */
15258
+#include <stdio.h>
15259
+#include <stdlib.h>
15260
+#include <emmintrin.h>
15261
+int
15262
+main ()
15263
+{
15264
+int nshift = rand() % 32;
15265
+__m128i shifted;
15266
+shifted = _mm_slli_epi32(_mm_set1_epi32(1),nshift);
15267
+
15268
+  ;
15269
+  return 0;
15270
+}
15271
+_ACEOF
15272
+if ac_fn_c_try_compile "$LINENO"; then :
15273
+  ax_cv_sse2_shift_defect=no
15274
+else
15275
+  ax_cv_sse2_shift_defect=yes
15276
+fi
15277
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15278
+
15279
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_sse2_shift_defect" >&5
15280
+$as_echo "$ax_cv_sse2_shift_defect" >&6; }
15281
+  if test "$ax_cv_sse2_shift_defect" = yes; then
15282
+
15283
+$as_echo "#define DEFECTIVE_SSE2_COMPILER 1" >>confdefs.h
15284
+
15285
+  fi
15286
+
15287
+ac_ext=c
15288
+ac_cpp='$CPP $CPPFLAGS'
15289
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15290
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15291
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15292
+
15293
+
15294
+fi
15295
+
15296
+
15297
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sse4.1 is enabled" >&5
15298
+$as_echo_n "checking whether sse4.1 is enabled... " >&6; }
15299
+# Check whether --enable-sse4.1 was given.
15300
+if test "${enable_sse4_1+set}" = set; then :
15301
+  enableval=$enable_sse4_1; answer="$enableval"
15302
+else
15303
+  answer=""
15304
+fi
15305
+
15306
+if test "$ax_cv_want_sse2_ext" = no; then
15307
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled because the user disabled sse2" >&5
15308
+$as_echo "disabled because the user disabled sse2" >&6; }
15309
+   ax_cv_want_sse41_ext=no
15310
+else
15311
+    case x"$answer" in
15312
+	 xyes)
15313
+	 { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
15314
+$as_echo "enabled" >&6; }
15315
+	 ax_cv_want_sse41_ext=yes
15316
+	 ;;
15317
+
15318
+	 xno)
15319
+	 { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
15320
+$as_echo "disabled" >&6; }
15321
+	 ax_cv_want_sse41_ext=no
15322
+	 ;;
15323
+
15324
+	 x)
15325
+	 { $as_echo "$as_me:${as_lineno-$LINENO}: result: not specified so enabled by default" >&5
15326
+$as_echo "not specified so enabled by default" >&6; }
15327
+	 ax_cv_want_sse41_ext=yes
15328
+	 ;;
15329
+    esac
15330
+fi
15331
+
15332
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether simd is enabled" >&5
15333
+$as_echo_n "checking whether simd is enabled... " >&6; }
15334
+# Check whether --enable-simd was given.
15335
+if test "${enable_simd+set}" = set; then :
15336
+  enableval=$enable_simd; answer="$enableval"
15337
+else
15338
+  answer=""
15339
+fi
15340
+
15341
+case x"$answer" in
15342
+     xyes)
15343
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
15344
+$as_echo "enabled" >&6; }
15345
+
15346
+ac_ext=c
15347
+ac_cpp='$CPP $CPPFLAGS'
15348
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15349
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15350
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15351
+
15352
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid  output" >&5
15353
+$as_echo_n "checking for x86 cpuid  output... " >&6; }
15354
+if ${ax_cv_gcc_x86_cpuid_+:} false; then :
15355
+  $as_echo_n "(cached) " >&6
15356
+else
15357
+  if test "$cross_compiling" = yes; then :
15358
+  ax_cv_gcc_x86_cpuid_=unknown
15359
+else
15360
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15361
+/* end confdefs.h.  */
15362
+#include <stdio.h>
15363
+int
15364
+main ()
15365
+{
15366
+
15367
+     int op = , eax, ebx, ecx, edx;
15368
+     FILE *f;
15369
+      __asm__("cpuid"
15370
+        : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
15371
+        : "a" (op));
15372
+     f = fopen("conftest_cpuid", "w"); if (!f) return 1;
15373
+     fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
15374
+     fclose(f);
15375
+     return 0;
15376
+
15377
+  ;
15378
+  return 0;
15379
+}
15380
+_ACEOF
15381
+if ac_fn_c_try_run "$LINENO"; then :
15382
+  ax_cv_gcc_x86_cpuid_=`cat conftest_cpuid`; rm -f conftest_cpuid
15383
+else
15384
+  ax_cv_gcc_x86_cpuid_=unknown; rm -f conftest_cpuid
15385
+fi
15386
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15387
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15388
+fi
15389
+
15390
+fi
15391
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_" >&5
15392
+$as_echo "$ax_cv_gcc_x86_cpuid_" >&6; }
15393
+ac_ext=c
15394
+ac_cpp='$CPP $CPPFLAGS'
15395
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15396
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15397
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15398
+
15399
+
15400
+
15401
+ac_ext=c
15402
+ac_cpp='$CPP $CPPFLAGS'
15403
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15404
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15405
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15406
+
15407
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86-AVX xgetbv  output" >&5
15408
+$as_echo_n "checking for x86-AVX xgetbv  output... " >&6; }
15409
+if ${ax_cv_gcc_x86_avx_xgetbv_+:} false; then :
15410
+  $as_echo_n "(cached) " >&6
15411
+else
15412
+  if test "$cross_compiling" = yes; then :
15413
+  ax_cv_gcc_x86_avx_xgetbv_=unknown
15414
+else
15415
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15416
+/* end confdefs.h.  */
15417
+#include <stdio.h>
15418
+int
15419
+main ()
15420
+{
15421
+
15422
+     int op = , eax, edx;
15423
+     FILE *f;
15424
+      /* Opcodes for xgetbv */
15425
+      __asm__(".byte 0x0f, 0x01, 0xd0"
15426
+        : "=a" (eax), "=d" (edx)
15427
+        : "c" (op));
15428
+     f = fopen("conftest_xgetbv", "w"); if (!f) return 1;
15429
+     fprintf(f, "%x:%x\n", eax, edx);
15430
+     fclose(f);
15431
+     return 0;
15432
+
15433
+  ;
15434
+  return 0;
15435
+}
15436
+_ACEOF
15437
+if ac_fn_c_try_run "$LINENO"; then :
15438
+  ax_cv_gcc_x86_avx_xgetbv_=`cat conftest_xgetbv`; rm -f conftest_xgetbv
15439
+else
15440
+  ax_cv_gcc_x86_avx_xgetbv_=unknown; rm -f conftest_xgetbv
15441
+fi
15442
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15443
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
15444
+fi
15445
+
15446
+fi
15447
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_avx_xgetbv_" >&5
15448
+$as_echo "$ax_cv_gcc_x86_avx_xgetbv_" >&6; }
15449
+ac_ext=c
15450
+ac_cpp='$CPP $CPPFLAGS'
15451
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15452
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15453
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
15454
+
15455
+
15456
+
15457
+
15458
+
15459
+  case $host_cpu in
15460
+    powerpc*)
15461
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether altivec is enabled and supported" >&5
15462
+$as_echo_n "checking whether altivec is enabled and supported... " >&6; }
15463
+if ${ax_cv_have_altivec_ext+:} false; then :
15464
+  $as_echo_n "(cached) " >&6
15465
+else
15466
+
15467
+            if test `/usr/sbin/sysctl -a 2>/dev/null| grep -c hw.optional.altivec` != 0; then
15468
+                if test `/usr/sbin/sysctl -n hw.optional.altivec` = 1; then
15469
+                  ax_cv_have_altivec_ext=yes
15470
+                fi
15471
+            fi
15472
+
15473
+fi
15474
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have_altivec_ext" >&5
15475
+$as_echo "$ax_cv_have_altivec_ext" >&6; }
15476
+
15477
+          if test "$ax_cv_have_altivec_ext" = yes; then
15478
+
15479
+$as_echo "#define HAVE_ALTIVEC 1" >>confdefs.h
15480
+
15481
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -faltivec" >&5
15482
+$as_echo_n "checking whether C compiler accepts -faltivec... " >&6; }
15483
+if ${ax_cv_check_cflags___faltivec+:} false; then :
15484
+  $as_echo_n "(cached) " >&6
15485
+else
15486
+
15487
+  ax_check_save_flags=$CFLAGS
15488
+  CFLAGS="$CFLAGS  -faltivec"
15489
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15490
+/* end confdefs.h.  */
15491
+