Skip to content

Commit b46c455

Browse files
amane-ameseiko2plus
authored andcommitted
ENH: Convert unary_fp from C universal intrinsics to C++ using Highway (#13)
* ENH, SIMD: Initial implementation of Highway wrapper 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. * Convert unary_fp to highway. --------- Co-authored-by: Sayed Adel <seiko@imavr.com>
1 parent 73f8bd0 commit b46c455

File tree

3 files changed

+400
-250
lines changed

3 files changed

+400
-250
lines changed

numpy/_core/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,13 +1029,14 @@ foreach gen_mtargets : [
10291029
],
10301030
[
10311031
'loops_unary_fp.dispatch.h',
1032-
src_file.process('src/umath/loops_unary_fp.dispatch.c.src'),
1032+
'src/umath/loops_unary_fp.dispatch.cpp',
10331033
[
10341034
SSE41, SSE2,
10351035
VSX2,
10361036
ASIMD, NEON,
10371037
VXE, VX,
10381038
LSX,
1039+
RVV,
10391040
]
10401041
],
10411042
[

numpy/_core/src/umath/loops_unary_fp.dispatch.c.src

Lines changed: 0 additions & 249 deletions
This file was deleted.

0 commit comments

Comments
 (0)