-
Notifications
You must be signed in to change notification settings - Fork 7
/
numpyxc.py
73 lines (57 loc) · 2.54 KB
/
numpyxc.py
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
import os, sys
xcprefix = os.environ.get('PYTHONXCPREFIX', None)
if not xcprefix:
raise Exception("Must specify PYTHONXCPREFIX as an argument to make this work")
xcdirflags = "-I{0}/include -L{0}/lib -L{0}/lib/python2.7 " + \
"-L{0}/lib/python2.7/site-packages/numpy/core/lib"
xcdirflags = xcdirflags.format(xcprefix)
import setup
print setup.__file__
from numpy.distutils import fcompiler, ccompiler
from numpy.distutils.intelccompiler import IntelCCompiler
from numpy.distutils.fcompiler.intel import IntelFCompiler
class IntelMICCompiler(IntelCCompiler):
""" A modified Intel compiler compatible with an gcc built Python."""
compiler_type = 'intelmic'
cc_exe = 'icc'
def __init__ (self, verbose=0, dry_run=0, force=0):
IntelCCompiler.__init__ (self, verbose, dry_run, force)
compiler = "icc -mmic -mkl -fPIC -fp-model strict -g " + xcdirflags
self.set_executables(compiler=compiler + ' -shared',
compiler_so=compiler,
compiler_cxx=compiler,
linker_exe=compiler,
linker_so=compiler + ' -shared')
# Export it into a module that is __import__ed by np.distutils.ccompiler
import sys, imp
imc = imp.new_module('numpy.distutils.intelmiccompiler')
sys.modules['numpy.distutils.intelmiccompiler'] = imc
imc.IntelMICCompiler = IntelMICCompiler
# print ccompiler.compiler_class # {name: (module_name, module_member_name, desc), ...}
ccompiler.compiler_class['intelmic'] = ('intelmiccompiler', 'IntelMICCompiler', 'Intel Compiler for Xeon Phi')
class IntelMICFCompiler(IntelFCompiler):
compiler_type = 'intelmic'
compiler_aliases = ()
description = "Intel Fortran Cross-Compiler for 64-bit MIC"
executables = {
'version_cmd' : None, # set by update_executables
'compiler_f77' : [None, "-72"],
'compiler_f90' : [None],
'compiler_fix' : [None, "-FI"],
'linker_so' : ["<F90>", "-shared"],
'archiver' : ["ar", "-cr"],
'ranlib' : ["ranlib"]
}
def get_flags(self):
# for Intel Fortran, -fp-model source is the same as precise without a compiler warning
return ["-fPIC -shared -mmic -mkl -fp-model strict -g " + xcdirflags]
def get_flags_linker_so(self):
return self.get_flags()
def get_flags_opt(self):
return ['']
def get_version(self):
return "TODO"
fcompiler.load_all_fcompiler_classes()
# print fcompiler.fcompiler_class # {name: (name, klass, desc), ...}
fcompiler.fcompiler_class['intelmic'] = ('intelmic', IntelMICFCompiler, IntelMICFCompiler.description)
setup.setup_package()