google / google/highway

Evaluate need for Non-Contiguous Element-Wise Load/Store Functions like npyv_loadn2_* and npyv_storen2_* in NumPy ?

Open
#2,728 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5.8k
Forks
471
Avg merge
1d 6h
Merged PRs (30d)
81

Description

Based on the discussion in https://github.com/numpy/numpy/pull/29766#discussion_r2362473314 ,I've attempted ARM NEON implementations for the following two functions:
npyv_loadn2_f32 npyv_loadn2_f64

Could you please review these implementations and confirm if they conform to Highway library norms (e.g., descriptor-based API, portability, and backend consistency)? This will help me decide whether to proceed with implementations for additional functions.

```
// Load 2 float32 elements from ptr and ptr + stride, pack into Vec128
HWY_API Vec128 LoadN2(Simd /*d*/, const float* HWY_RESTRICT ptr, size_t stride) {
const uint32x2_t a = vld1_u32(reinterpret_cast(ptr));
const uint32x2_t b = vld1_u32(reinterpret_cast(ptr + stride));
return Vec128(vreinterpretq_f32_u32(vcombine_u32(a, b)));
}

// Load 2 float64 elements from ptr and ptr + stride
HWY_API Vec128 LoadN2(Simd /*d*/, const double* HWY_RESTRICT ptr, size_t /*stride*/) {
return Vec128(vld1q_f64(ptr));
}
```

Thank you for your feedback!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.