Changeset View
Changeset View
Standalone View
Standalone View
files/Try-to-load-so.avx2-libs-first-if-they-exist-and-cpu.patch
- This file was added.
| From 325fb5e5ee95a597b50583846938e3ba97fa78ab Mon Sep 17 00:00:00 2001 | |||||
| From: Joey Riches <josephriches@gmail.com> | |||||
| Date: Thu, 22 Jul 2021 02:54:21 +0100 | |||||
| Subject: [PATCH 1/1] Try to load so.avx2 libs first if they exist and cpu is | |||||
| supported | |||||
| We compile for haswell so we also check for popcnt to exclude bdver4 (Exacavator) | |||||
| Not really the most ideal solution but should do the trick. | |||||
| --- | |||||
| Python/dynload_shlib.c | 11 ++++++++++- | |||||
| 1 file changed, 10 insertions(+), 1 deletion(-) | |||||
| diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c | |||||
| index f271193190..f25c01dce0 100644 | |||||
| --- a/Python/dynload_shlib.c | |||||
| +++ b/Python/dynload_shlib.c | |||||
| @@ -61,6 +61,7 @@ _PyImport_FindSharedFuncptr(const char *prefix, | |||||
| void *handle; | |||||
| char funcname[258]; | |||||
| char pathbuf[260]; | |||||
| + char *pathname2; | |||||
| int dlopenflags=0; | |||||
| if (strchr(pathname, '/') == NULL) { | |||||
| @@ -93,7 +94,15 @@ _PyImport_FindSharedFuncptr(const char *prefix, | |||||
| dlopenflags = PyThreadState_GET()->interp->dlopenflags; | |||||
| - handle = dlopen(pathname, dlopenflags); | |||||
| + pathname2 = malloc(strlen(pathname) + strlen(".avx2") + 1); | |||||
| + sprintf(pathname2, "%s%s", pathname, ".avx2"); | |||||
| + if (__builtin_cpu_supports("avx2") && | |||||
| + __builtin_cpu_supports("popcnt") && // We compile for haswell, add popcnt check to exclude bdver4 (Exacavator) | |||||
| + access(pathname2, R_OK) == 0) | |||||
| + handle = dlopen(pathname2, dlopenflags); | |||||
| + else | |||||
| + handle = dlopen(pathname, dlopenflags); | |||||
| + free(pathname2); | |||||
| if (handle == NULL) { | |||||
| PyObject *mod_name; | |||||
| -- | |||||
| 2.32.0 | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.