comparison src/fftw-3.3.8/m4/ax_cc_maxopt.m4 @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
1 dnl @synopsis AX_CC_MAXOPT
2 dnl @summary turn on optimization flags for the C compiler
3 dnl @category C
4 dnl
5 dnl Try to turn on "good" C optimization flags for various compilers
6 dnl and architectures, for some definition of "good". (In our case,
7 dnl good for FFTW and hopefully for other scientific codes. Modify
8 dnl as needed.)
9 dnl
10 dnl The user can override the flags by setting the CFLAGS environment
11 dnl variable.
12 dnl
13 dnl Note also that the flags assume that ANSI C aliasing rules are
14 dnl followed by the code (e.g. for gcc's -fstrict-aliasing), and that
15 dnl floating-point computations can be re-ordered as needed.
16 dnl
17 dnl Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
18 dnl
19 dnl @version 2011-06-22
20 dnl @license GPLWithACException
21 dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Matteo Frigo.
22 AC_DEFUN([AX_CC_MAXOPT],
23 [
24 AC_REQUIRE([AC_PROG_CC])
25 AC_REQUIRE([AX_COMPILER_VENDOR])
26 AC_REQUIRE([AC_CANONICAL_HOST])
27
28 # Try to determine "good" native compiler flags if none specified via CFLAGS
29 if test "$ac_test_CFLAGS" != "set"; then
30 CFLAGS=""
31 case $ax_cv_c_compiler_vendor in
32 dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
33 ;;
34
35 sun) CFLAGS="-native -fast -xO5 -dalign"
36 ;;
37
38 hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
39 ;;
40
41 ibm) xlc_opt="-qarch=auto -qtune=auto"
42 AX_CHECK_COMPILER_FLAGS($xlc_opt,
43 CFLAGS="-O3 -qalias=ansi -w $xlc_opt",
44 [CFLAGS="-O3 -qalias=ansi -w"])
45 ;;
46
47 intel) CFLAGS="-O3"
48 # Intel seems to have changed the spelling of this flag recently
49 icc_ansi_alias="unknown"
50 for flag in -ansi-alias -ansi_alias; do
51 AX_CHECK_COMPILER_FLAGS($flag, [icc_ansi_alias=$flag; break])
52 done
53 if test "x$icc_ansi_alias" != xunknown; then
54 CFLAGS="$CFLAGS $icc_ansi_alias"
55 fi
56 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
57 # We used to check for architecture flags here, e.g. -xHost etc.,
58 # but these flags are problematic. On icc-12.0.0, "-mavx -xHost"
59 # overrides -mavx with -xHost, generating SSE2 code instead of AVX
60 # code. ICC does not seem to support -mtune=host or equivalent
61 # non-ABI changing flag.
62 ;;
63
64 clang)
65 CFLAGS="-O3 -fomit-frame-pointer"
66 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
67 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,CFLAGS="$CFLAGS -fstrict-aliasing")
68 ;;
69
70 gnu)
71 # Default optimization flags for gcc on all systems.
72 # Somehow -O3 does not imply -fomit-frame-pointer on ia32
73 CFLAGS="-O3 -fomit-frame-pointer"
74
75 # tune for the host by default
76 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
77
78 # -malign-double for x86 systems
79 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
80
81 # -fstrict-aliasing for gcc-2.95+
82 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
83 CFLAGS="$CFLAGS -fstrict-aliasing")
84
85 # -fno-schedule-insns is pretty much required on all risc
86 # processors.
87 #
88 # gcc performs one pass of instruction scheduling, then a pass of
89 # register allocation, then another pass of instruction
90 # scheduling. The first pass reorders instructions in a way that
91 # is pretty much the worst possible for the purposes of register
92 # allocation. We disable the first pass.
93 AX_CHECK_COMPILER_FLAGS(-fno-schedule-insns, CFLAGS="$CFLAGS -fno-schedule-insns")
94
95 # flags to enable power ISA 2.07 instructions with gcc (always true with vsx)
96 if test "$have_vsx" = "yes"; then
97 AX_CHECK_COMPILER_FLAGS(-mcpu=power8, CFLAGS="$CFLAGS -mcpu=power8")
98 AX_CHECK_COMPILER_FLAGS(-mpower8-fusion, CFLAGS="$CFLAGS -mpower8-fusion")
99 AX_CHECK_COMPILER_FLAGS(-mpower8-vector, CFLAGS="$CFLAGS -mpower8-vector")
100 AX_CHECK_COMPILER_FLAGS(-mdirect-move, CFLAGS="$CFLAGS -mdirect-move")
101 fi
102 ;;
103 esac
104
105 if test -z "$CFLAGS"; then
106 echo ""
107 echo "********************************************************"
108 echo "* WARNING: Don't know the best CFLAGS for this system *"
109 echo "* Use ./configure CFLAGS=... to specify your own flags *"
110 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
111 echo "********************************************************"
112 echo ""
113 CFLAGS="-O3"
114 fi
115
116 AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
117 echo ""
118 echo "********************************************************"
119 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
120 echo "* your compiler. *"
121 echo "* Use ./configure CFLAGS=... to specify your own flags *"
122 echo "********************************************************"
123 echo ""
124 CFLAGS=""
125 ])
126
127 fi
128 ])