提交 0c108883 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Tweak the blas flags logic so that it doesn't require certain keys in the dict.

Also fix the flags test code so that it doesn't fail due to the mac bug.
上级 3dcba54d
...@@ -272,10 +272,11 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in ...@@ -272,10 +272,11 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
"mk2_rt"]]) "mk2_rt"]])
# Anaconda # Anaconda
if "Anaconda" in sys.version and sys.platform == "win32": if "Anaconda" in sys.version and sys.platform == "win32":
# If the "mkl-service" conda package (available through Python # If the "mkl-service" conda package (available
# package "mkl") is installed and importable, then the libraries # through Python package "mkl") is installed and
# (installed by conda package "mkl-rt") are actually available. # importable, then the libraries (installed by conda
# Using "conda install mkl" will install both, as well as # package "mkl-rt") are actually available. Using
# "conda install mkl" will install both, as well as
# optimized versions of numpy and scipy. # optimized versions of numpy and scipy.
try: try:
import mkl # noqa import mkl # noqa
...@@ -291,28 +292,24 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in ...@@ -291,28 +292,24 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
if try_blas_flag(flags): if try_blas_flag(flags):
return ' '.join(flags) return ' '.join(flags)
# If numpy was linked with library that are not installed or ret = (
# the dev version of the package is not currently available, we # TODO: the Gemm op below should separate the
# can't reuse them. # -L and -l arguments into the two callbacks
if any(os.path.exists(dir) for dir in blas_info['library_dirs']): # that CLinker uses for that stuff. for now,
ret = ( # we just pass the whole ldflags as the -l
# TODO: the Gemm op below should separate the # options part.
# -L and -l arguments into the two callbacks ['-L%s' % l for l in blas_info.get('library_dirs', [])] +
# that CLinker uses for that stuff. for now, ['-l%s' % l for l in blas_info.get('libraries', [])] +
# we just pass the whole ldflags as the -l blas_info.get('extra_link_args', []))
# options part. if try_blas_flag(ret):
['-L%s' % l for l in blas_info['library_dirs']] + return ' '.join(ret)
['-l%s' % l for l in blas_info['libraries']] + # Try to add the anaconda lib directory to runtime loading of lib.
[]) # This fix some case with Anaconda 2.3 on Linux.
if "Anaconda" in sys.version and "linux" in sys.platform:
lib_path = os.path.join(sys.prefix, 'lib')
ret.append('-Wl,-rpath,' + lib_path)
if try_blas_flag(ret): if try_blas_flag(ret):
return ' '.join(ret) return ' '.join(ret)
# Try to add the anaconda lib directory to runtime loading of lib.
# This fix some case with Anaconda 2.3 on Linux.
if "Anaconda" in sys.version and "linux" in sys.platform:
lib_path = os.path.join(sys.prefix, 'lib')
ret.append('-Wl,-rpath,' + lib_path)
if try_blas_flag(ret):
return ' '.join(ret)
except KeyError: except KeyError:
pass pass
...@@ -327,15 +324,15 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in ...@@ -327,15 +324,15 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
def try_blas_flag(flags): def try_blas_flag(flags):
test_code = textwrap.dedent("""\ test_code = textwrap.dedent("""\
extern "C" float sdot_(int*, float*, int*, float*, int*); extern "C" double ddot_(int*, double*, int*, double*, int*);
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int Nx = 5; int Nx = 5;
int Sx = 1; int Sx = 1;
float x[5] = {0, 1, 2, 3, 4}; double x[5] = {0, 1, 2, 3, 4};
float r = sdot_(&Nx, x, &Sx, x, &Sx); double r = ddot_(&Nx, x, &Sx, x, &Sx);
if ((r - 30.f) > 1e-6 || (r - 30.f) < -1e-6) if ((r - 30.) > 1e-6 || (r - 30.) < -1e-6)
{ {
return -1; return -1;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论