From f23957dbbde2308fc32da1d1a774b0d04f9aac31 Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Sun, 18 Jul 2021 22:47:35 +0100 Subject: [PATCH 1/7] add support for windows on arm targets --- numpy/core/include/numpy/npy_cpu.h | 2 ++ numpy/random/src/philox/philox.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h index 065176ac5fb6..1249bd4af193 100644 --- a/numpy/core/include/numpy/npy_cpu.h +++ b/numpy/core/include/numpy/npy_cpu.h @@ -84,6 +84,8 @@ # error Unknown ARM CPU, please report this to numpy maintainers with \ information about your platform (OS, CPU and compiler) #endif +#elif defined(_M_ARM64) + #define NPY_CPU_ARMEL_AARCH64 #elif defined(__sh__) && defined(__LITTLE_ENDIAN__) #define NPY_CPU_SH_LE #elif defined(__sh__) && defined(__BIG_ENDIAN__) diff --git a/numpy/random/src/philox/philox.h b/numpy/random/src/philox/philox.h index c72424a975ef..154c039f631d 100644 --- a/numpy/random/src/philox/philox.h +++ b/numpy/random/src/philox/philox.h @@ -33,7 +33,7 @@ static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) { return (uint64_t)product; } #else -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_M_ARM64) #include #if defined(_WIN64) && defined(_M_AMD64) #pragma intrinsic(_umul128) From d72b973673492dd70eca46eb997c117a5d0e7bdb Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Mon, 19 Jul 2021 17:37:34 +0100 Subject: [PATCH 2/7] Philox: Use _umulh intrinsic for ARM64 target --- numpy/random/src/philox/philox.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/numpy/random/src/philox/philox.h b/numpy/random/src/philox/philox.h index 154c039f631d..8844acc15725 100644 --- a/numpy/random/src/philox/philox.h +++ b/numpy/random/src/philox/philox.h @@ -33,10 +33,16 @@ static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) { return (uint64_t)product; } #else -#if defined(_WIN32) && !defined(_M_ARM64) +#if defined(_WIN32) #include #if defined(_WIN64) && defined(_M_AMD64) #pragma intrinsic(_umul128) +#elif defined(_WIN64) && defined(_M_ARM64) +#pragma intrinsic(__umulh) +static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) { + *high = __umulh(a, b); + return a * b; +} #else #pragma intrinsic(__emulu) static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) { From 6eed7960f0febb6e309b0066977bd975187a3d33 Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Wed, 21 Jul 2021 10:13:41 +0100 Subject: [PATCH 3/7] CPU Detection: Refactor to avoid separate pre-processor definition for WoA --- numpy/core/include/numpy/npy_cpu.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h index 1249bd4af193..1865f2ee54c8 100644 --- a/numpy/core/include/numpy/npy_cpu.h +++ b/numpy/core/include/numpy/npy_cpu.h @@ -63,7 +63,7 @@ #define NPY_CPU_HPPA #elif defined(__alpha__) #define NPY_CPU_ALPHA -#elif defined(__arm__) || defined(__aarch64__) +#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) #if defined(__ARMEB__) || defined(__AARCH64EB__) #if defined(__ARM_32BIT_STATE) #define NPY_CPU_ARMEB_AARCH32 @@ -72,10 +72,10 @@ #else #define NPY_CPU_ARMEB #endif - #elif defined(__ARMEL__) || defined(__AARCH64EL__) + #elif defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) #if defined(__ARM_32BIT_STATE) #define NPY_CPU_ARMEL_AARCH32 - #elif defined(__ARM_64BIT_STATE) + #elif defined(__ARM_64BIT_STATE) || defined(_M_ARM64) #define NPY_CPU_ARMEL_AARCH64 #else #define NPY_CPU_ARMEL @@ -84,8 +84,6 @@ # error Unknown ARM CPU, please report this to numpy maintainers with \ information about your platform (OS, CPU and compiler) #endif -#elif defined(_M_ARM64) - #define NPY_CPU_ARMEL_AARCH64 #elif defined(__sh__) && defined(__LITTLE_ENDIAN__) #define NPY_CPU_SH_LE #elif defined(__sh__) && defined(__BIG_ENDIAN__) From 75d85f155f82421de149f70f4a8d9588f79f1fa9 Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Thu, 22 Jul 2021 17:21:10 +0100 Subject: [PATCH 4/7] adapt test_dragon4 to avoid using pow (**) to workaround issue in windows C RT for arm64 --- numpy/core/tests/test_scalarprint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py index 620472683391..2f1c3bc5e309 100644 --- a/numpy/core/tests/test_scalarprint.py +++ b/numpy/core/tests/test_scalarprint.py @@ -154,7 +154,8 @@ def test_dragon4(self): "0.00000000000000000000000000000000000000000000140129846432" "4817070923729583289916131280261941876515771757068283889791" "08268586060148663818836212158203125") - assert_equal(fpos64(0.5**(1022 + 52), unique=False, precision=1074), + + assert_equal(fpos64(5e-324, unique=False, precision=1074), "0.00000000000000000000000000000000000000000000000000000000" "0000000000000000000000000000000000000000000000000000000000" "0000000000000000000000000000000000000000000000000000000000" From 9471c02107393785868fd4cc876947067a80a874 Mon Sep 17 00:00:00 2001 From: Niyas Sait <87434895+nsait-linaro@users.noreply.github.com> Date: Sun, 25 Jul 2021 11:07:11 +0100 Subject: [PATCH 5/7] Update numpy/core/include/numpy/npy_cpu.h Co-authored-by: Matti Picus --- numpy/core/include/numpy/npy_cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h index 1865f2ee54c8..bc1fad72f768 100644 --- a/numpy/core/include/numpy/npy_cpu.h +++ b/numpy/core/include/numpy/npy_cpu.h @@ -64,6 +64,7 @@ #elif defined(__alpha__) #define NPY_CPU_ALPHA #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) + /* _M_ARM64 is defined in MSVC for ARM64 compilation on Windows */ #if defined(__ARMEB__) || defined(__AARCH64EB__) #if defined(__ARM_32BIT_STATE) #define NPY_CPU_ARMEB_AARCH32 From 6ce34c3becbd6acc86a99d68a055383d9d430c8c Mon Sep 17 00:00:00 2001 From: Niyas Sait Date: Tue, 27 Jul 2021 12:54:53 +0100 Subject: [PATCH 6/7] add release note for numpy windows/arm64 support --- doc/release/upcoming_changes/19513.new_feature.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/release/upcoming_changes/19513.new_feature.rst diff --git a/doc/release/upcoming_changes/19513.new_feature.rst b/doc/release/upcoming_changes/19513.new_feature.rst new file mode 100644 index 000000000000..343a183b84f8 --- /dev/null +++ b/doc/release/upcoming_changes/19513.new_feature.rst @@ -0,0 +1,4 @@ +Preliminary support for `windows/arm64` target +---------------------------------------------- + +`numpy` added support for windows/arm64 target. Please note `OpenBLAS` support is not yet available for windows/arm64 target. From 3ab6a59e793af0388675f9f76610344687b4f2f1 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 27 Jul 2021 13:30:29 -0600 Subject: [PATCH 7/7] Update 19513.new_feature.rst --- doc/release/upcoming_changes/19513.new_feature.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/release/upcoming_changes/19513.new_feature.rst b/doc/release/upcoming_changes/19513.new_feature.rst index 343a183b84f8..5f945cea2b68 100644 --- a/doc/release/upcoming_changes/19513.new_feature.rst +++ b/doc/release/upcoming_changes/19513.new_feature.rst @@ -1,4 +1,4 @@ Preliminary support for `windows/arm64` target ---------------------------------------------- - -`numpy` added support for windows/arm64 target. Please note `OpenBLAS` support is not yet available for windows/arm64 target. +``numpy`` added support for windows/arm64 target. Please note +``OpenBLAS`` support is not yet available for windows/arm64 target.