From ab526f2beedfb4ef917e259e5213a30e735bc206 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 11 Sep 2025 08:08:12 -0500 Subject: [PATCH 1/5] Drop support for remainder --- mkl_umath/generate_umath.py | 8 ++------ mkl_umath/src/mkl_umath_loops.c.src | 30 ----------------------------- mkl_umath/src/mkl_umath_loops.h.src | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/mkl_umath/generate_umath.py b/mkl_umath/generate_umath.py index f83b013..0204de3 100644 --- a/mkl_umath/generate_umath.py +++ b/mkl_umath/generate_umath.py @@ -717,12 +717,8 @@ def english_upper(s): TD(inexactvec), ), # 'arctan2': -'remainder': - Ufunc(2, 1, None, - docstrings.get('numpy._core.umath.remainder'), - None, - TD(inexactvec), - ), +# 'remainder': Intel(R) MKL function v?Remainder follows C's modulo operator, +# but NumPy is expecting Python's one # 'divmod': # 'hypot': 'isnan': diff --git a/mkl_umath/src/mkl_umath_loops.c.src b/mkl_umath/src/mkl_umath_loops.c.src index 1890dcd..7de860d 100644 --- a/mkl_umath/src/mkl_umath_loops.c.src +++ b/mkl_umath/src/mkl_umath_loops.c.src @@ -835,36 +835,6 @@ mkl_umath_@TYPE@_@kind@(char **args, const npy_intp *dimensions, const npy_intp } /**end repeat1**/ -void -mkl_umath_@TYPE@_remainder(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func)) -{ - const int contig = IS_BINARY_CONT(@type@, @type@); - const int disjoint_or_same1 = DISJOINT_OR_SAME(args[0], args[2], dimensions[0], sizeof(@type@)); - const int disjoint_or_same2 = DISJOINT_OR_SAME(args[1], args[2], dimensions[0], sizeof(@type@)); - const int can_vectorize = contig && disjoint_or_same1 && disjoint_or_same2; - int ignore_fpstatus = 0; - - if (can_vectorize && dimensions[0] > VML_TRANSCEDENTAL_THRESHOLD) { - ignore_fpstatus = 1; - CHUNKED_VML_CALL3(v@s@Remainder, dimensions[0], @type@, args[0], args[1], args[2]); - /* v@s@Remainder(dimensions[0], (@type@*) args[0], (@type@*) args[1], (@type@*) args[2]); */ - } - else { - BINARY_LOOP { - const @type@ in1 = *(@type@ *)ip1; - const @type@ in2 = *(@type@ *)ip2; - int invalid_cases = !npy_isnan(in1) && in2 == 0; - invalid_cases |= (in1 == NPY_INFINITY || in1 == -NPY_INFINITY) && !npy_isnan(in2); - invalid_cases |= (in1 != NPY_INFINITY && in1 != -NPY_INFINITY) && (in2 == NPY_INFINITY || in2 == -NPY_INFINITY); - ignore_fpstatus |= invalid_cases; - divmod@c@(in1, in2, (@type@ *)op1); - } - } - if (ignore_fpstatus) { - feclearexcept(FE_UNDERFLOW | FE_INVALID); - } -} - /**begin repeat1 * # kind = cos, sin, tan, arccos, arcsin, arctan, cosh, sinh, tanh, arccosh, arcsinh, arctanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log1p, log10# * # func = cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log1p, log10# diff --git a/mkl_umath/src/mkl_umath_loops.h.src b/mkl_umath/src/mkl_umath_loops.h.src index a9f7d63..714c877 100644 --- a/mkl_umath/src/mkl_umath_loops.h.src +++ b/mkl_umath/src/mkl_umath_loops.h.src @@ -58,7 +58,7 @@ copysign, cos, cosh, divide, divmod, isfinite, isinf, isnan, equal, exp, exp2, expm1, fabs, floor, fmax, fmin, frexp, greater, greater_equal, ldexp, less, less_equal, log, log2, log10, log1p, logical_and, logical_not, logical_or, logical_xor, multiply, modf, - negative, nextafter, not_equal, positive, reciprocal, remainder, rint, sign, signbit, sin, + negative, nextafter, not_equal, positive, reciprocal, rint, sign, signbit, sin, sinh, spacing, sqrt, square, subtract, tan, tanh, trunc# */ MKL_UMATH_API From 424d6268c4c62781727aaebecf8f35f00e724cc2 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 11 Sep 2025 08:08:30 -0500 Subject: [PATCH 2/5] Add TODO comment to divmod --- mkl_umath/generate_umath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkl_umath/generate_umath.py b/mkl_umath/generate_umath.py index 0204de3..6a1a69d 100644 --- a/mkl_umath/generate_umath.py +++ b/mkl_umath/generate_umath.py @@ -719,7 +719,7 @@ def english_upper(s): # 'arctan2': # 'remainder': Intel(R) MKL function v?Remainder follows C's modulo operator, # but NumPy is expecting Python's one -# 'divmod': +# 'divmod': TODO: check if it can be added # 'hypot': 'isnan': Ufunc(1, 1, None, From 4379a6bfc037d2a84c74bb82fd6ed6235154a51e Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 11 Sep 2025 08:09:47 -0500 Subject: [PATCH 3/5] Add clarification to the code stating why maximum/minimum were dropped --- mkl_umath/generate_umath.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkl_umath/generate_umath.py b/mkl_umath/generate_umath.py index 6a1a69d..9de1112 100644 --- a/mkl_umath/generate_umath.py +++ b/mkl_umath/generate_umath.py @@ -532,8 +532,8 @@ def english_upper(s): None, TD(inexactvec + cmplxvec, out='?'), ), -# 'maximum': -# 'minimum': +# 'maximum': no dedicated Intel(R) MKL function +# 'minimum': no dedicated Intel(R) MKL function # 'clip': 'fmax': Ufunc(2, 1, ReorderableNone, From 6fb240aa6b364f57242a00403c703186c05a1c4e Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 11 Sep 2025 08:11:17 -0500 Subject: [PATCH 4/5] Fix typos indentified by codespell --- mkl_umath/src/blocking_utils.h | 2 +- mkl_umath/src/fast_loop_macros.h | 2 +- mkl_umath/src/mkl_umath_loops.c.src | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mkl_umath/src/blocking_utils.h b/mkl_umath/src/blocking_utils.h index 4acd31b..7e5e433 100644 --- a/mkl_umath/src/blocking_utils.h +++ b/mkl_umath/src/blocking_utils.h @@ -27,7 +27,7 @@ #include "numpy/arrayobject.h" -/* Adapated from NumPy's source code. +/* Adapted from NumPy's source code. * https://github.com/numpy/numpy/blob/main/LICENSE.txt */ /* diff --git a/mkl_umath/src/fast_loop_macros.h b/mkl_umath/src/fast_loop_macros.h index ea5130c..3daf032 100644 --- a/mkl_umath/src/fast_loop_macros.h +++ b/mkl_umath/src/fast_loop_macros.h @@ -51,7 +51,7 @@ #define NPY_ASSUME_ALIGNED(p, b) #endif -/* Adapated from NumPy's source code. +/* Adapted from NumPy's source code. * https://github.com/numpy/numpy/blob/main/LICENSE.txt */ /** diff --git a/mkl_umath/src/mkl_umath_loops.c.src b/mkl_umath/src/mkl_umath_loops.c.src index 7de860d..7f78d86 100644 --- a/mkl_umath/src/mkl_umath_loops.c.src +++ b/mkl_umath/src/mkl_umath_loops.c.src @@ -48,7 +48,7 @@ #define USE_NUMPY_2 #endif -/* Adapated from NumPy's source code. +/* Adapted from NumPy's source code. * https://github.com/numpy/numpy/blob/main/LICENSE.txt */ /* From 451eea9083f0b2c92dda6130bc3c12eb08f4d5fd Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 11 Sep 2025 08:17:30 -0500 Subject: [PATCH 5/5] Add PR to the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aece0d7..4b4473d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Dropped support for `maximum` and `minimum` [gh-104](https://github.com/IntelPython/mkl_umath/pull/104) +* Dropped support for `remainder` function [gh-110](https://github.com/IntelPython/mkl_umath/pull/110) ## [0.2.0] - 2025-06-03 This release updates `mkl_umath` to be aligned with both numpy-1.26.x and numpy-2.x.x.