ENH: Convert unary_complex from C universal intrinsics to C++ using Highway#28815
Open
amane-ame wants to merge 4 commits intonumpy:mainfrom
Open
ENH: Convert unary_complex from C universal intrinsics to C++ using Highway#28815amane-ame wants to merge 4 commits intonumpy:mainfrom
amane-ame wants to merge 4 commits intonumpy:mainfrom
Conversation
aef050e to
1338bdc
Compare
A thin wrapper over Google's Highway SIMD library to simplify its interface.
This commit provides the implementation of that wrapper, consisting of:
- simd.hpp: Main header defining the SIMD namespaces and configuration
- simd.inc.hpp: Template header included multiple times with different namespaces
The wrapper eliminates Highway's class tags by:
- Using lane types directly which can be deduced from arguments
- Leveraging namespaces (np::simd and np::simd128) for different register widths
A README is included to guide usage and document design decisions.
SIMD: Update wrapper with improved docs and type support
- Fix hardware/platform terminology in documentation for clarity
- Add support for long double in template specializations
- Add kMaxLanes constant to expose maximum vector width information
- Follows clang formatting style for consistency with NumPy codebase.
SIMD: Improve isolation and constexpr handling in wrapper
- Add anonymous namespace around implementation to ensure each
translation unit gets its own constants based on local flags
- Use HWY_LANES_CONSTEXPR for Lanes function to ensure proper
constexpr evaluation across platforms
Update Highway submodule to latest master
SIMD: Fix compile error by using MaxLanes instead of Lanes for array size
Replace hn::Lanes(f64) with hn::MaxLanes(f64) when defining the index array
size to fix error C2131: "expression did not evaluate to a constant". This error
occurs because Lanes() isn't always constexpr compatible, especially with
scalable vector extensions. MaxLanes() provides a compile-time constant value
suitable for static array allocation and should be used with non-scalable SIMD
extensions when defining fixed-size arrays.
SIMD: Rename NPY_SIMDX to NPY_HWY
Rename Highway wrapper macros for clarity:
- NPY_SIMDX → NPY_HWY
- NPY_SIMDX_F16 → NPY_HWY_F16
- NPY_SIMDX_F64 → NPY_HWY_F64
- NPY_SIMDX_FMA → NPY_HWY_FMA
To avoids confusion with legacy SIMD macros.
1338bdc to
484ce6e
Compare
ixgbe
reviewed
May 20, 2025
| auto infmask = hn::IsInf(smaller); | ||
| auto div_mask = hn::ExclusiveNeither(zeromask, infmask); | ||
|
|
||
| auto ratio = hn::MaskedDiv(div_mask, smaller, larger); |
Contributor
There was a problem hiding this comment.
It seems that MaskedDiv can not be found in RVV (https://github.com/google/highway/blob/master/hwy/ops/rvv-inl.h).
When i compile on BPI-F3(SpacemiT K1 8 core , RVV1.0) , it cause an error.
Author
There was a problem hiding this comment.
It was here: https://github.com/google/highway/blob/c861f4ca87795cd8d57e8879f1677ba858600f1b/hwy/ops/generic_ops-inl.h#L700
Try to update your highway submodule version to latest.
Contributor
There was a problem hiding this comment.
Zero masked arithmetic operations : google/highway@046dee2
Fix review comments : google/highway@329e50a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #28622, merge it first.