summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2016-09-24 12:45:01 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2016-09-24 13:15:09 +0200
commita860256f88c8ebb3f74eb7e90ee89f05dedf3a7c (patch)
tree5aff93e33860517e465bf3f6f1d06c2929c4a436
parent37740eb8c09dbc6b074aa10298401f994cd7fa55 (diff)
downloadnumpy-a860256f88c8ebb3f74eb7e90ee89f05dedf3a7c.tar.gz
MAINT: add runtime check for AVX macros
-rw-r--r--numpy/core/include/numpy/npy_common.h11
-rw-r--r--numpy/core/setup_common.py2
2 files changed, 13 insertions, 0 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h
index d851b7fb2..21b15869f 100644
--- a/numpy/core/include/numpy/npy_common.h
+++ b/numpy/core/include/numpy/npy_common.h
@@ -29,6 +29,11 @@
#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
@@ -92,7 +97,13 @@
#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
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 2a42a0638..5e1396e6b 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -142,6 +142,8 @@ OPTIONAL_FUNCTION_ATTRIBUTES = [('__attribute__((optimize("unroll-loops")))',
'attribute_optimize_opt_3'),
('__attribute__((nonnull (1)))',
'attribute_nonnull'),
+ ('__attribute__((target ("avx")))',
+ 'attribute_target_avx'),
('__attribute__((target ("avx2")))',
'attribute_target_avx2'),
]