summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/linalg/lapack_lite/f2c.h5
-rwxr-xr-xnumpy/linalg/lapack_lite/make_lite.py66
-rw-r--r--numpy/linalg/lapack_lite/python_xerbla.c3
-rw-r--r--numpy/linalg/setup.py9
4 files changed, 71 insertions, 12 deletions
diff --git a/numpy/linalg/lapack_lite/f2c.h b/numpy/linalg/lapack_lite/f2c.h
index 4462eaa74..d3fbfc177 100644
--- a/numpy/linalg/lapack_lite/f2c.h
+++ b/numpy/linalg/lapack_lite/f2c.h
@@ -11,6 +11,8 @@
#include "numpy/npy_common.h"
#include "npy_cblas.h"
+#include "lapack_lite_names.h"
+
typedef CBLAS_INT integer;
typedef char *address;
typedef short int shortint;
@@ -383,6 +385,9 @@ extern void z_log(doublecomplex *, doublecomplex *);
extern void z_sin(doublecomplex *, doublecomplex *);
extern void z_sqrt(doublecomplex *, doublecomplex *);
+extern double f__cabs(double, double);
+extern double f__cabsf(float, float);
+
#ifdef __cplusplus
}
#endif
diff --git a/numpy/linalg/lapack_lite/make_lite.py b/numpy/linalg/lapack_lite/make_lite.py
index 61102d6ab..bc442b8d1 100755
--- a/numpy/linalg/lapack_lite/make_lite.py
+++ b/numpy/linalg/lapack_lite/make_lite.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
-Usage: make_lite.py <wrapped_routines_file> <lapack_dir> <output_dir>
+Usage: make_lite.py <wrapped_routines_file> <lapack_dir>
Typical invocation:
@@ -15,6 +15,7 @@ from __future__ import division, absolute_import, print_function
import sys
import os
+import re
import subprocess
import shutil
@@ -35,11 +36,14 @@ F2C_ARGS = ['-A', '-Nx800']
# The header to add to the top of the f2c_*.c file. Note that dlamch_() calls
# will be replaced by the macros below by clapack_scrub.scrub_source()
-HEADER = '''\
+HEADER_BLURB = '''\
/*
-NOTE: This is generated code. Look in Misc/lapack_lite for information on
- remaking this file.
-*/
+ * NOTE: This is generated code. Look in numpy/linalg/lapack_lite for
+ * information on remaking this file.
+ */
+'''
+
+HEADER = HEADER_BLURB + '''\
#include "f2c.h"
#ifdef HAVE_CONFIG
@@ -281,6 +285,52 @@ def ensure_executable(name):
except:
raise SystemExit(name + ' not found')
+def create_name_header(output_dir):
+ routine_re = re.compile(r'^ (subroutine|.* function)\s+(\w+)\(.*$',
+ re.I)
+ extern_re = re.compile(r'^extern [a-z]+ ([a-z0-9_]+)\(.*$')
+
+ # BLAS/LAPACK symbols
+ symbols = set(['xerbla'])
+ for fn in os.listdir(output_dir):
+ fn = os.path.join(output_dir, fn)
+
+ if not fn.endswith('.f'):
+ continue
+
+ with open(fn, 'r') as f:
+ for line in f:
+ m = routine_re.match(line)
+ if m:
+ symbols.add(m.group(2).lower())
+
+ # f2c symbols
+ f2c_symbols = set()
+ with open('f2c.h', 'r') as f:
+ for line in f:
+ m = extern_re.match(line)
+ if m:
+ f2c_symbols.add(m.group(1))
+
+ with open(os.path.join(output_dir, 'lapack_lite_names.h'), 'w') as f:
+ f.write(HEADER_BLURB)
+ f.write(
+ "/*\n"
+ " * This file renames all BLAS/LAPACK and f2c symbols to avoid\n"
+ " * dynamic symbol name conflicts, in cases where e.g.\n"
+ " * integer sizes do not match with 'standard' ABI.\n"
+ " */\n")
+
+ # Rename BLAS/LAPACK symbols
+ for name in sorted(symbols):
+ f.write("#define %s_ BLAS_FUNC(%s)\n" % (name, name))
+
+ # Rename also symbols that f2c exports itself
+ f.write("\n"
+ "/* Symbols exported by f2c.c */\n")
+ for name in sorted(f2c_symbols):
+ f.write("#define %s numpy_lapack_lite_%s\n" % (name, name))
+
def main():
if len(sys.argv) != 3:
print(__doc__)
@@ -330,12 +380,14 @@ def main():
print()
+ create_name_header(output_dir)
+
for fname in os.listdir(output_dir):
- if fname.endswith('.c'):
+ if fname.endswith('.c') or fname == 'lapack_lite_names.h':
print('Copying ' + fname)
shutil.copy(
os.path.join(output_dir, fname),
- os.path.dirname(__file__),
+ os.path.abspath(os.path.dirname(__file__)),
)
diff --git a/numpy/linalg/lapack_lite/python_xerbla.c b/numpy/linalg/lapack_lite/python_xerbla.c
index 4dbb92e1f..fe2f718b2 100644
--- a/numpy/linalg/lapack_lite/python_xerbla.c
+++ b/numpy/linalg/lapack_lite/python_xerbla.c
@@ -2,9 +2,6 @@
#include "numpy/npy_common.h"
#include "npy_cblas.h"
-#undef c_abs
-#include "f2c.h"
-
/*
From the original manpage:
--------------------------
diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py
index 0aa0566d6..e4d47b885 100644
--- a/numpy/linalg/setup.py
+++ b/numpy/linalg/setup.py
@@ -40,8 +40,13 @@ def configuration(parent_package='', top_path=None):
def calc_info(self):
info = {'language': 'c'}
if sys.maxsize > 2**32:
- # Build lapack-lite in 64-bit integer mode
- info['define_macros'] = [('HAVE_BLAS_ILP64', None)]
+ # Build lapack-lite in 64-bit integer mode.
+ # The suffix is arbitrary (lapack_lite symbols follow it),
+ # but use the "64_" convention here.
+ info['define_macros'] = [
+ ('HAVE_BLAS_ILP64', None),
+ ('BLAS_SYMBOL_SUFFIX', '64_')
+ ]
self.set_info(**info)
lapack_info = numpy_linalg_lapack_lite().get_info(2)