intelccompiler.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import platform
  2. from distutils.unixccompiler import UnixCCompiler
  3. from numpy.distutils.exec_command import find_executable
  4. from numpy.distutils.ccompiler import simple_version_match
  5. if platform.system() == 'Windows':
  6. from numpy.distutils.msvc9compiler import MSVCCompiler
  7. class IntelCCompiler(UnixCCompiler):
  8. """A modified Intel compiler compatible with a GCC-built Python."""
  9. compiler_type = 'intel'
  10. cc_exe = 'icc'
  11. cc_args = 'fPIC'
  12. def __init__(self, verbose=0, dry_run=0, force=0):
  13. UnixCCompiler.__init__(self, verbose, dry_run, force)
  14. v = self.get_version()
  15. mpopt = 'openmp' if v and v < '15' else 'qopenmp'
  16. self.cc_exe = ('icc -fPIC -fp-model strict -O3 '
  17. '-fomit-frame-pointer -{}').format(mpopt)
  18. compiler = self.cc_exe
  19. if platform.system() == 'Darwin':
  20. shared_flag = '-Wl,-undefined,dynamic_lookup'
  21. else:
  22. shared_flag = '-shared'
  23. self.set_executables(compiler=compiler,
  24. compiler_so=compiler,
  25. compiler_cxx=compiler,
  26. archiver='xiar' + ' cru',
  27. linker_exe=compiler + ' -shared-intel',
  28. linker_so=compiler + ' ' + shared_flag +
  29. ' -shared-intel')
  30. class IntelItaniumCCompiler(IntelCCompiler):
  31. compiler_type = 'intele'
  32. cc_exe = 'icc'
  33. class IntelEM64TCCompiler(UnixCCompiler):
  34. """
  35. A modified Intel x86_64 compiler compatible with a 64bit GCC-built Python.
  36. """
  37. compiler_type = 'intelem'
  38. cc_exe = 'icc -m64'
  39. cc_args = '-fPIC'
  40. def __init__(self, verbose=0, dry_run=0, force=0):
  41. UnixCCompiler.__init__(self, verbose, dry_run, force)
  42. v = self.get_version()
  43. mpopt = 'openmp' if v and v < '15' else 'qopenmp'
  44. self.cc_exe = ('icc -std=c99 -m64 -fPIC -fp-model strict -O3 '
  45. '-fomit-frame-pointer -{}').format(mpopt)
  46. compiler = self.cc_exe
  47. if platform.system() == 'Darwin':
  48. shared_flag = '-Wl,-undefined,dynamic_lookup'
  49. else:
  50. shared_flag = '-shared'
  51. self.set_executables(compiler=compiler,
  52. compiler_so=compiler,
  53. compiler_cxx=compiler,
  54. archiver='xiar' + ' cru',
  55. linker_exe=compiler + ' -shared-intel',
  56. linker_so=compiler + ' ' + shared_flag +
  57. ' -shared-intel')
  58. if platform.system() == 'Windows':
  59. class IntelCCompilerW(MSVCCompiler):
  60. """
  61. A modified Intel compiler compatible with an MSVC-built Python.
  62. """
  63. compiler_type = 'intelw'
  64. compiler_cxx = 'icl'
  65. def __init__(self, verbose=0, dry_run=0, force=0):
  66. MSVCCompiler.__init__(self, verbose, dry_run, force)
  67. version_match = simple_version_match(start=r'Intel\(R\).*?32,')
  68. self.__version = version_match
  69. def initialize(self, plat_name=None):
  70. MSVCCompiler.initialize(self, plat_name)
  71. self.cc = self.find_exe('icl.exe')
  72. self.lib = self.find_exe('xilib')
  73. self.linker = self.find_exe('xilink')
  74. self.compile_options = ['/nologo', '/O3', '/MD', '/W3',
  75. '/Qstd=c99']
  76. self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
  77. '/Qstd=c99', '/Z7', '/D_DEBUG']
  78. class IntelEM64TCCompilerW(IntelCCompilerW):
  79. """
  80. A modified Intel x86_64 compiler compatible with
  81. a 64bit MSVC-built Python.
  82. """
  83. compiler_type = 'intelemw'
  84. def __init__(self, verbose=0, dry_run=0, force=0):
  85. MSVCCompiler.__init__(self, verbose, dry_run, force)
  86. version_match = simple_version_match(start=r'Intel\(R\).*?64,')
  87. self.__version = version_match