8000 Backport gh-6243 by charris · Pull Request #6340 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Backport gh-6243 #6340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MSVCCompiler overwrite 'lib' and 'include' environment variables. This
behavior affect at least python 3.5 and SciPy build and build failed.
During initialization <python>.distutils.MSVCCompiler replace Intel
environment('include' and 'lib' paths). This fix decorate 'initialize'
function in MSVCCompiler and extend 'lib' and 'include' environment
variables. Changed compilation keys: generate optimized code
specialized for Intel processors with SSE4.2 support.
  • Loading branch information
dmitrii-zagornyi authored and charris committed Sep 22, 2015
commit 7cba81b77555bbf439f7b2f68c4e0e7cd5ca7f62
2 changes: 1 addition & 1 deletion numpy/distutils/fcompiler/compaq.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
29 changes: 14 additions & 15 deletions numpy/distutils/fcompiler/intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'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,))
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -120,11 +120,10 @@ def get_flags(self):
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?
Expand All @@ -145,26 +144,26 @@ def update_executables(self):

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):
opt = ['/nologo', '/MD', '/nbs', '/names:lowercase', '/assume:underscore']
return opt

def get_flags_free(self):
return ["-FR"]
return []

def get_flags_debug(self):
return ['/4Yb', '/d2']
Expand All @@ -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 = {
Expand All @@ -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__':
Expand Down
33 changes: 16 additions & 17 deletions numpy/distutils/intelccompiler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from __future__ import division, absolute_import, print_function

import sys
import platform

from distutils.unixccompiler import UnixCCompiler
if platform.system() == 'Windows':
from numpy.distutils.msvc9compiler import MSVCCompiler
from numpy.distutils.exec_command import find_executable
from numpy.distutils.ccompiler import simple_version_match

Expand All @@ -15,14 +17,14 @@ 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):
Expand All @@ -40,24 +42,22 @@ class IntelEM64TCCompiler(UnixCCompiler):
A modifi 8000 ed 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.
Expand All @@ -72,11 +72,11 @@ def __init__(self, verbose=0, dry_run=0, force=0):

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']

Expand All @@ -91,4 +91,3 @@ def __init__(self, verbose=0, dry_run=0, force=0):
MSVCCompiler.__init__(self, verbose, dry_run, force)
version_match = simple_version_match(start='Intel\(R\).*?64,')
self.__version = version_match

21 changes: 21 additions & 0 deletions numpy/distutils/msvc9compiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from distutils.msvccompiler import *
from distutils.msvc9compiler import MSVCCompiler as distutils_MSVCCompiler


class MSVCCompiler(distutils_MSVCCompiler):
def __init__(self, verbose=0, dry_run=0, force=0):
distutils_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.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_MSVCCompiler.manifest_setup_ldargs(self, output_filename, build_temp, ld_args)
17 changes: 17 additions & 0 deletions numpy/distutils/msvccompiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from distutils.msvccompiler import *
from distutils.msvccompiler import MSVCCompiler as distutils_MSVCCompiler


class MSVCCompiler(distutils_MSVCCompiler):
def __init__(self, verbose=0, dry_run=0, force=0):
distutils_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.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']
4 changes: 2 additions & 2 deletions numpy/distutils/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,8 @@ def __init__(self):
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'
Expand Down
0