提交 6ce3aa78 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3884 from abergeron/fix_mac_blas

Fix blas detection on mac.
......@@ -272,10 +272,11 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
"mk2_rt"]])
# Anaconda
if "Anaconda" in sys.version and sys.platform == "win32":
# If the "mkl-service" conda package (available through Python
# package "mkl") is installed and importable, then the libraries
# (installed by conda package "mkl-rt") are actually available.
# Using "conda install mkl" will install both, as well as
# If the "mkl-service" conda package (available
# through Python package "mkl") is installed and
# importable, then the libraries (installed by conda
# package "mkl-rt") are actually available. Using
# "conda install mkl" will install both, as well as
# optimized versions of numpy and scipy.
try:
import mkl # noqa
......@@ -291,19 +292,15 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
if try_blas_flag(flags):
return ' '.join(flags)
# If numpy was linked with library that are not installed or
# the dev version of the package is not currently available, we
# can't reuse them.
if any(os.path.exists(dir) for dir in blas_info['library_dirs']):
ret = (
# TODO: the Gemm op below should separate the
# -L and -l arguments into the two callbacks
# that CLinker uses for that stuff. for now,
# we just pass the whole ldflags as the -l
# options part.
['-L%s' % l for l in blas_info['library_dirs']] +
['-l%s' % l for l in blas_info['libraries']] +
[])
['-L%s' % l for l in blas_info.get('library_dirs', [])] +
['-l%s' % l for l in blas_info.get('libraries', [])] +
blas_info.get('extra_link_args', []))
if try_blas_flag(ret):
return ' '.join(ret)
# Try to add the anaconda lib directory to runtime loading of lib.
......@@ -327,15 +324,15 @@ SOMEPATH/Canopy_64bit/User/lib/python2.7/site-packages/numpy/distutils/system_in
def try_blas_flag(flags):
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 Nx = 5;
int Sx = 1;
float x[5] = {0, 1, 2, 3, 4};
float r = sdot_(&Nx, x, &Sx, x, &Sx);
double x[5] = {0, 1, 2, 3, 4};
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;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论