Skip to content

update ldexp types #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged

update ldexp types #73

merged 1 commit into from
May 15, 2025

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented May 13, 2025

With stock NumPy 2.2.5 on Windows we have

>>> numpy.ldexp.types
# ['ei->e', 'fi->f', 'eq->e', 'fq->f', 'di->d', 'dq->d', 'gi->g', 'gq->g']`

While for Stock NumPy 2.2.5 on Linux we have

>>> numpy.ldexp.types 
# ['ei->e', 'fi->f', 'el->e', 'fl->f', 'di->d', 'dl->d', 'gi->g', 'gl->g']`

The difference is that we have 'q' on Windows instead of 'l' on Linux.

With Intel/Stock NumPy 1.26.4, on both Windows and Linux we have 'l'.

mkl_umath currently has functions for type 'fl->f' and 'dl->d' which have no equivalent in Stock NumPy 2.2.5 on Windows.
This PR resolves this issue. The changes I made is based on what is done in numpy-2.x.x.

With this branch

# Python 3.11.12 | packaged by conda-forge | [MSC v.1943 64 bit (AMD64)]
>>> import mkl_umath, numpy
>>> mkl_umath.use_in_numpy()

>>> mkl_umath.ldexp.types
# ['fi->f', 'fq->f', 'di->d', 'dq->d']
>>> numpy.ldexp.types
# ['ei->e', 'fi->f', 'eq->e', 'fq->f', 'di->d', 'dq->d', 'gi->g', 'gq->g']

@vtavana vtavana self-assigned this May 13, 2025
@vtavana vtavana force-pushed the update-ldexp branch 6 times, most recently from 8395aab to 0b9eeee Compare May 14, 2025 00:30
@vtavana vtavana marked this pull request as ready for review May 14, 2025 06:00
@AndresGuzman-Ballen
Copy link
Contributor

Since this branch is currently being used to debug numpy test failures, I wonder if it'd be worth making this change in this PR:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af4e480..c421df7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@ if(WIN32)
    string(CONCAT PRECISION_FLAGS
      "/fp:fast=2 "
      "/Qimf-precision=high "
+     "/Qprec-sqrt "
      "/Qprotect-parens "
    )
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox ${WARNING_FLAGS} ${SDL_FLAGS} ${PRECISION_FLAGS}")
@@ -81,6 +82,7 @@ elseif(UNIX)
      "${SDL_FLAGS}"
    )
    string(CONCAT PRECISION_FLAGS
+     "-prec-sqrt "
      "-fprotect-parens "
      "-fimf-precision=high "
      "-fp-model fast=2 "

Using assert_almost_equal didn't address the issues I was seeing in the test failures, and it was only when I saw "sqrt" in the test failure did I realize that the failures were probably stemming from some change in the use of the -prec-sqrt flag and sure enough, it was removed in 77ef1a5

Copy link
Contributor

@AndresGuzman-Ballen AndresGuzman-Ballen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the context of fixing the ldexp issue, I think this PR is good!

@ndgrigorian
Copy link
Collaborator

ndgrigorian commented May 15, 2025

@AndresGuzman-Ballen
we had discussion in #69 about removing the option and the possibility of test failures.

What's interesting is that it is apparently no longer going to be supported—but if this means test failures, do we know what alternative they recommend?

Note that following their recommendation to use icx -qnextgen-diag does list -prec-sqrt as being removed.

@vtavana
Copy link
Collaborator Author

vtavana commented May 15, 2025

What's interesting is that it is apparently no longer going to be supported—but if this means test failures, do we know what alternative they recommend?

@ndgrigorian
I talked to Andres yesterday. They use frankenstein internal ICC compiler not icx for Intel numpy recipe. They should continue to use the patched CMakeLists.txt or use icx, if possible.

@AndresGuzman-Ballen
Copy link
Contributor

@vtavana correct! @ndgrigorian sorry for the confusion.

Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the changelog needs to be updated with that change

Copy link
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AndresGuzman-Ballen
Copy link
Contributor

By the way, will we need to increment the patch version number for mkl_umath after this is merged?

@vtavana vtavana merged commit 2de3d22 into main May 15, 2025
32 checks passed
@vtavana vtavana deleted the update-ldexp branch May 15, 2025 21:36
@ndgrigorian
Copy link
Collaborator

By the way, will we need to increment the patch version number for mkl_umath after this is merged?

Do you mean the package version? I figured we would cut a new version around the time of the release, but if numpy builds need it, I can go ahead and do it whenever.

@AndresGuzman-Ballen
Copy link
Contributor

@ndgrigorian good point! I'll keep an eye out for new versions around release time then :) thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants