Skip to content

Commit

Permalink
ENH: Add support for windows on arm targets (#19513)
Browse files Browse the repository at this point in the history
* add support for windows on arm targets

* Philox: Use  _umulh intrinsic for ARM64 target

* CPU Detection: Refactor to avoid separate pre-processor definition for WoA

* adapt test_dragon4 to avoid using pow (**) to workaround issue in windows C RT for arm64

* Update numpy/core/include/numpy/npy_cpu.h

Co-authored-by: Matti Picus <matti.picus@gmail.com>

* add release note for numpy windows/arm64 support

* Update 19513.new_feature.rst

Co-authored-by: Matti Picus <matti.picus@gmail.com>
Co-authored-by: Charles Harris <charlesr.harris@gmail.com>
  • Loading branch information
3 people committed Jul 27, 2021
1 parent 2a86270 commit 77bc322
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions 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.
7 changes: 4 additions & 3 deletions numpy/core/include/numpy/npy_cpu.h
Expand Up @@ -63,7 +63,8 @@
#define NPY_CPU_HPPA
#elif defined(__alpha__)
#define NPY_CPU_ALPHA
#elif defined(__arm__) || defined(__aarch64__)
#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
Expand All @@ -72,10 +73,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
Expand Down
3 changes: 2 additions & 1 deletion numpy/core/tests/test_scalarprint.py
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion numpy/random/src/philox/philox.h
Expand Up @@ -33,10 +33,16 @@ 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)
#include <intrin.h>
#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) {
Expand Down

0 comments on commit 77bc322

Please sign in to comment.