Skip to content

Add Neon implementation of minmax - #5963

Merged
Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
hazzlim:minmax-val-pr
Jan 15, 2026
Merged

Add Neon implementation of minmax#5963
Stephan T. Lavavej (StephanTLavavej) merged 12 commits into
microsoft:mainfrom
hazzlim:minmax-val-pr

Conversation

@hazzlim

Copy link
Copy Markdown
Contributor
Add and enable a Neon implementation of minmax on ARM64 platforms. The
existing code is refactored to support an unrolled version for
sufficiently large inputs.

This is stacked on #5949.

Performance numbers:

Benchmark Speedup MSVC Speedup Clang
bm<uint8_t, Op::Min_val>/8021 26.191 1.073
bm<uint8_t, Op::Min_val>/63 2.833 0.931
bm<uint8_t, Op::Max_val>/8021 24.444 1.04
bm<uint8_t, Op::Max_val>/63 3.209 1.004
bm<uint8_t, Op::Both_val>/8021 66.888 28.622
bm<uint8_t, Op::Both_val>/63 2.219 2.946
bm<uint16_t, Op::Min_val>/8021 13.457 1.023
bm<uint16_t, Op::Min_val>/31 2.25 1.023
bm<uint16_t, Op::Max_val>/8021 13.457 1.023
bm<uint16_t, Op::Max_val>/31 2.588 1.023
bm<uint16_t, Op::Both_val>/8021 38.111 14.178
bm<uint16_t, Op::Both_val>/31 2.324 2.689
bm<uint32_t, Op::Min_val>/8021 23.837 7.554
bm<uint32_t, Op::Min_val>/15 3.896 3
bm<uint32_t, Op::Max_val>/8021 24.318 7.495
bm<uint32_t, Op::Max_val>/15 3.987 2.921
bm<uint32_t, Op::Both_val>/8021 12.5 8.182
bm<uint32_t, Op::Both_val>/15 2.338 2.857
bm<uint64_t, Op::Min_val>/8021 2.01 0.684
bm<uint64_t, Op::Min_val>/7 1.374 1.5
bm<uint64_t, Op::Max_val>/8021 2.115 0.7
bm<uint64_t, Op::Max_val>/7 1.495 1.5
bm<uint64_t, Op::Both_val>/8021 1.029 0.741
bm<uint64_t, Op::Both_val>/7 0.967 1.321
bm<int8_t, Op::Min_val>/8021 26.191 1.073
bm<int8_t, Op::Min_val>/63 3.103 1.111
bm<int8_t, Op::Max_val>/8021 26.111 1.087
bm<int8_t, Op::Max_val>/63 3.286 1.167
bm<int8_t, Op::Both_val>/8021 66.957 28
bm<int8_t, Op::Both_val>/63 1.87 2.574
bm<int16_t, Op::Min_val>/8021 12.866 0.99
bm<int16_t, Op::Min_val>/31 1.952 0.978
bm<int16_t, Op::Max_val>/8021 12.866 1.023
bm<int16_t, Op::Max_val>/31 1.933 0.996
bm<int16_t, Op::Both_val>/8021 28.667 14.178
bm<int16_t, Op::Both_val>/31 2.066 2.42
bm<int32_t, Op::Min_val>/8021 24.405 7.595
bm<int32_t, Op::Min_val>/15 3.983 2.921
bm<int32_t, Op::Max_val>/8021 24.405 7.667
bm<int32_t, Op::Max_val>/15 4.075 2.921
bm<int32_t, Op::Both_val>/8021 14.659 8.182
bm<int32_t, Op::Both_val>/15 2.442 2.921
bm<int64_t, Op::Min_val>/8021 2.16 0.735
bm<int64_t, Op::Min_val>/7 1.6 1.64
bm<int64_t, Op::Max_val>/8021 2.07 0.713
bm<int64_t, Op::Max_val>/7 1.495 1.605
bm<int64_t, Op::Both_val>/8021 1.23 0.761
bm<int64_t, Op::Both_val>/7 0.946 1.35
bm<float, Op::Min_val>/8021 8.928 4.167
bm<float, Op::Min_val>/15 1.971 1.338
bm<float, Op::Max_val>/8021 9.126 4.148
bm<float, Op::Max_val>/15 2.017 1.307
bm<float, Op::Both_val>/8021 4.767 3.855
bm<float, Op::Both_val>/15 0.954 0.933
bm<double, Op::Min_val>/8021 4.563 2.182
bm<double, Op::Min_val>/7 0.854 0.76
bm<double, Op::Max_val>/8021 4.362 2.121
bm<double, Op::Max_val>/7 0.937 0.767
bm<double, Op::Both_val>/8021 2.118 1.964
bm<double, Op::Both_val>/7 0.899 0.47
Comment thread stl/inc/xutility Outdated
Comment thread stl/src/vector_algorithms.cpp Outdated
Comment thread stl/src/vector_algorithms.cpp Outdated
Comment thread stl/src/vector_algorithms.cpp
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added performance Must go faster ARM64 Related to the ARM64 architecture labels Dec 18, 2025
@StephanTLavavej

Copy link
Copy Markdown
Member

#5949 has been merged, so this should be ready to be revised.

As a reminder, draft mode disables PR checks when commits are pushed. Merely moving a PR out of draft mode won't trigger checks, so you should mark as "ready for review" and then push commits to trigger PR checks.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Work In Progress in STL Code Reviews Jan 8, 2026
@hazzlim
Hari Limaye (hazzlim) marked this pull request as ready for review January 9, 2026 01:42
@hazzlim
Hari Limaye (hazzlim) requested a review from a team as a code owner January 9, 2026 01:42
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Work In Progress to Initial Review in STL Code Reviews Jan 9, 2026
Comment thread stl/src/vector_algorithms.cpp
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Ready To Merge in STL Code Reviews Jan 13, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Ready To Merge to Merging in STL Code Reviews Jan 15, 2026
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 44821d9 into microsoft:main Jan 15, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Jan 15, 2026
@StephanTLavavej

Copy link
Copy Markdown
Member

📉 🦾 📈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ARM64 Related to the ARM64 architecture performance Must go faster

3 participants