diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-09-22 14:42:36 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-09-22 14:42:36 -0600 |
commit | 941a4e037d394dada43e3c2beef1e650d5505742 (patch) | |
tree | 566c8b79bfa64d8b9cf12976ca616b292a53f586 | |
parent | 81ed748a9ef98625b18edea83c4762a8959adce4 (diff) | |
parent | 5ef26af9209f206c36329e0b2585b4ebdbb5f5fd (diff) | |
download | numpy-941a4e037d394dada43e3c2beef1e650d5505742.tar.gz |
Merge pull request #6243 from dzagorny/intel-distutils-fixes
BLD: Intel distutils fixes
-rw-r--r-- | numpy/distutils/exec_command.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/compaq.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/intel.py | 29 | ||||
-rw-r--r-- | numpy/distutils/intelccompiler.py | 35 | ||||
-rw-r--r-- | numpy/distutils/msvc9compiler.py | 23 | ||||
-rw-r--r-- | numpy/distutils/msvccompiler.py | 17 | ||||
-rw-r--r-- | numpy/distutils/npy_pkg_config.py | 43 | ||||
-rw-r--r-- | numpy/distutils/system_info.py | 4 |
8 files changed, 92 insertions, 63 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index f751a8ca3..9fa09cd51 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -441,8 +441,10 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): se_flush() if _so_has_fileno: os.dup2(so_dup, so_fileno) + os.close(so_dup) if _se_has_fileno: os.dup2(se_dup, se_fileno) + os.close(se_dup) fout.close() fout = open_latin1(outfile, 'r') diff --git a/numpy/distutils/fcompiler/compaq.py b/numpy/distutils/fcompiler/compaq.py index 5162b168c..2dd6c01e6 100644 --- a/numpy/distutils/fcompiler/compaq.py +++ b/numpy/distutils/fcompiler/compaq.py @@ -74,7 +74,7 @@ class CompaqVisualFCompiler(FCompiler): fc_exe = 'DF' if sys.platform=='win32': - from distutils.msvccompiler import MSVCCompiler + from numpy.distutils.msvccompiler import MSVCCompiler try: m = MSVCCompiler() diff --git a/numpy/distutils/fcompiler/intel.py b/numpy/distutils/fcompiler/intel.py index ef0bcc30b..28624918d 100644 --- a/numpy/distutils/fcompiler/intel.py +++ b/numpy/distutils/fcompiler/intel.py @@ -10,6 +10,7 @@ compilers = ['IntelFCompiler', 'IntelVisualFCompiler', 'IntelItaniumFCompiler', 'IntelItaniumVisualFCompiler', 'IntelEM64VisualFCompiler', 'IntelEM64TFCompiler'] + def intel_version_match(type): # Match against the important stuff in the version string return simple_version_match(start=r'Intel.*?Fortran.*?(?:%s).*?Version' % (type,)) @@ -45,17 +46,16 @@ class IntelFCompiler(BaseIntelFCompiler): } pic_flags = ['-fPIC'] - module_dir_switch = '-module ' # Don't remove ending space! + module_dir_switch = '-module ' # Don't remove ending space! module_include_switch = '-I' def get_flags_free(self): - return ["-FR"] + return ['-FR'] def get_flags(self): return ['-fPIC'] def get_flags_opt(self): - #return ['-i8 -xhost -openmp -fp-model strict'] return ['-xhost -openmp -fp-model strict'] def get_flags_arch(self): @@ -120,11 +120,10 @@ class IntelEM64TFCompiler(IntelFCompiler): return ['-fPIC'] def get_flags_opt(self): - #return ['-i8 -xhost -openmp -fp-model strict'] - return ['-xhost -openmp -fp-model strict'] + return ['-openmp -fp-model strict'] def get_flags_arch(self): - return [] + return ['-xSSE4.2'] # Is there no difference in the version string between the above compilers # and the Visual compilers? @@ -145,18 +144,18 @@ class IntelVisualFCompiler(BaseIntelFCompiler): executables = { 'version_cmd' : None, - 'compiler_f77' : [None, "-FI", "-w90", "-w95"], - 'compiler_fix' : [None, "-FI", "-4L72", "-w"], + 'compiler_f77' : [None], + 'compiler_fix' : [None], 'compiler_f90' : [None], - 'linker_so' : ['<F90>', "-shared"], + 'linker_so' : [None], 'archiver' : [ar_exe, "/verbose", "/OUT:"], 'ranlib' : None } compile_switch = '/c ' - object_switch = '/Fo' #No space after /Fo! - library_switch = '/OUT:' #No space after /OUT:! - module_dir_switch = '/module:' #No space after /module: + object_switch = '/Fo' # No space after /Fo! + library_switch = '/OUT:' # No space after /OUT:! + module_dir_switch = '/module:' # No space after /module: module_include_switch = '/I' def get_flags(self): @@ -164,7 +163,7 @@ class IntelVisualFCompiler(BaseIntelFCompiler): return opt def get_flags_free(self): - return ["-FR"] + return [] def get_flags_debug(self): return ['/4Yb', '/d2'] @@ -185,7 +184,7 @@ class IntelItaniumVisualFCompiler(IntelVisualFCompiler): version_match = intel_version_match('Itanium') - possible_executables = ['efl'] # XXX this is a wild guess + possible_executables = ['efl'] # XXX this is a wild guess ar_exe = IntelVisualFCompiler.ar_exe executables = { @@ -206,7 +205,7 @@ class IntelEM64VisualFCompiler(IntelVisualFCompiler): version_match = simple_version_match(start='Intel\(R\).*?64,') def get_flags_arch(self): - return ["/arch:SSE2"] + return ['/QxSSE4.2'] if __name__ == '__main__': diff --git a/numpy/distutils/intelccompiler.py b/numpy/distutils/intelccompiler.py index db6ef80bd..a1f34e304 100644 --- a/numpy/distutils/intelccompiler.py +++ b/numpy/distutils/intelccompiler.py @@ -1,10 +1,12 @@ from __future__ import division, absolute_import, print_function -import sys +import platform from distutils.unixccompiler import UnixCCompiler from numpy.distutils.exec_command import find_executable from numpy.distutils.ccompiler import simple_version_match +if platform.system() == 'Windows': + from numpy.distutils.msvc9compiler import MSVCCompiler class IntelCCompiler(UnixCCompiler): @@ -15,14 +17,15 @@ class IntelCCompiler(UnixCCompiler): def __init__(self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__(self, verbose, dry_run, force) - self.cc_exe = 'icc -fPIC' + self.cc_exe = ('icc -fPIC -fp-model strict -O3 ' + '-fomit-frame-pointer -openmp') compiler = self.cc_exe self.set_executables(compiler=compiler, compiler_so=compiler, compiler_cxx=compiler, archiver='xiar' + ' cru', - linker_exe=compiler, - linker_so=compiler + ' -shared') + linker_exe=compiler + ' -shared-intel', + linker_so=compiler + ' -shared -shared-intel') class IntelItaniumCCompiler(IntelCCompiler): @@ -40,24 +43,23 @@ class IntelEM64TCCompiler(UnixCCompiler): A modified Intel x86_64 compiler compatible with a 64bit GCC-built Python. """ compiler_type = 'intelem' - cc_exe = 'icc -m64 -fPIC' - cc_args = "-fPIC" + cc_exe = 'icc -m64' + cc_args = '-fPIC' def __init__(self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__(self, verbose, dry_run, force) - self.cc_exe = 'icc -m64 -fPIC' + self.cc_exe = ('icc -m64 -fPIC -fp-model strict -O3 ' + '-fomit-frame-pointer -openmp -xSSE4.2') compiler = self.cc_exe self.set_executables(compiler=compiler, compiler_so=compiler, compiler_cxx=compiler, archiver='xiar' + ' cru', - linker_exe=compiler, - linker_so=compiler + ' -shared') + linker_exe=compiler + ' -shared-intel', + linker_so=compiler + ' -shared -shared-intel') -if sys.platform == 'win32': - from distutils.msvc9compiler import MSVCCompiler - +if platform.system() == 'Windows': class IntelCCompilerW(MSVCCompiler): """ A modified Intel compiler compatible with an MSVC-built Python. @@ -72,11 +74,11 @@ if sys.platform == 'win32': def initialize(self, plat_name=None): MSVCCompiler.initialize(self, plat_name) - self.cc = self.find_exe("icl.exe") - self.lib = self.find_exe("xilib") - self.linker = self.find_exe("xilink") + self.cc = self.find_exe('icl.exe') + self.lib = self.find_exe('xilib') + self.linker = self.find_exe('xilink') self.compile_options = ['/nologo', '/O3', '/MD', '/W3', - '/Qstd=c99'] + '/Qstd=c99', '/QxSSE4.2'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/Qstd=c99', '/Z7', '/D_DEBUG'] @@ -91,4 +93,3 @@ if sys.platform == 'win32': MSVCCompiler.__init__(self, verbose, dry_run, force) version_match = simple_version_match(start='Intel\(R\).*?64,') self.__version = version_match - diff --git a/numpy/distutils/msvc9compiler.py b/numpy/distutils/msvc9compiler.py new file mode 100644 index 000000000..636165bd5 --- /dev/null +++ b/numpy/distutils/msvc9compiler.py @@ -0,0 +1,23 @@ +import os +import distutils.msvc9compiler +from distutils.msvc9compiler import * + + +class MSVCCompiler(distutils.msvc9compiler.MSVCCompiler): + def __init__(self, verbose=0, dry_run=0, force=0): + distutils.msvc9compiler.MSVCCompiler.__init__(self, verbose, dry_run, force) + + def initialize(self, plat_name=None): + environ_lib = os.getenv('lib') + environ_include = os.getenv('include') + distutils.msvc9compiler.MSVCCompiler.initialize(self, plat_name) + if environ_lib is not None: + os.environ['lib'] = environ_lib + os.environ['lib'] + if environ_include is not None: + os.environ['include'] = environ_include + os.environ['include'] + + def manifest_setup_ldargs(self, output_filename, build_temp, ld_args): + ld_args.append('/MANIFEST') + distutils.msvc9compiler.MSVCCompiler.manifest_setup_ldargs(self, + output_filename, + build_temp, ld_args) diff --git a/numpy/distutils/msvccompiler.py b/numpy/distutils/msvccompiler.py new file mode 100644 index 000000000..0d28f6b9f --- /dev/null +++ b/numpy/distutils/msvccompiler.py @@ -0,0 +1,17 @@ +import os +import distutils.msvccompiler +from distutils.msvccompiler import * + + +class MSVCCompiler(distutils.msvccompiler.MSVCCompiler): + def __init__(self, verbose=0, dry_run=0, force=0): + distutils.msvccompiler.MSVCCompiler.__init__(self, verbose, dry_run, force) + + def initialize(self, plat_name=None): + environ_lib = os.getenv('lib') + environ_include = os.getenv('include') + distutils.msvccompiler.MSVCCompiler.initialize(self, plat_name) + if environ_lib is not None: + os.environ['lib'] = environ_lib + os.environ['lib'] + if environ_include is not None: + os.environ['include'] = environ_include + os.environ['include'] diff --git a/numpy/distutils/npy_pkg_config.py b/numpy/distutils/npy_pkg_config.py index ceab906a4..6156439e1 100644 --- a/numpy/distutils/npy_pkg_config.py +++ b/numpy/distutils/npy_pkg_config.py @@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function import sys import re import os -import shlex if sys.version_info[0] < 3: from ConfigParser import SafeConfigParser, NoOptionError @@ -56,35 +55,23 @@ def parse_flags(line): * 'ignored' """ - lexer = shlex.shlex(line) - lexer.whitespace_split = True - d = {'include_dirs': [], 'library_dirs': [], 'libraries': [], - 'macros': [], 'ignored': []} - def next_token(t): - if t.startswith('-I'): - if len(t) > 2: - d['include_dirs'].append(t[2:]) - else: - t = lexer.get_token() - d['include_dirs'].append(t) - elif t.startswith('-L'): - if len(t) > 2: - d['library_dirs'].append(t[2:]) + 'macros': [], 'ignored': []} + + flags = (' ' + line).split(' -') + for flag in flags: + flag = '-' + flag + if len(flag) > 0: + if flag.startswith('-I'): + d['include_dirs'].append(flag[2:].strip()) + elif flag.startswith('-L'): + d['library_dirs'].append(flag[2:].strip()) + elif flag.startswith('-l'): + d['libraries'].append(flag[2:].strip()) + elif flag.startswith('-D'): + d['macros'].append(flag[2:].strip()) else: - t = lexer.get_token() - d['library_dirs'].append(t) - elif t.startswith('-l'): - d['libraries'].append(t[2:]) - elif t.startswith('-D'): - d['macros'].append(t[2:]) - else: - d['ignored'].append(t) - return lexer.get_token() - - t = lexer.get_token() - while t: - t = next_token(t) + d['ignored'].append(flag) return d diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index be94c8704..9dd48e2dc 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -999,8 +999,8 @@ class mkl_info(system_info): plt = '64' #l = 'mkl_ipf' elif cpu.is_Xeon(): - plt = 'em64t' - #l = 'mkl_em64t' + plt = 'intel64' + #l = 'mkl_intel64' else: plt = '32' #l = 'mkl_ia32' |