Use simde so SIMD speedups work on ARM as well

This commit is contained in:
Kovid Goyal 2023-11-12 14:14:09 +05:30
parent 4790959938
commit 49a54b086f
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 23 additions and 1 deletions

View file

@ -250,6 +250,15 @@
}
},
{
"name": "simde",
"unix": {
"filename": "simde-amalgamated-0.7.6.tar.xz",
"hash": "sha256:703eac1f2af7de1f7e4aea2286130b98e1addcc0559426e78304c92e2b4eb5e1",
"urls": ["https://github.com/simd-everywhere/simde/releases/download/v0.7.6/{filename}"]
}
},
{
"name": "wayland",
"os": "linux",

View file

@ -96,6 +96,7 @@ Run-time dependencies:
Build-time dependencies:
* ``gcc`` or ``clang``
* ``simde``
* ``go`` >= _build_go_version (see :file:`go.mod` for go packages used during building)
* ``pkg-config``
* For building on Linux in addition to the above dependencies you might also

View file

@ -5,9 +5,10 @@
* Distributed under terms of the GPL3 license.
*/
#define SIMDE_ENABLE_NATIVE_ALIASES
#include "data-types.h"
#include "simd-string.h"
#include <immintrin.h>
#include <simde/x86/avx2.h>
static bool has_sse4_2 = false, has_avx2 = false;
@ -194,7 +195,18 @@ bool
init_simd(void *x) {
PyObject *module = (PyObject*)x;
#define A(x, val) { Py_INCREF(Py_##val); if (0 != PyModule_AddObject(module, #x, Py_##val)) return false; }
#ifdef __APPLE__
// Modern Apple Intel processors should all support AVX2. And simde takes care of NEON on Apple Silicon
has_sse4_2 = true; has_avx2 = true;
#else
#ifdef __aarch64__
// no idea how to probe ARM cpu for NEON support. This file uses pretty
// basic AVX2 and SSE4.2 intrinsics, so hopefully they work on ARM
has_sse4_2 = true; has_avx2 = true;
#else
has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2");
#endif
#endif
if (has_avx2) {
A(has_avx2, True);
find_byte_not_in_range_impl = find_byte_not_in_range_avx2;