summaryrefslogtreecommitdiff
path: root/numpy/random/src
diff options
context:
space:
mode:
authorKevin Sheppard <bashtage@users.noreply.github.com>2019-05-27 11:11:57 +0100
committermattip <matti.picus@gmail.com>2019-05-27 22:58:35 +0300
commit9c261e6d617fcb3d58708f10b52dd3ea1eb6e301 (patch)
tree2c4c250f5ee5694a740b3308393ec0251e1cfbda /numpy/random/src
parent23853d65e5c31f182a405427f580123f214e386e (diff)
downloadnumpy-9c261e6d617fcb3d58708f10b52dd3ea1eb6e301.tar.gz
PERF: Reorder header for philox (#34)
* PERF: Reorder header for philox Reorder header so that support uint128 is always used if avilable, irrespective of platform
Diffstat (limited to 'numpy/random/src')
-rw-r--r--numpy/random/src/pcg64/pcg64.h2
-rw-r--r--numpy/random/src/philox/philox.h18
2 files changed, 10 insertions, 10 deletions
diff --git a/numpy/random/src/pcg64/pcg64.h b/numpy/random/src/pcg64/pcg64.h
index d4c96ff5f..a28c8eaa6 100644
--- a/numpy/random/src/pcg64/pcg64.h
+++ b/numpy/random/src/pcg64/pcg64.h
@@ -62,7 +62,7 @@
extern "C" {
#endif
-#if __SIZEOF_INT128__ && !defined(PCG_FORCE_EMULATED_128BIT_MATH)
+#if defined(__SIZEOF_INT128__) && !defined(PCG_FORCE_EMULATED_128BIT_MATH)
typedef __uint128_t pcg128_t;
#define PCG_128BIT_CONSTANT(high, low) (((pcg128_t)(high) << 64) + low)
#else
diff --git a/numpy/random/src/philox/philox.h b/numpy/random/src/philox/philox.h
index ae6cf9308..309d89eae 100644
--- a/numpy/random/src/philox/philox.h
+++ b/numpy/random/src/philox/philox.h
@@ -25,10 +25,17 @@ _philox4x64bumpkey(struct r123array2x64 key) {
return key;
}
+/* Prefer uint128 if available: GCC, clang, ICC */
+#ifdef __SIZEOF_INT128__
+static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) {
+ __uint128_t product = ((__uint128_t)a) * ((__uint128_t)b);
+ *hip = product >> 64;
+ return (uint64_t)product;
+}
+#else
#ifdef _WIN32
#include <intrin.h>
-/* TODO: This isn't correct for many platforms */
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_M_AMD64)
#pragma intrinsic(_umul128)
#else
#pragma intrinsic(__emulu)
@@ -59,13 +66,6 @@ static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) {
return _umul128(a, b, hip);
}
#else
-#if __SIZEOF_INT128__
-static NPY_INLINE uint64_t mulhilo64(uint64_t a, uint64_t b, uint64_t *hip) {
- __uint128_t product = ((__uint128_t)a) * ((__uint128_t)b);
- *hip = product >> 64;
- return (uint64_t)product;
-}
-#else
static NPY_INLINE uint64_t _umul128(uint64_t a, uint64_t b, uint64_t *high) {
uint64_t a_lo, a_hi, b_lo, b_hi, a_x_b_hi, a_x_b_mid, a_x_b_lo, b_x_a_mid,