comparison fft/fftw/fftw-3.3.4/m4/ax_cc_maxopt.m4 @ 19:26056e866c29

Add FFTW to comparison table
author Chris Cannam
date Tue, 06 Oct 2015 13:08:39 +0100
parents
children
comparison
equal deleted inserted replaced
18:8db794ca3e0b 19:26056e866c29
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="-qtune=auto"
42 AX_CHECK_COMPILER_FLAGS($xlc_opt,
43 CFLAGS="-O3 -qansialias -w $xlc_opt",
44 [CFLAGS="-O3 -qansialias -w"
45 echo "******************************************************"
46 echo "* You seem to have the IBM C compiler. It is *"
47 echo "* recommended for best performance that you use: *"
48 echo "* *"
49 echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
50 echo "* ^^^ ^^^ *"
51 echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
52 echo "* CPU you have. (Set the CFLAGS environment var. *"
53 echo "* and re-run configure.) For more info, man cc. *"
54 echo "******************************************************"])
55 ;;
56
57 intel) CFLAGS="-O3"
58 # Intel seems to have changed the spelling of this flag recently
59 icc_ansi_alias="unknown"
60 for flag in -ansi-alias -ansi_alias; do
61 AX_CHECK_COMPILER_FLAGS($flag, [icc_ansi_alias=$flag; break])
62 done
63 if test "x$icc_ansi_alias" != xunknown; then
64 CFLAGS="$CFLAGS $icc_ansi_alias"
65 fi
66 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
67 # We used to check for architecture flags here, e.g. -xHost etc.,
68 # but these flags are problematic. On icc-12.0.0, "-mavx -xHost"
69 # overrides -mavx with -xHost, generating SSE2 code instead of AVX
70 # code. ICC does not seem to support -mtune=host or equivalent
71 # non-ABI changing flag.
72 ;;
73
74 gnu)
75 # Default optimization flags for gcc on all systems.
76 # Somehow -O3 does not imply -fomit-frame-pointer on ia32
77 CFLAGS="-O3 -fomit-frame-pointer"
78
79 # tune for the host by default
80 AX_CHECK_COMPILER_FLAGS(-mtune=native, CFLAGS="$CFLAGS -mtune=native")
81
82 # -malign-double for x86 systems
83 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
84
85 # -fstrict-aliasing for gcc-2.95+
86 AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
87 CFLAGS="$CFLAGS -fstrict-aliasing")
88
89 # -fno-schedule-insns is pretty much required on all risc
90 # processors.
91 #
92 # gcc performs one pass of instruction scheduling, then a pass of
93 # register allocation, then another pass of instruction
94 # scheduling. The first pass reorders instructions in a way that
95 # is pretty much the worst possible for the purposes of register
96 # allocation. We disable the first pass.
97 AX_CHECK_COMPILER_FLAGS(-fno-schedule-insns, CFLAGS="$CFLAGS -fno-schedule-insns")
98
99 # note that we enable "unsafe" fp optimization with other compilers, too
100 AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
101
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 ])