File: ax_cc_maxopt.html

package info (click to toggle)
autoconf-archive 20060312-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,180 kB
  • ctags: 13
  • sloc: sh: 455; makefile: 44
file content (200 lines) | stat: -rw-r--r-- 6,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
 <head>
  <title>
   Autoconf Macro: ax_cc_maxopt
  </title>
  <link rel="stylesheet" type="text/css" href="ac-archive.css">
 </head>
 <body>
  <table summary="web navigation" style="width:100%;">
   <tbody>
    <tr>
     <td style="width:50%;" align="center">
      <a href="http://autoconf-archive.cryp.to/ax_cc_maxopt.m4">Download M4
      Source</a>
     </td>
     <td style="width:50%;" align="center">
      <a href="macros-by-category.html">Macro Index Page</a>
     </td>
    </tr>
   </tbody>
  </table>
  <hr>
  <h1>
   ax_cc_maxopt
  </h1>
  <h2>
   Synopsis
  </h2>
  <p class="indent" style="white-space:nowrap;">
   <code>AX_CC_MAXOPT</code>
  </p>
  <h2>
   Description
  </h2>
  <div class="indent">
   <p>
    Try to turn on "good" C optimization flags for various compilers and
    architectures, for some definition of "good". (In our case, good for FFTW
    and hopefully for other scientific codes. Modify as needed.)
   </p>
   <p>
    The user can override the flags by setting the CFLAGS environment variable.
    The user can also specify --enable-portable-binary in order to disable any
    optimization flags that might result in a binary that only runs on the host
    architecture.
   </p>
   <p>
    Note also that the flags assume that ANSI C aliasing rules are followed by
    the code (e.g. for gcc's -fstrict-aliasing), and that floating-point
    computations can be re-ordered as needed.
   </p>
   <p>
    Requires macros: AX_CHECK_COMPILER_FLAGS, AX_COMPILER_VENDOR,
    AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID.
   </p>
  </div>
  <h2>
   Author
  </h2>
  <p class="indent">
   Steven G. Johnson &lt;stevenj@alum.mit.edu&gt; and Matteo Frigo.
  </p>
  <h2>
   Last Modified
  </h2>
  <p class="indent">
   2005-05-30
  </p>
  <h2>
   M4 Source Code
  </h2>
  <div class="indent">
   <pre class="m4source">
AC_DEFUN([AX_CC_MAXOPT],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([AC_CANONICAL_HOST])

AC_ARG_ENABLE(portable-binary, [AC_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
        acx_maxopt_portable=$withval, acx_maxopt_portable=no)

# Try to determine "good" native compiler flags if none specified via CFLAGS
if test "$ac_test_CFLAGS" != "set"; then
  CFLAGS=""
  case $ax_cv_c_compiler_vendor in
    dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
         if test "x$acx_maxopt_portable" = xno; then
           CFLAGS="$CFLAGS -arch host"
         fi;;

    sun) CFLAGS="-native -fast -xO5 -dalign"
         if test "x$acx_maxopt_portable" = xyes; then
           CFLAGS="$CFLAGS -xarch=generic"
         fi;;

    hp)  CFLAGS="+Oall +Optrs_ansi +DSnative"
         if test "x$acx_maxopt_portable" = xyes; then
           CFLAGS="$CFLAGS +DAportable"
         fi;;

    ibm) if test "x$acx_maxopt_portable" = xno; then
           xlc_opt="-qarch=auto -qtune=auto"
         else
           xlc_opt="-qtune=auto"
         fi
         AX_CHECK_COMPILER_FLAGS($xlc_opt,
                CFLAGS="-O3 -qansialias -w $xlc_opt",
               [CFLAGS="-O3 -qansialias -w"
                echo "******************************************************"
                echo "*  You seem to have the IBM  C compiler.  It is      *"
                echo "*  recommended for best performance that you use:    *"
                echo "*                                                    *"
                echo "*    CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
                echo "*                      ^^^        ^^^                *"
                echo "*  where xxx is pwr2, pwr3, 604, or whatever kind of *"
                echo "*  CPU you have.  (Set the CFLAGS environment var.   *"
                echo "*  and re-run configure.)  For more info, man cc.    *"
                echo "******************************************************"])
         ;;

    intel) CFLAGS="-O3 -ansi_alias"
        if test "x$acx_maxopt_portable" = xno; then
          icc_archflag=unknown
          icc_flags=""
          case $host_cpu in
            i686*|x86_64*)
              # icc accepts gcc assembly syntax, so these should work:
              AX_GCC_X86_CPUID(0)
              AX_GCC_X86_CPUID(1)
              case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
                *:756e6547:*:*) # Intel
                  case $ax_cv_gcc_x86_cpuid_1 in
                    *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
                    *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
                    *f??:*:*:*) icc_flags="-xN -xW -xK";;
                  esac ;;
              esac ;;
          esac
          if test "x$icc_flags" != x; then
            for flag in $icc_flags; do
              AX_CHECK_COMPILER_FLAGS($flag, [icc_archflag=$flag; break])
            done
          fi
          AC_MSG_CHECKING([for icc architecture flag])
          AC_MSG_RESULT($icc_archflag)
          if test "x$icc_archflag" != xunknown; then
            CFLAGS="$CFLAGS $icc_archflag"
          fi
        fi
        ;;

    gnu)
     # default optimization flags for gcc on all systems
     CFLAGS="-O3 -fomit-frame-pointer"

     # -malign-double for x86 systems
     AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")

     #  -fstrict-aliasing for gcc-2.95+
     AX_CHECK_COMPILER_FLAGS(-fstrict-aliasing,
        CFLAGS="$CFLAGS -fstrict-aliasing")

     # note that we enable "unsafe" fp optimization with other compilers, too
     AX_CHECK_COMPILER_FLAGS(-ffast-math, CFLAGS="$CFLAGS -ffast-math")

     AX_GCC_ARCHFLAG($acx_maxopt_portable)
     ;;
  esac

  if test -z "$CFLAGS"; then
        echo ""
        echo "********************************************************"
        echo "* WARNING: Don't know the best CFLAGS for this system  *"
        echo "* Use ./configure CFLAGS=... to specify your own flags *"
        echo "* (otherwise, a default of CFLAGS=-O3 will be used)    *"
        echo "********************************************************"
        echo ""
        CFLAGS="-O3"
  fi

  AX_CHECK_COMPILER_FLAGS($CFLAGS, [], [
        echo ""
        echo "********************************************************"
        echo "* WARNING: The guessed CFLAGS don't seem to work with  *"
        echo "* your compiler.                                       *"
        echo "* Use ./configure CFLAGS=... to specify your own flags *"
        echo "********************************************************"
        echo ""
        CFLAGS=""
  ])

fi
])
</pre>
  </div>
 </body>
</html>