Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 1 | # =========================================================================== |
| 2 | # http://www.gnu.org/software/autoconf-archive/ax_ext.html |
| 3 | # =========================================================================== |
| 4 | # |
| 5 | # SYNOPSIS |
| 6 | # |
Vadim Yanitskiy | 61fbf2e | 2017-05-20 01:08:55 +0300 | [diff] [blame^] | 7 | # AX_SSE |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 8 | # |
| 9 | # DESCRIPTION |
| 10 | # |
Vadim Yanitskiy | 61fbf2e | 2017-05-20 01:08:55 +0300 | [diff] [blame^] | 11 | # Find SIMD extensions supported by compiler. The -m"simdextensionname" is |
| 12 | # added to SIMD_FLAGS if compiler supports it. For example, if "sse2" is |
| 13 | # available, then "-msse2" is added to SIMD_FLAGS. |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 14 | # |
| 15 | # This macro calls: |
| 16 | # |
| 17 | # AC_SUBST(SIMD_FLAGS) |
| 18 | # |
| 19 | # And defines: |
| 20 | # |
Vadim Yanitskiy | 61fbf2e | 2017-05-20 01:08:55 +0300 | [diff] [blame^] | 21 | # HAVE_SSE3 / HAVE_SSE4.1 |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 22 | # |
| 23 | # LICENSE |
| 24 | # |
| 25 | # Copyright (c) 2007 Christophe Tournayre <turn3r@users.sourceforge.net> |
| 26 | # Copyright (c) 2013 Michael Petch <mpetch@capp-sysware.com> |
| 27 | # |
| 28 | # Copying and distribution of this file, with or without modification, are |
| 29 | # permitted in any medium without royalty provided the copyright notice |
| 30 | # and this notice are preserved. This file is offered as-is, without any |
| 31 | # warranty. |
Philipp Maier | f5bf33b | 2017-03-16 13:12:07 +0100 | [diff] [blame] | 32 | # |
| 33 | # NOTE: The functionality that requests the cpuid has been stripped because |
| 34 | # this project detects the CPU capabilities during runtime. However, we |
| 35 | # still need to check if the compiler supports the requested SIMD flag |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 36 | |
| 37 | #serial 12 |
| 38 | |
Philipp Maier | e8ae9fc | 2017-03-20 12:08:42 +0100 | [diff] [blame] | 39 | AC_DEFUN([AX_SSE], |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 40 | [ |
| 41 | AC_REQUIRE([AC_CANONICAL_HOST]) |
| 42 | |
| 43 | case $host_cpu in |
| 44 | i[[3456]]86*|x86_64*|amd64*) |
| 45 | |
| 46 | AC_REQUIRE([AX_GCC_X86_CPUID]) |
| 47 | AC_REQUIRE([AX_GCC_X86_AVX_XGETBV]) |
| 48 | |
| 49 | AX_GCC_X86_CPUID(0x00000001) |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 50 | |
Philipp Maier | f5bf33b | 2017-03-16 13:12:07 +0100 | [diff] [blame] | 51 | AX_CHECK_COMPILE_FLAG(-msse3, ax_cv_support_sse3_ext=yes, []) |
| 52 | if test x"$ax_cv_support_sse3_ext" = x"yes"; then |
| 53 | SIMD_FLAGS="$SIMD_FLAGS -msse3" |
| 54 | AC_DEFINE(HAVE_SSE3,,[Support SSE3 (Streaming SIMD Extensions 3) instructions]) |
Philipp Maier | e8ae9fc | 2017-03-20 12:08:42 +0100 | [diff] [blame] | 55 | AM_CONDITIONAL(HAVE_SSE3, true) |
Philipp Maier | f5bf33b | 2017-03-16 13:12:07 +0100 | [diff] [blame] | 56 | else |
| 57 | AC_MSG_WARN([Your compiler does not support sse3 instructions, can you try another compiler?]) |
Philipp Maier | e8ae9fc | 2017-03-20 12:08:42 +0100 | [diff] [blame] | 58 | AM_CONDITIONAL(HAVE_SSE3, false) |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 59 | fi |
| 60 | |
Philipp Maier | f5bf33b | 2017-03-16 13:12:07 +0100 | [diff] [blame] | 61 | AX_CHECK_COMPILE_FLAG(-msse4.1, ax_cv_support_sse41_ext=yes, []) |
| 62 | if test x"$ax_cv_support_sse41_ext" = x"yes"; then |
| 63 | SIMD_FLAGS="$SIMD_FLAGS -msse4.1" |
| 64 | AC_DEFINE(HAVE_SSE4_1,,[Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions]) |
Philipp Maier | e8ae9fc | 2017-03-20 12:08:42 +0100 | [diff] [blame] | 65 | AM_CONDITIONAL(HAVE_SSE4_1, true) |
Philipp Maier | f5bf33b | 2017-03-16 13:12:07 +0100 | [diff] [blame] | 66 | else |
| 67 | AC_MSG_WARN([Your compiler does not support sse4.1 instructions, can you try another compiler?]) |
Philipp Maier | e8ae9fc | 2017-03-20 12:08:42 +0100 | [diff] [blame] | 68 | AM_CONDITIONAL(HAVE_SSE4_1, false) |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 69 | fi |
Thomas Tsou | 3eaae80 | 2013-08-20 19:31:14 -0400 | [diff] [blame] | 70 | ;; |
| 71 | esac |
| 72 | |
| 73 | AC_SUBST(SIMD_FLAGS) |
| 74 | ]) |