Skip to content
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

ENH: Add max values comparison for floating point #18863

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

howjmay
Copy link
Contributor

@howjmay howjmay commented Apr 27, 2021

SIMD intrinsics for comparing double/single precision has been
added. Now only NEON and SSE ones are added.

@charris charris changed the title feat: Add max values comparison for floating point ENH: Add max values comparison for floating point Apr 27, 2021
@charris
Copy link
Member

charris commented Apr 27, 2021

See doc/source/dev/development_workflow.rst for the expected prefixes for the commit message.

@charris charris added the component: SIMD Issues in SIMD (fast instruction sets) code or machinery label Apr 27, 2021
Copy link
Member

@seiko2plus seiko2plus left a comment

Choose a reason for hiding this comment

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

Your code here is following x86 behavior rather than IEEE, since If "one" of the two arguments is NaN, the value of the other argument is returned.

Our SIMD interface tries not to differentiate between one architecture and another. in other words, it tries to provide the maximum possible performance for all architectures.

Therefore, I suggest the following:

  • make npyv_max_[f32, f64] map directly to vmaxq_[f32, f64], _mm[,256,512]max[ps, pd], vec_max(VSX) which not oby the standards and also not provide a standardized behavior for NaN.
  • add new intrinics npyv_maxp_[f32, f64] that follow IEEE behavior.
    note: extra p for precise

You will also need to add a testing unit case for both intrinsic which requires the following:

Thank you!

@howjmay howjmay marked this pull request as draft April 28, 2021 14:10
@howjmay howjmay force-pushed the simd-max branch 17 times, most recently from 6f2bf34 to 190f2b9 Compare April 29, 2021 15:27
@howjmay howjmay requested a review from seiko2plus April 29, 2021 15:55
@howjmay howjmay marked this pull request as ready for review April 29, 2021 15:55
Copy link
Member

@seiko2plus seiko2plus left a comment

Choose a reason for hiding this comment

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

several fixes and improvements

numpy/core/src/_simd/_simd.dispatch.c.src Outdated Show resolved Hide resolved
numpy/core/src/_simd/_simd.dispatch.c.src Outdated Show resolved Hide resolved
numpy/core/src/common/simd/neon/math.h Outdated Show resolved Hide resolved
numpy/core/src/common/simd/neon/math.h Outdated Show resolved Hide resolved
numpy/core/tests/test_simd.py Outdated Show resolved Hide resolved
numpy/core/src/common/simd/sse/math.h Outdated Show resolved Hide resolved
numpy/core/src/common/simd/avx2/math.h Outdated Show resolved Hide resolved
numpy/core/src/common/simd/avx512/math.h Outdated Show resolved Hide resolved
numpy/core/src/common/simd/avx2/math.h Outdated Show resolved Hide resolved
numpy/core/src/common/simd/avx2/math.h Outdated Show resolved Hide resolved
@howjmay
Copy link
Contributor Author

howjmay commented Apr 30, 2021

Thank you @seiko2plus ! I learned a lot from your reviews. I have fixed them, please take a look.

@howjmay howjmay force-pushed the simd-max branch 2 times, most recently from 8c861e2 to 49948f9 Compare April 30, 2021 12:20
@howjmay howjmay force-pushed the simd-max branch 3 times, most recently from 95bcd72 to 7e5669b Compare April 30, 2021 12:49
@howjmay howjmay requested a review from seiko2plus April 30, 2021 12:50
Copy link
Member

@seiko2plus seiko2plus left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you!

SIMD intrinsics for comparing double/single precision has been
added. Now only NEON and SSE ones are added.
@seiko2plus
Copy link
Member

Thank you @howjmay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Enhancement component: SIMD Issues in SIMD (fast instruction sets) code or machinery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants