~ubuntu-branches/ubuntu/feisty/python-numpy/feisty

« back to all changes in this revision

Viewing changes to numpy/distutils/fcompiler/intel.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-12 10:00:24 UTC
  • Revision ID: james.westby@ubuntu.com-20060712100024-5lw9q2yczlisqcrt
Tags: upstream-0.9.8
ImportĀ upstreamĀ versionĀ 0.9.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# http://developer.intel.com/software/products/compilers/flin/
 
2
 
 
3
import os
 
4
import sys
 
5
 
 
6
from numpy.distutils.cpuinfo import cpu
 
7
from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
 
8
from numpy.distutils.exec_command import find_executable
 
9
 
 
10
class IntelFCompiler(FCompiler):
 
11
 
 
12
    compiler_type = 'intel'
 
13
    version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit '\
 
14
                      'applications, Version (?P<version>[^\s*]*)'
 
15
 
 
16
    for fc_exe in map(find_executable,['ifort','ifc']):
 
17
        if os.path.isfile(fc_exe):
 
18
            break
 
19
 
 
20
    executables = {
 
21
        'version_cmd'  : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
 
22
                          % {'fname':dummy_fortran_file()}],
 
23
        'compiler_f77' : [fc_exe,"-72","-w90","-w95"],
 
24
        'compiler_fix' : [fc_exe,"-FI"],
 
25
        'compiler_f90' : [fc_exe],
 
26
        'linker_so'    : [fc_exe,"-shared"],
 
27
        'archiver'     : ["ar", "-cr"],
 
28
        'ranlib'       : ["ranlib"]
 
29
        }
 
30
 
 
31
    pic_flags = ['-KPIC']
 
32
    module_dir_switch = '-module ' # Don't remove ending space!
 
33
    module_include_switch = '-I'
 
34
 
 
35
    def get_flags(self):
 
36
        opt = self.pic_flags + ["-cm"]
 
37
        return opt
 
38
 
 
39
    def get_flags_free(self):
 
40
        return ["-FR"]
 
41
 
 
42
    def get_flags_opt(self):
 
43
        return ['-O3','-unroll']
 
44
 
 
45
    def get_flags_arch(self):
 
46
        opt = []
 
47
        if cpu.has_fdiv_bug():
 
48
            opt.append('-fdiv_check')
 
49
        if cpu.has_f00f_bug():
 
50
            opt.append('-0f_check')
 
51
        if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():
 
52
            opt.extend(['-tpp6'])
 
53
        elif cpu.is_PentiumM():
 
54
            opt.extend(['-tpp7','-xB'])
 
55
        elif cpu.is_Pentium():
 
56
            opt.append('-tpp5')
 
57
        elif cpu.is_PentiumIV() or cpu.is_Xeon():
 
58
            opt.extend(['-tpp7','-xW'])
 
59
        if cpu.has_mmx() and not cpu.is_Xeon():
 
60
            opt.append('-xM')
 
61
        if cpu.has_sse2():
 
62
            opt.append('-arch SSE2')
 
63
        elif cpu.has_sse():
 
64
            opt.append('-arch SSE')
 
65
        return opt
 
66
 
 
67
    def get_flags_linker_so(self):
 
68
        opt = FCompiler.get_flags_linker_so(self)
 
69
        v = self.get_version()
 
70
        if v and v >= '8.0':
 
71
            opt.append('-nofor_main')
 
72
        opt.extend(self.get_flags_arch())
 
73
        return opt
 
74
 
 
75
class IntelItaniumFCompiler(IntelFCompiler):
 
76
    compiler_type = 'intele'
 
77
    version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
 
78
                      ' for the Itanium\(TM\)-based applications,'\
 
79
                      ' Version (?P<version>[^\s*]*)'
 
80
 
 
81
    for fc_exe in map(find_executable,['ifort','efort','efc']):
 
82
        if os.path.isfile(fc_exe):
 
83
            break
 
84
 
 
85
    executables = {
 
86
        'version_cmd'  : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
 
87
                          % {'fname':dummy_fortran_file()}],
 
88
        'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
 
89
        'compiler_fix' : [fc_exe,"-FI"],
 
90
        'compiler_f90' : [fc_exe],
 
91
        'linker_so'    : [fc_exe,"-shared"],
 
92
        'archiver'     : ["ar", "-cr"],
 
93
        'ranlib'       : ["ranlib"]
 
94
        }
 
95
 
 
96
class IntelEM64TFCompiler(IntelFCompiler):
 
97
    compiler_type = 'intelem'
 
98
 
 
99
    version_pattern = r'Intel\(R\) Fortran Compiler for Intel\(R\) EM64T-based '\
 
100
                      'applications, Version (?P<version>[^\s*]*)'
 
101
 
 
102
    for fc_exe in map(find_executable,['ifort','efort','efc']):
 
103
        if os.path.isfile(fc_exe):
 
104
            break
 
105
 
 
106
    executables = {
 
107
        'version_cmd'  : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
 
108
                          % {'fname':dummy_fortran_file()}],
 
109
        'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
 
110
        'compiler_fix' : [fc_exe,"-FI"],
 
111
        'compiler_f90' : [fc_exe],
 
112
        'linker_so'    : [fc_exe,"-shared"],
 
113
        'archiver'     : ["ar", "-cr"],
 
114
        'ranlib'       : ["ranlib"]
 
115
        }
 
116
 
 
117
class IntelVisualFCompiler(FCompiler):
 
118
 
 
119
    compiler_type = 'intelv'
 
120
    version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit applications, '\
 
121
                      'Version (?P<version>[^\s*]*)'
 
122
 
 
123
    ar_exe = 'lib.exe'
 
124
    fc_exe = 'ifl'
 
125
    if sys.platform=='win32':
 
126
        from distutils.msvccompiler import MSVCCompiler
 
127
        ar_exe = MSVCCompiler().lib
 
128
 
 
129
    executables = {
 
130
        'version_cmd'  : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
 
131
                          % {'fname':dummy_fortran_file()}],
 
132
        'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
 
133
        'compiler_fix' : [fc_exe,"-FI","-4L72","-w"],
 
134
        'compiler_f90' : [fc_exe],
 
135
        'linker_so'    : [fc_exe,"-shared"],
 
136
        'archiver'     : [ar_exe, "/verbose", "/OUT:"],
 
137
        'ranlib'       : None
 
138
        }
 
139
 
 
140
    compile_switch = '/c '
 
141
    object_switch = '/Fo'     #No space after /Fo!
 
142
    library_switch = '/OUT:'  #No space after /OUT:!
 
143
    module_dir_switch = '/module:' #No space after /module:
 
144
    module_include_switch = '/I'
 
145
 
 
146
    def get_flags(self):
 
147
        opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']
 
148
        return opt
 
149
 
 
150
    def get_flags_free(self):
 
151
        return ["-FR"]
 
152
 
 
153
    def get_flags_debug(self):
 
154
        return ['/4Yb','/d2']
 
155
 
 
156
    def get_flags_opt(self):
 
157
        return ['/O3','/Qip','/Qipo','/Qipo_obj']
 
158
 
 
159
    def get_flags_arch(self):
 
160
        opt = []
 
161
        if cpu.is_PentiumPro() or cpu.is_PentiumII():
 
162
            opt.extend(['/G6','/Qaxi'])
 
163
        elif cpu.is_PentiumIII():
 
164
            opt.extend(['/G6','/QaxK'])
 
165
        elif cpu.is_Pentium():
 
166
            opt.append('/G5')
 
167
        elif cpu.is_PentiumIV():
 
168
            opt.extend(['/G7','/QaxW'])
 
169
        if cpu.has_mmx():
 
170
            opt.append('/QaxM')
 
171
        return opt
 
172
 
 
173
class IntelItaniumVisualFCompiler(IntelVisualFCompiler):
 
174
 
 
175
    compiler_type = 'intelev'
 
176
    version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
 
177
                      ' for the Itanium\(TM\)-based applications,'\
 
178
                      ' Version (?P<version>[^\s*]*)'
 
179
 
 
180
    fc_exe = 'efl' # XXX this is a wild guess
 
181
    ar_exe = IntelVisualFCompiler.ar_exe
 
182
 
 
183
    executables = {
 
184
        'version_cmd'  : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
 
185
                          % {'fname':dummy_fortran_file()}],
 
186
        'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
 
187
        'compiler_fix' : [fc_exe,"-FI","-4L72","-w"],
 
188
        'compiler_f90' : [fc_exe],
 
189
        'linker_so'    : [fc_exe,"-shared"],
 
190
        'archiver'     : [ar_exe, "/verbose", "/OUT:"],
 
191
        'ranlib'       : None
 
192
        }
 
193
 
 
194
if __name__ == '__main__':
 
195
    from distutils import log
 
196
    log.set_verbosity(2)
 
197
    from numpy.distutils.fcompiler import new_fcompiler
 
198
    compiler = new_fcompiler(compiler='intel')
 
199
    compiler.customize()
 
200
    print compiler.get_version()