From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/numpy/, dev-python/numpy/files/
Date: Mon, 24 May 2021 22:09:04 +0000 (UTC) [thread overview]
Message-ID: <1621894135.ca58a4b159282f564f046e035a17f7ce0bd30f01.sam@gentoo> (raw)
commit: ca58a4b159282f564f046e035a17f7ce0bd30f01
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon May 24 22:08:17 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon May 24 22:08:55 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca58a4b1
dev-python/numpy: add popcnt patch
Closes: https://bugs.gentoo.org/788184
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../files/numpy-1.20.2-fix-popcnt-detection.patch | 103 +++++++++++++++++++++
...{numpy-1.20.2.ebuild => numpy-1.20.2-r1.ebuild} | 1 +
dev-python/numpy/numpy-1.20.3.ebuild | 1 +
3 files changed, 105 insertions(+)
diff --git a/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch b/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch
new file mode 100644
index 00000000000..85f4bb11b76
--- /dev/null
+++ b/dev-python/numpy/files/numpy-1.20.2-fix-popcnt-detection.patch
@@ -0,0 +1,103 @@
+https://github.com/numpy/numpy/pull/19074
+https://bugs.gentoo.org/788184
+
+From 8dc768964b5578a8aa9db1ef2c55134a00731e10 Mon Sep 17 00:00:00 2001
+From: Carl Michal <michal@physics.ubc.ca>
+Date: Sat, 22 May 2021 20:43:10 -0700
+Subject: [PATCH 1/2] Fix compile-time test of POPCNT
+
+The compile-time test of POPCNT, cpu_popcnt.c produced code that would
+execute without error even if the machine didn't support the popcnt
+instruction. This patch attempts to use popcnt on random numbers so the
+compiler can't substitute the answer at compile time.
+---
+ numpy/distutils/checks/cpu_popcnt.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c
+index e6a80fb40be4..f6c785dd2a97 100644
+--- a/numpy/distutils/checks/cpu_popcnt.c
++++ b/numpy/distutils/checks/cpu_popcnt.c
+@@ -4,20 +4,26 @@
+ #include <popcntintrin.h>
+ #endif
+
++#include <stdlib.h>
++
+ int main(void)
+ {
+ long long a = 0;
+ int b;
++
++ a = random();
++ b = random();
++
+ #ifdef _MSC_VER
+ #ifdef _M_X64
+- a = _mm_popcnt_u64(1);
++ a = _mm_popcnt_u64(a);
+ #endif
+- b = _mm_popcnt_u32(1);
++ b = _mm_popcnt_u32(b);
+ #else
+ #ifdef __x86_64__
+- a = __builtin_popcountll(1);
++ a = __builtin_popcountll(a);
+ #endif
+- b = __builtin_popcount(1);
++ b = __builtin_popcount(b);
+ #endif
+ return (int)a + b;
+ }
+
+From 52d5fe1ede45083d0783c3e2bbaee5c44df9d553 Mon Sep 17 00:00:00 2001
+From: Carl Michal <michal@physics.ubc.ca>
+Date: Sun, 23 May 2021 08:24:52 -0700
+Subject: [PATCH 2/2] Change fix of cpu_popcnt.c to use
+ _mm_popcnt_u64/_mm_popcnt_u32 on GCC
+
+_builtin_popcount is always available, so the compile-time check always
+succeeds.
+---
+ numpy/distutils/checks/cpu_popcnt.c | 26 ++++++++------------------
+ 1 file changed, 8 insertions(+), 18 deletions(-)
+
+diff --git a/numpy/distutils/checks/cpu_popcnt.c b/numpy/distutils/checks/cpu_popcnt.c
+index f6c785dd2a97..540c98dab05d 100644
+--- a/numpy/distutils/checks/cpu_popcnt.c
++++ b/numpy/distutils/checks/cpu_popcnt.c
+@@ -4,26 +4,16 @@
+ #include <popcntintrin.h>
+ #endif
+
+-#include <stdlib.h>
+-
+-int main(void)
++int main(int argc, char **argv)
+ {
+- long long a = 0;
+- int b;
+-
+- a = random();
+- b = random();
+-
+-#ifdef _MSC_VER
+- #ifdef _M_X64
++ // To make sure popcnt instructions are generated
++ // and been tested against the assembler
++ unsigned long long a = *((unsigned long long*)argv[argc-1]);
++ unsigned int b = *((unsigned int*)argv[argc-2]);
++
++#if defined(_M_X64) || defined(__x86_64__)
+ a = _mm_popcnt_u64(a);
+- #endif
+- b = _mm_popcnt_u32(b);
+-#else
+- #ifdef __x86_64__
+- a = __builtin_popcountll(a);
+- #endif
+- b = __builtin_popcount(b);
+ #endif
++ b = _mm_popcnt_u32(b);
+ return (int)a + b;
+ }
diff --git a/dev-python/numpy/numpy-1.20.2.ebuild b/dev-python/numpy/numpy-1.20.2-r1.ebuild
similarity index 98%
rename from dev-python/numpy/numpy-1.20.2.ebuild
rename to dev-python/numpy/numpy-1.20.2-r1.ebuild
index 234a0932bb9..2e16936ea19 100644
--- a/dev-python/numpy/numpy-1.20.2.ebuild
+++ b/dev-python/numpy/numpy-1.20.2-r1.ebuild
@@ -48,6 +48,7 @@ BDEPEND="
PATCHES=(
"${FILESDIR}"/numpy-1.20.1-no-hardcode-blasv2.patch
"${FILESDIR}"/numpy-1.20.2-fix-ccompiler-tests.patch
+ "${FILESDIR}"/numpy-1.20.2-fix-popcnt-detection.patch
)
distutils_enable_tests pytest
diff --git a/dev-python/numpy/numpy-1.20.3.ebuild b/dev-python/numpy/numpy-1.20.3.ebuild
index 5b772a58a6f..6604eb23a4e 100644
--- a/dev-python/numpy/numpy-1.20.3.ebuild
+++ b/dev-python/numpy/numpy-1.20.3.ebuild
@@ -46,6 +46,7 @@ BDEPEND="
PATCHES=(
"${FILESDIR}"/numpy-1.20.1-no-hardcode-blasv2.patch
"${FILESDIR}"/numpy-1.20.2-fix-ccompiler-tests.patch
+ "${FILESDIR}"/numpy-1.20.2-fix-popcnt-detection.patch
"${FILESDIR}"/numpy-1.20.3-float-hashing-py310.patch
)
next reply other threads:[~2021-05-24 22:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 22:09 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-10-31 19:19 [gentoo-commits] repo/gentoo:master commit in: dev-python/numpy/, dev-python/numpy/files/ Michał Górny
2024-07-22 1:20 Michał Górny
2023-11-07 20:35 Sam James
2023-08-22 4:12 Michał Górny
2023-08-01 6:48 Sam James
2023-07-23 21:43 Sam James
2023-06-26 13:14 Sam James
2022-12-03 17:01 Michał Górny
2022-10-25 8:21 Sam James
2022-10-08 13:52 Michał Górny
2021-12-31 22:49 Sam James
2021-09-08 6:16 Michał Górny
2021-05-14 21:39 Marek Szuba
2021-04-30 20:25 Michał Górny
2021-03-28 9:48 Michał Górny
2020-09-16 10:13 Michał Górny
2020-02-26 19:46 David Seifert
2019-11-20 1:24 Patrick McLean
2019-06-23 12:47 Benda XU
2019-01-08 18:54 Virgil Dupras
2018-07-15 22:22 Michał Górny
2018-07-14 21:44 Michał Górny
2016-10-18 20:02 David Seifert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1621894135.ca58a4b159282f564f046e035a17f7ce0bd30f01.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox