8000 BUG: Fix building on s390x with clang by charris · Pull Request #28422 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix building on s390x with clang #28422

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
Mar 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: Fix building on s390x with clang
clang on s390x did not have implementations of vector logical
operators such as vec_and, vec_or and vec_xor in vecintrin.h
until __VEC__ == 10305 which caused compile errors. Add
implementations to allow the build to complete.

Currently, clang >= 19 is required for all tests to pass because
that is the minimum version supported by highway on s390x with clang.
  • Loading branch information
jonathan-albrecht-ibm authored and charris committed Mar 3, 2025
commit ac7e1a11f0be590753f1c36077bd142d5f74c496
25 changes: 19 additions & 6 deletions numpy/_core/src/common/simd/vec/operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
/***************************
* Logical
***************************/
#define NPYV_IMPL_VEC_BIN_WRAP(INTRIN, SFX) \
NPY_FINLINE npyv_##SFX npyv_##INTRIN##_##SFX(npyv_##SFX a, npyv_##SFX b) \
{ return vec_##INTRIN(a, b); }

#define NPYV_IMPL_VEC_BIN_CAST(INTRIN, SFX, CAST) \
NPY_FINLINE npyv_##SFX npyv_##INTRIN##_##SFX(npyv_##SFX a, npyv_##SFX b) \
{ return (npyv_##SFX)vec_##INTRIN((CAST)a, (CAST)b); }
Expand All @@ -54,6 +58,15 @@
#else
#define NPYV_IMPL_VEC_BIN_B64(INTRIN) NPYV_IMPL_VEC_BIN_CAST(INTRIN, b64, npyv_b64)
#endif

// Up to clang __VEC__ 10305 logical intrinsics do not support f32 or f64
#if defined(NPY_HAVE_VX) && defined(__clang__) && __VEC__ < 10305
#define NPYV_IMPL_VEC_BIN_F32(INTRIN) NPYV_IMPL_VEC_BIN_CAST(INTRIN, f32, npyv_u32)
#define NPYV_IMPL_VEC_BIN_F64(INTRIN) NPYV_IMPL_VEC_BIN_CAST(INTRIN, f64, npyv_u64)
#else
#define NPYV_IMPL_VEC_BIN_F32(INTRIN) NPYV_IMPL_VEC_BIN_WRAP(INTRIN, f32)
#define NPYV_IMPL_VEC_BIN_F64(INTRIN) NPYV_IMPL_VEC_BIN_WRAP(INTRIN, f64)
#endif
// AND
#define npyv_and_u8 vec_and
#define npyv_and_s8 vec_and
Expand All @@ -64,9 +77,9 @@
#define npyv_and_u64 vec_and
#define npyv_and_s64 vec_and
#if NPY_SIMD_F32
#define npyv_and_f32 vec_and
NPYV_IMPL_VEC_BIN_F32(and)
#endif
#define npyv_and_f64 vec_and
NPYV_IMPL_VEC_BIN_F64(and)
#define npyv_and_b8 vec_and
#define npyv_and_b16 vec_and
#define npyv_and_b32 vec_and
Expand All @@ -82,9 +95,9 @@ NPYV_IMPL_VEC_BIN_B64(and)
#define npyv_or_u64 vec_or
#define npyv_or_s64 vec_or
#if NPY_SIMD_F32
#define npyv_or_f32 vec_or
NPYV_IMPL_VEC_BIN_F32(or)
#endif
#define npyv_or_f64 vec_or
NPYV_IMPL_VEC_BIN_F64(or)
#define npyv_or_b8 vec_or
#define npyv_or_b16 vec_or
#define npyv_or_b32 vec_or
Expand All @@ -100,9 +113,9 @@ NPYV_IMPL_VEC_BIN_B64(or)
#define npyv_xor_u64 vec_xor
#define npyv_xor_s64 vec_xor
#if NPY_SIMD_F32
#define npyv_xor_f32 vec_xor
NPYV_IMPL_VEC_BIN_F32(xor)
#endif
#define npyv_xor_f64 vec_xor
NPYV_IMPL_VEC_BIN_F64(xor)
#define npyv_xor_b8 vec_xor
#define npyv_xor_b16 vec_xor
#define npyv_xor_b32 vec_xor
Expand Down
Loading
0