From 21d2c7e16875e8d34fbc327cd30a40b50e9974f1 Mon Sep 17 00:00:00 2001 From: Andres Guzman-Ballen Date: Mon, 6 Mar 2017 12:11:34 -0600 Subject: ENH: Allows building npy_math with static inlining Code Overview: Numpy currently decouples the math function definitions in `npy_math.c.src` from the function declarations found in `npy_math.h`. This patch allows definitions to be included along with the inclusion of the `npy_math.h` header. Keeping the declarations and definitions separate is usually the right approach, but mathematical code like this might be better off as an exception to this common practice. Because the definitions are in the source file instead of the header, the compiler does not have any clue what lies underneath these math functions. This means the compiler can't make important optimizations like inlining and vectorization. Extensions that utilize these functions could greatly benefit from this, specifically `loops.c.src` from the umath extension. Implementation Details: + Renames `npy_math.c.src` to `npy_math_internal.h.src` + Generates `npy_math_internal.h` from template by adding to `npymath_sources` list and adding `npymath` directory to include paths in `generate_numpyconfig_h` function of `numpy/core/setup.py` + Numpy's core distutils defines `#NPY_INTERNAL_BUILD` macro to make sure `npy_math_internal.h` is not included when other modules try to include public header `npy_math.h` - Currently do not know how to ship headers generated from template files + Adds `npy_math.c`, a file that includes the `npy_math_internal.h.src` file (but does not add NPY_INLINE static) - This is to keep the same static npy_math library as it exists now + Appends `numpy/npy_math.h` with `npy_math_internal.h` under condition that it's not being included in npy_math.c.src - The conditional macros mean `loops.c.src` will have definitions included, and the compiler will vectorize accordingly + Adds `NPY_INLINE` static to function declarations and definitions when necessary + Replaces `sqrtf` with `npy_sqrtf` in `numpy/core/src/umath/umath_tests.c` to make function portable - `_sqrtf` was not found on certain Windows environments compiling with Py2 --- .gitignore | 1 - 1 file changed, 1 deletion(-) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 29609cdec..964910c26 100644 --- a/.gitignore +++ b/.gitignore @@ -122,7 +122,6 @@ numpy/core/src/multiarray/multiarray_tests.c numpy/core/src/multiarray/nditer_templ.c numpy/core/src/multiarray/scalartypes.c numpy/core/src/npymath/ieee754.c -numpy/core/src/npymath/npy_math.c numpy/core/src/npymath/npy_math_complex.c numpy/core/src/npysort/binsearch.c numpy/core/src/npysort/heapsort.c -- cgit v1.2.1