Skip to content

Commit 0bb4631

Browse files
authored
Merge pull request #109 from IntelPython/remove-dedicated-log2-loop
No need to have a separate loop for `log2` umath
2 parents 89719d2 + 633d08f commit 0bb4631

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Changed
1616
* Dropped support for `maximum` and `minimum` [gh-104](https://github.com/IntelPython/mkl_umath/pull/104)
17+
* Used a common umath loop for `log2` function to match NumPy [gh-109](https://github.com/IntelPython/mkl_umath/pull/109)
1718

1819
## [0.2.0] - 2025-06-03
1920
This release updates `mkl_umath` to be aligned with both numpy-1.26.x and numpy-2.x.x.

mkl_umath/src/mkl_umath_loops.c.src

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -866,9 +866,9 @@ mkl_umath_@TYPE@_remainder(char **args, const npy_intp *dimensions, const npy_in
866866
}
867867

868868
/**begin repeat1
869-
* # kind = cos, sin, tan, arccos, arcsin, arctan, cosh, sinh, tanh, arccosh, arcsinh, arctanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log1p, log10#
870-
* # func = cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log1p, log10#
871-
* # VML = Cos, Sin, Tan, Acos, Asin, Atan, Cosh, Sinh, Tanh, Acosh, Asinh, Atanh, Abs, Floor, Ceil, Rint, Trunc, Cbrt, Sqrt, Expm1, Ln, Log1p, Log10#
869+
* # kind = cos, sin, tan, arccos, arcsin, arctan, cosh, sinh, tanh, arccosh, arcsinh, arctanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log2, log1p, log10#
870+
* # func = cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh, fabs, floor, ceil, rint, trunc, cbrt, sqrt, expm1, log, log2, log1p, log10#
871+
* # VML = Cos, Sin, Tan, Acos, Asin, Atan, Cosh, Sinh, Tanh, Acosh, Asinh, Atanh, Abs, Floor, Ceil, Rint, Trunc, Cbrt, Sqrt, Expm1, Ln, Log2, Log1p, Log10#
872872
*/
873873
void
874874
mkl_umath_@TYPE@_@kind@(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func))
@@ -931,37 +931,6 @@ mkl_umath_@TYPE@_@kind@(char **args, const npy_intp *dimensions, const npy_intp
931931
}
932932
/**end repeat1**/
933933

934-
void
935-
mkl_umath_@TYPE@_log2(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func))
936-
{
937-
const int contig = IS_UNARY_CONT(@type@, @type@);
938-
const int disjoint_or_same = DISJOINT_OR_SAME(args[0], args[1], dimensions[0], sizeof(@type@));
939-
const int can_vectorize = contig && disjoint_or_same;
940-
int ignore_fpstatus = 0;
941-
942-
if (can_vectorize && dimensions[0] > VML_TRANSCEDENTAL_THRESHOLD)
943-
{
944-
ignore_fpstatus = 1;
945-
CHUNKED_VML_CALL2(v@s@Log2, dimensions[0], @type@, args[0], args[1]);
946-
/* v@s@Log2(dimensions[0], (@type@*) args[0], (@type@*) args[1]); */
947-
}
948-
else {
949-
UNARY_LOOP_DISPATCH(
950-
@type@, @type@
951-
,
952-
can_vectorize
953-
,
954-
const @type@ in1 = *(@type@ *)ip1;
955-
const int invalid_cases = in1 < 0 || in1 == 0 || npy_isnan(in1) || in1 == -NPY_INFINITY;
956-
ignore_fpstatus |= invalid_cases;
957-
*(@type@ *)op1 = log2@c@(in1);
958-
)
959-
}
960-
if (ignore_fpstatus) {
961-
feclearexcept(FE_DIVBYZERO | FE_INVALID);
962-
}
963-
}
964-
965934
void
966935
mkl_umath_@TYPE@_absolute(char **args, const npy_intp *dimensions, const npy_intp *steps, void *NPY_UNUSED(func))
967936
{

0 commit comments

Comments
 (0)