<pre style='margin:0'>
Michael Dickens (michaelld) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/3f78e4b15ec81d8989010f4b386a2e14f62aabfa">https://github.com/macports/macports-ports/commit/3f78e4b15ec81d8989010f4b386a2e14f62aabfa</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 3f78e4b15ec81d8989010f4b386a2e14f62aabfa
</span>Author: Ryan Schmidt <ryandesign@macports.org>
AuthorDate: Fri Jun 26 15:28:18 2020 -0500
<span style='display:block; white-space:pre;color:#404040;'> py27-numpy: Backport new CPU detection code
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://trac.macports.org/ticket/59022
</span>---
python/py-numpy/Portfile | 3 +-
.../py-numpy/files/patch-cpu-detection.py.27.patch | 727 +++++++++++++++++++++
2 files changed, 729 insertions(+), 1 deletion(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/python/py-numpy/Portfile b/python/py-numpy/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index 09606f47e75..ed8b7b32c59 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/python/py-numpy/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/python/py-numpy/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -53,7 +53,8 @@ if {${name} ne ${subport}} {
</span> checksums rmd160 cbb34cf0981ea142ff45722d05a9daad20a134ea \
sha256 2dce87065d5de1a83485cfb3de5e4e793787890f5c1dcc3536a9cabf2e1620af \
size 4691852
<span style='display:block; white-space:pre;background:#ffe0e0;'>- revision 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ revision 2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ patchfiles-append patch-cpu-detection.py.27.patch
</span> patchfiles-append patch-numpy_core_setup.py.27.diff \
patch-numpy_tests_test_scripts.py.27.diff \
patch-fcompiler_g95.27.diff
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/python/py-numpy/files/patch-cpu-detection.py.27.patch b/python/py-numpy/files/patch-cpu-detection.py.27.patch
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..6a573cd56fa
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/python/py-numpy/files/patch-cpu-detection.py.27.patch
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,727 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+New CPU detection code from 1.19.0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+https://github.com/numpy/numpy/issues/15342
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+https://github.com/numpy/numpy/pull/13421/commits/ad174001a869f42bb89ccff77ac3eec04a9d71e8
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- numpy/core/code_generators/generate_umath.py.orig 2019-12-29 12:43:21.000000000 -0600
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/code_generators/generate_umath.py 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -985,7 +985,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for vt in t.simd:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ code2list.append(textwrap.dedent("""\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #ifdef HAVE_ATTRIBUTE_TARGET_{ISA}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- if (npy_cpu_supports("{isa}")) {{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (NPY_CPU_HAVE({ISA})) {{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {fname}_functions[{idx}] = {type}_{fname}_{isa};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -1117,7 +1117,6 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Please make changes to the code generator program (%s)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ **/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- #include "cpuid.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "ufunc_object.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "ufunc_type_resolution.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "loops.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- numpy/core/setup.py.orig 2019-12-29 12:43:21.000000000 -0600
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/setup.py 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -755,6 +755,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'common', 'ucsnarrow.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'common', 'ufunc_override.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'common', 'numpyos.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ join('src', 'common', 'npy_cpu_features.c.src'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ blas_info = get_info('blas_opt', 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -901,7 +902,6 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'matmul.c.src'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'ufunc_object.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'extobj.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- join('src', 'umath', 'cpuid.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'scalarmath.c.src'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'ufunc_type_resolution.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ join('src', 'umath', 'override.c'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- numpy/core/setup_common.py.orig 2019-12-29 12:43:21.000000000 -0600
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/setup_common.py 2020-06-26 15:19:32.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -134,9 +134,6 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ("__builtin_bswap64", '5u'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ("__builtin_expect", '5, 0'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ("__builtin_mul_overflow", '5, 5, (int*)5'),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- # broken on OSX 10.11, make sure its not optimized away
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- ("volatile int r = __builtin_cpu_supports", '"sse"',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+- "stdio.h", "__BUILTIN_CPU_SUPPORTS"),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # MMX only needed for icc, but some clangs don't have it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ("_m_from_int64", '0', "emmintrin.h"),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ("_mm_load_ps", '(float*)0', "xmmintrin.h"), # SSE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- numpy/core/src/common/npy_config.h.orig 2019-12-29 12:43:21.000000000 -0600
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/src/common/npy_config.h 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -2,6 +2,7 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #define _NPY_NPY_CONFIG_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "config.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include "npy_cpu_features.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "numpy/numpyconfig.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "numpy/npy_cpu.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #include "numpy/npy_os.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/src/common/npy_cpu_features.c.src 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,404 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include "npy_cpu_features.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include "numpy/npy_common.h" // for NPY_INLINE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include "numpy/npy_cpu.h" // To guarantee of having CPU definitions in scope.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/******************** Private Definitions *********************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Hold all CPU features boolean values
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static unsigned char npy__cpu_have[NPY_CPU_FEATURE_MAX];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/******************** Private Declarations *********************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// Almost detect all CPU features in runtime
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features(void);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/******************** Public Definitions *********************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_have(int feature_id)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (feature_id <= NPY_CPU_FEATURE_NONE || feature_id >= NPY_CPU_FEATURE_MAX)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return npy__cpu_have[feature_id];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_init(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_init_features();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN PyObject *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_features_dict(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ PyObject *dict = PyDict_New();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (dict) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /**begin repeat
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * #feature = MMX, SSE, SSE2, SSE3, SSSE3, SSE41, POPCNT, SSE42,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * AVX, F16C, XOP, FMA4, FMA3, AVX2, AVX512F,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * AVX512CD, AVX512ER, AVX512PF, AVX5124FMAPS, AVX5124VNNIW,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * AVX512VPOPCNTDQ, AVX512VL, AVX512BW, AVX512DQ, AVX512VNNI,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * AVX512IFMA, AVX512VBMI, AVX512VBMI2, AVX512BITALG,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * AVX512_KNL, AVX512_KNM, AVX512_SKX, AVX512_CLX, AVX512_CNL, AVX512_ICL,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * VSX, VSX2, VSX3,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * NEON, NEON_FP16, NEON_VFPV4, ASIMD, FPHP, ASIMDHP, ASIMDDP, ASIMDFHM#
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (PyDict_SetItemString(dict, "@feature@",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_@feature@] ? Py_True : Py_False) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_DECREF(dict);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /**end repeat**/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return dict;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/****************************************************************
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * This section is reserved to defining @npy__cpu_init_features
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * for each CPU architecture, please try to keep it clean. Ty
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ****************************************************************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/***************** X86 ******************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(NPY_CPU_AMD64) || defined(NPY_CPU_X86)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef _MSC_VER
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <intrin.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(__INTEL_COMPILER)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <immintrin.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_getxcr0(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(_MSC_VER) || defined (__INTEL_COMPILER)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return _xgetbv(0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(__GNUC__) || defined(__clang__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned int eax, edx;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ __asm__("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return (eax | (unsigned long long)edx << 32);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO: handle other x86 compilers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_cpuid(int reg[4], int func_id)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(_MSC_VER)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ __cpuidex(reg, func_id, 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(__INTEL_COMPILER)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ __cpuid(reg, func_id);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(__GNUC__) || defined(__clang__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_CPU_X86) && defined(__PIC__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // %ebx may be the PIC register
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #define NPY__CPUID_ASM \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "xchg{l}\t{%%}ebx, %1\n\t" \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "cpuid\n\t" \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "xchg{l}\t{%%}ebx, %1\n\t"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #define NPY__CPUID_ASM "cpuid"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ __asm__(NPY__CPUID_ASM : "=a" (reg[0]), "=b" (reg[1]), "=c" (reg[2]), "=d" (reg[3]) : "a" (func_id), "c" (0) : );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // TODO: handle other x86 compilers
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ reg[0] = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // validate platform support
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int reg[] = {0, 0, 0, 0};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_cpuid(reg, 0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (reg[0] == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_cpuid(reg, 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_MMX] = (reg[3] & (1 << 23)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSE] = (reg[3] & (1 << 25)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSE2] = (reg[3] & (1 << 26)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSE3] = (reg[2] & (1 << 0)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSSE3] = (reg[2] & (1 << 9)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSE41] = (reg[2] & (1 << 19)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_POPCNT] = (reg[2] & (1 << 23)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_SSE42] = (reg[2] & (1 << 20)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_F16C] = (reg[2] & (1 << 29)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // check OSXSAVE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((reg[2] & (1 << 27)) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // check AVX OS support
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int xcr = npy__cpu_getxcr0();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((xcr & 6) != 6)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX] = (reg[2] & (1 << 28)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!npy__cpu_have[NPY_CPU_FEATURE_AVX])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_FMA3] = (reg[2] & (1 << 12)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // second call to the cpuid to get extended AMD feature bits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_cpuid(reg, 0x80000001);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_XOP] = (reg[2] & (1 << 11)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_FMA4] = (reg[2] & (1 << 16)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // third call to the cpuid to get extended AVX2 & AVX512 feature bits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_cpuid(reg, 7);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX2] = (reg[1] & (1 << 5)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!npy__cpu_have[NPY_CPU_FEATURE_AVX2])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // detect AVX2 & FMA3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_FMA] = npy__cpu_have[NPY_CPU_FEATURE_FMA3];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // check AVX512 OS support
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((xcr & 0xe6) != 0xe6)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512F] = (reg[1] & (1 << 16)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512CD] = (reg[1] & (1 << 28)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (npy__cpu_have[NPY_CPU_FEATURE_AVX512F] && npy__cpu_have[NPY_CPU_FEATURE_AVX512CD]) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Knights Landing
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512PF] = (reg[1] & (1 << 26)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512ER] = (reg[1] & (1 << 27)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_KNL] = npy__cpu_have[NPY_CPU_FEATURE_AVX512ER] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512PF];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Knights Mill
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VPOPCNTDQ] = (reg[2] & (1 << 14)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX5124VNNIW] = (reg[3] & (1 << 2)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX5124FMAPS] = (reg[3] & (1 << 3)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_KNM] = npy__cpu_have[NPY_CPU_FEATURE_AVX512_KNL] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX5124FMAPS] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX5124VNNIW] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VPOPCNTDQ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Skylake-X
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512DQ] = (reg[1] & (1 << 17)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512BW] = (reg[1] & (1 << 30)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VL] = (reg[1] & (1 << 31)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_SKX] = npy__cpu_have[NPY_CPU_FEATURE_AVX512BW] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512DQ] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VL];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Cascade Lake
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VNNI] = (reg[2] & (1 << 11)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_CLX] = npy__cpu_have[NPY_CPU_FEATURE_AVX512_SKX] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VNNI];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Cannon Lake
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512IFMA] = (reg[1] & (1 << 21)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VBMI] = (reg[2] & (1 << 1)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_CNL] = npy__cpu_have[NPY_CPU_FEATURE_AVX512_SKX] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512IFMA] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VBMI];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Ice Lake
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VBMI2] = (reg[2] & (1 << 6)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512BITALG] = (reg[2] & (1 << 12)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_ICL] = npy__cpu_have[NPY_CPU_FEATURE_AVX512_CLX] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512_CNL] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VBMI2] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512BITALG] &&
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_AVX512VPOPCNTDQ];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/***************** POWER ******************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(NPY_CPU_PPC64) || defined(NPY_CPU_PPC64LE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __linux__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #include <sys/auxv.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #ifndef AT_HWCAP2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #define AT_HWCAP2 26
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #ifndef PPC_FEATURE2_ARCH_3_00
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #define PPC_FEATURE2_ARCH_3_00 0x00800000
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __linux__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned int hwcap = getauxval(AT_HWCAP);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((hwcap & PPC_FEATURE_HAS_VSX) == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap = getauxval(AT_HWCAP2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hwcap & PPC_FEATURE2_ARCH_3_00)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX2] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX3] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX2] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// TODO: AIX, FreeBSD
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_CPU_PPC64LE) || defined(NPY_HAVE_VSX2)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX2] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #ifdef NPY_HAVE_VSX3
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_VSX3] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/***************** ARM ******************/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#elif defined(__arm__) || defined(__aarch64__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static NPY_INLINE void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features_arm8(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_FP16] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_VFPV4] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMD] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __linux__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * we aren't sure of what kind kernel or clib we deal with
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * so we play it safe
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <fcntl.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP 16
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2 26
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// arch/arm/include/uapi/asm/hwcap.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_HALF (1 << 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_NEON (1 << 12)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_VFPv3 (1 << 13)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_VFPv4 (1 << 16)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2_AES (1 << 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2_PMULL (1 << 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2_SHA1 (1 << 2)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2_SHA2 (1 << 3)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP2_CRC32 (1 << 4)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++// arch/arm64/include/uapi/asm/hwcap.h
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_FP (1 << 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_ASIMD (1 << 1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_FPHP (1 << 9)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_ASIMDHP (1 << 10)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_ASIMDDP (1 << 20)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY__HWCAP_ASIMDFHM (1 << 23)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++__attribute__((weak)) unsigned long getauxval(unsigned long); // linker should handle it
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features_linux(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned long hwcap = 0, hwcap2 = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (getauxval != 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap = getauxval(NPY__HWCAP);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #ifdef __arm__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap2 = getauxval(NPY__HWCAP2);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ unsigned long auxv[2];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ int fd = open("/proc/self/auxv", O_RDONLY);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (fd >= 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ while (read(fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (auxv[0] == NPY__HWCAP) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap = auxv[1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #ifdef __arm__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (auxv[0] == NPY__HWCAP2) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap2 = auxv[1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // detect the end
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ else if (auxv[0] == 0 && auxv[1] == 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ close(fd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (hwcap == 0 && hwcap2 == 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * FIXME: failback to compiler definitions,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * BTW we can parse /proc/cpuinfo for badly patched kernels
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __arm__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Detect Arm8 (aarch32 state)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if ((hwcap2 & NPY__HWCAP2_AES) || (hwcap2 & NPY__HWCAP2_SHA1) ||
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (hwcap2 & NPY__HWCAP2_SHA2) || (hwcap2 & NPY__HWCAP2_PMULL) ||
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ (hwcap2 & NPY__HWCAP2_CRC32))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!(hwcap & (NPY__HWCAP_FP | NPY__HWCAP_ASIMD))) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Is this could happen? maybe disabled by kernel
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // BTW this will break the baseline of AARCH64
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_FPHP] = (hwcap & NPY__HWCAP_FPHP) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDHP] = (hwcap & NPY__HWCAP_ASIMDHP) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDDP] = (hwcap & NPY__HWCAP_ASIMDDP) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDFHM] = (hwcap & NPY__HWCAP_ASIMDFHM) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_init_features_arm8();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON] = (hwcap & NPY__HWCAP_NEON) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_FP16] = (hwcap & (NPY__HWCAP_NEON | NPY__HWCAP_VFPv3 |
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY__HWCAP_HALF)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_VFPV4] = (hwcap & (NPY__HWCAP_NEON | NPY__HWCAP_VFPv4)) != 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __linux__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (npy__cpu_init_features_linux())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // We have nothing else todo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#if defined(NPY_HAVE_NEON_ARM8) || defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 8)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_FPHP) || defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_FPHP] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_ASIMDHP) || defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDHP] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_ASIMDDP) || defined(__ARM_FEATURE_DOTPROD)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDDP] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_ASIMDFHM) || defined(__ARM_FEATURE_FP16FML)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_ASIMDFHM] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_init_features_arm8();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_NEON) || defined(__ARM_NEON__)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON] = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_NEON_FP16) || defined(__ARM_FP16_FORMAT_IEEE) || (defined(__ARM_FP) && (__ARM_FP & 2))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_FP16] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #if defined(NPY_HAVE_NEON_VFPV4) || defined(__ARM_FEATURE_FMA)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy__cpu_have[NPY_CPU_FEATURE_NEON_VFPV4] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ #endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*********** Unsupported ARCH ***********/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy__cpu_init_features(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/src/common/npy_cpu_features.h 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,117 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifndef _NPY_CPU_FEATURES_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define _NPY_CPU_FEATURES_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include "numpy/numpyconfig.h" // for NPY_VISIBILITY_HIDDEN
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#include <Python.h> // for PyObject
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++extern "C" {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++enum npy_cpu_features
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_NONE = 0,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // X86
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_MMX = 1,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSE = 2,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSE2 = 3,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSE3 = 4,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSSE3 = 5,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSE41 = 6,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_POPCNT = 7,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_SSE42 = 8,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX = 9,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_F16C = 10,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_XOP = 11,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_FMA4 = 12,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_FMA3 = 13,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX2 = 14,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_FMA = 15, // AVX2 & FMA3, provides backward compatibility
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512F = 30,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512CD = 31,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512ER = 32,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512PF = 33,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX5124FMAPS = 34,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX5124VNNIW = 35,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512VPOPCNTDQ = 36,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512BW = 37,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512DQ = 38,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512VL = 39,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512IFMA = 40,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512VBMI = 41,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512VNNI = 42,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512VBMI2 = 43,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512BITALG = 44,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // X86 CPU Groups
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Knights Landing (F,CD,ER,PF)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_KNL = 101,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Knights Mill (F,CD,ER,PF,4FMAPS,4VNNIW,VPOPCNTDQ)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_KNM = 102,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Skylake-X (F,CD,BW,DQ,VL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_SKX = 103,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Cascade Lake (F,CD,BW,DQ,VL,VNNI)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_CLX = 104,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Cannon Lake (F,CD,BW,DQ,VL,IFMA,VBMI)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_CNL = 105,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Ice Lake (F,CD,BW,DQ,VL,IFMA,VBMI,VNNI,VBMI2,BITALG,VPOPCNTDQ)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_AVX512_ICL = 106,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // IBM/POWER VSX
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // POWER7
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_VSX = 200,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // POWER8
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_VSX2 = 201,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // POWER9
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_VSX3 = 202,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ARM
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_NEON = 300,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_NEON_FP16 = 301,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // FMA
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_NEON_VFPV4 = 302,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // Advanced SIMD
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_ASIMD = 303,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ARMv8.2 half-precision
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_FPHP = 304,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ARMv8.2 half-precision vector arithm
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_ASIMDHP = 305,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ARMv8.2 dot product
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_ASIMDDP = 306,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ // ARMv8.2 single&half-precision multiply
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_ASIMDFHM = 307,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NPY_CPU_FEATURE_MAX
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * Initialize CPU features
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * return 0 on success otherwise return -1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_init(void);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * return 0 if CPU feature isn't available
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * note: `npy_cpu_init` must be called first otherwise it will always return 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++*/
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_have(int feature_id);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#define NPY_CPU_HAVE(FEATURE_NAME) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_have(NPY_CPU_FEATURE_##FEATURE_NAME)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * return a new dictionary contains CPU feature names
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * with runtime availability.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ * same as npy_cpu_have, `npy_cpu_init` must be called first.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++NPY_VISIBILITY_HIDDEN PyObject *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++npy_cpu_features_dict(void);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef __cplusplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif // _NPY_CPU_FEATURES_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- numpy/core/src/multiarray/multiarraymodule.c.orig 2019-12-29 12:43:21.000000000 -0600
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/src/multiarray/multiarraymodule.c 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -4548,6 +4548,11 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PyObject *m, *d, *s;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PyObject *c_api;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ /* Initialize CPU features */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (npy_cpu_init() < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto err;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Create the module and add the functions */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if defined(NPY_PY3K)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ m = PyModule_Create(&moduledef);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -4677,6 +4682,16 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ PyDict_SetItemString(d, "__version__", s);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Py_DECREF(s);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ s = npy_cpu_features_dict();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (s == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto err;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (PyDict_SetItemString(d, "__cpu_features__", s) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_DECREF(s);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ goto err;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ Py_DECREF(s);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s = NpyCapsule_FromVoidPtr((void *)_datetime_strings, NULL);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (s == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ goto err;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ numpy/core/tests/test_cpu_features.py 2020-06-26 15:18:29.000000000 -0500
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -0,0 +1,104 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++import sys, platform, re, pytest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++from numpy.testing import assert_equal
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++from numpy.core._multiarray_umath import __cpu_features__
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class AbstractTest(object):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features = []
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_groups = {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_map = {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_flags = set()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ # a hook
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ pass
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def test_features(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.load_flags()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for gname, features in self.features_groups.items():
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ test_features = [self.features_map.get(f, f) in self.features_flags for f in features]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert_equal(__cpu_features__.get(gname), all(test_features))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for feature_name in self.features:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ map_name = self.features_map.get(feature_name, feature_name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ cpu_have = map_name in self.features_flags
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ npy_have = __cpu_features__.get(feature_name)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ assert_equal(npy_have, cpu_have)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags_proc(self, magic_key):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ with open('/proc/cpuinfo') as fd:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for line in fd:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if not line.startswith(magic_key):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ flags_value = [s.strip() for s in line.split(':', 1)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if len(flags_value) == 2:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.features_flags = self.features_flags.union(flags_value[1].upper().split())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags_auxv(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ import subprocess
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ auxv = subprocess.check_output(['/bin/true'], env=dict(LD_SHOW_AUXV="1"))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ for at in auxv.split(b'\n'):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if not at.startswith(b"AT_HWCAP"):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap_value = [s.strip() for s in at.split(b':', 1)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if len(hwcap_value) == 2:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.features_flags = self.features_flags.union(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ hwcap_value[1].upper().decode().split()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++is_linux = sys.platform.startswith('linux')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++machine = platform.machine()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++is_x86 = re.match("^(amd64|x86|i386|i686)", machine, re.IGNORECASE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++@pytest.mark.skipif(not is_linux or not is_x86, reason="Only for Linux and x86")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class Test_X86_Features(AbstractTest):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "MMX", "SSE", "SSE2", "SSE3", "SSSE3", "SSE41", "POPCNT", "SSE42",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX", "F16C", "XOP", "FMA4", "FMA3", "AVX2", "AVX512F", "AVX512CD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX512ER", "AVX512PF", "AVX5124FMAPS", "AVX5124VNNIW", "AVX512VPOPCNTDQ",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX512VL", "AVX512BW", "AVX512DQ", "AVX512VNNI", "AVX512IFMA",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX512VBMI", "AVX512VBMI2", "AVX512BITALG",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_groups = dict(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_KNL = ["AVX512F", "AVX512CD", "AVX512ER", "AVX512PF"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_KNM = ["AVX512F", "AVX512CD", "AVX512ER", "AVX512PF", "AVX5124FMAPS",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX5124VNNIW", "AVX512VPOPCNTDQ"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_SKX = ["AVX512F", "AVX512CD", "AVX512BW", "AVX512DQ", "AVX512VL"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_CLX = ["AVX512F", "AVX512CD", "AVX512BW", "AVX512DQ", "AVX512VL", "AVX512VNNI"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_CNL = ["AVX512F", "AVX512CD", "AVX512BW", "AVX512DQ", "AVX512VL", "AVX512IFMA",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX512VBMI"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512_ICL = ["AVX512F", "AVX512CD", "AVX512BW", "AVX512DQ", "AVX512VL", "AVX512IFMA",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "AVX512VBMI", "AVX512VNNI", "AVX512VBMI2", "AVX512BITALG", "AVX512VPOPCNTDQ"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_map = dict(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ SSE3="PNI", SSE41="SSE4_1", SSE42="SSE4_2", FMA3="FMA",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX512VNNI="AVX512_VNNI", AVX512BITALG="AVX512_BITALG", AVX512VBMI2="AVX512_VBMI2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ AVX5124FMAPS="AVX512_4FMAPS", AVX5124VNNIW="AVX512_4VNNIW", AVX512VPOPCNTDQ="AVX512_VPOPCNTDQ",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.load_flags_proc("flags")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++is_power = re.match("^(powerpc|ppc)64", machine, re.IGNORECASE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++@pytest.mark.skipif(not is_linux or not is_power, reason="Only for Linux and Power")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class Test_POWER_Features(AbstractTest):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features = ["VSX", "VSX2", "VSX3"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_map = dict(VSX2="ARCH_2_07", VSX3="ARCH_3_00")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.load_flags_auxv()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++is_arm = re.match("^(arm|aarch64)", machine, re.IGNORECASE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++@pytest.mark.skipif(not is_linux or not is_arm, reason="Only for Linux and ARM")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++class Test_ARM_Features(AbstractTest):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ "NEON", "ASIMD", "FPHP", "ASIMDHP", "ASIMDDP", "ASIMDFHM"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ features_groups = dict(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NEON_FP16 = ["NEON", "HALF"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NEON_VFPV4 = ["NEON", "VFPV4"],
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ def load_flags(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.load_flags_proc("Features")
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if re.match("^(aarch64|AARCH64)", platform.machine()):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ self.features_map = dict(
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ NEON="ASIMD", HALF="ASIMD", VFPV4="ASIMD"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ )
</span></pre><pre style='margin:0'>
</pre>