summaryrefslogtreecommitdiff
path: root/numpy/core/include
diff options
context:
space:
mode:
authorJulian Taylor <juliantaylor108@gmail.com>2016-09-25 17:16:45 +0200
committerGitHub <noreply@github.com>2016-09-25 17:16:45 +0200
commit0887da9386e812d2769744afd6c58a927d6cbb45 (patch)
tree65f07b1cf5c4451be4e324e34fe8fd907578b07c /numpy/core/include
parenta17e905faa20fcdd1b3f039bceef6efa19671bb3 (diff)
parentae32e780d85e8e42402bc1fee2bbdb3ee90426c4 (diff)
downloadnumpy-0887da9386e812d2769744afd6c58a927d6cbb45.tar.gz
Merge pull request #7980 from juliantaylor/avx-runtime
ENH: Add ability to runtime select ufunc loops, add AVX2 integer loops
Diffstat (limited to 'numpy/core/include')
-rw-r--r--numpy/core/include/numpy/npy_common.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h
index 4509f2164..11a988163 100644
--- a/numpy/core/include/numpy/npy_common.h
+++ b/numpy/core/include/numpy/npy_common.h
@@ -28,6 +28,18 @@
#define NPY_GCC_OPT_3
#endif
+/* compile target attributes */
+#ifdef HAVE_ATTRIBUTE_TARGET_AVX
+#define NPY_GCC_TARGET_AVX __attribute__((target("avx")))
+#else
+#define NPY_GCC_TARGET_AVX
+#endif
+#ifdef HAVE_ATTRIBUTE_TARGET_AVX2
+#define NPY_GCC_TARGET_AVX2 __attribute__((target("avx2")))
+#else
+#define NPY_GCC_TARGET_AVX2
+#endif
+
/*
* mark an argument (starting from 1) that must not be NULL and is not checked
* DO NOT USE IF FUNCTION CHECKS FOR NULL!! the compiler will remove the check
@@ -79,6 +91,22 @@
#endif
#endif
+#ifdef HAVE___BUILTIN_CPU_SUPPORTS
+ #ifdef HAVE_ATTRIBUTE_TARGET_AVX2
+ #define NPY_CPU_SUPPORTS_AVX2 __builtin_cpu_supports("avx2")
+ #else
+ #define NPY_CPU_SUPPORTS_AVX2 0
+ #endif
+ #ifdef HAVE_ATTRIBUTE_TARGET_AVX
+ #define NPY_CPU_SUPPORTS_AVX __builtin_cpu_supports("avx")
+ #else
+ #define NPY_CPU_SUPPORTS_AVX 0
+ #endif
+#else
+ #define NPY_CPU_SUPPORTS_AVX 0
+ #define NPY_CPU_SUPPORTS_AVX2 0
+#endif
+
#if defined(_MSC_VER)
#define NPY_INLINE __inline
#elif defined(__GNUC__)