Skip to content

Improve SVE2 optimizations of SimdFloat32ToBFloat16 - #908

Merged
ermig1979 merged 1 commit into
devfrom
cursor/improve-sve2-float32-to-bfloat16-0c2d
Aug 24, 2026
Merged

Improve SVE2 optimizations of SimdFloat32ToBFloat16#908
ermig1979 merged 1 commit into
devfrom
cursor/improve-sve2-float32-to-bfloat16-0c2d

Conversation

@ermig1979

@ermig1979 ermig1979 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Replace the SVE2 software rounding path of SimdFloat32ToBFloat16 with hardware BFloat16 conversion.

Changes

  • Use svcvt_bf16_f32_x + svcvtnt_bf16_f32_x (BFCVT / BFCVTNT) in SimdSve2BFloat16.cpp instead of shift/add rounding.
  • Deinterleave consecutive f32 vectors with svuzp1_f32 / svuzp2_f32 so the convert pair writes sequential bf16 values.
  • Unroll the main loop by 4 destination vectors.
  • Add the change to the Improving list of release 7.2.165 in docs/2026.html.

Test results

  • AArch64 cross-compile of SimdSve2BFloat16.cpp emits bfcvt / bfcvtnt.
  • QEMU user-mode SVE (VL 128/256/512): hardware svcvt/svcvtnt matches Base::Float32ToBFloat16 for 39 sizes per VL, including tails.
  • Packing simulation of uzp1/uzp2 + even/odd convert matches Base for F=4/8/16 and aligned/tail sizes.
  • Native x86 ./Test "-r=.." -fi=Float32ToBFloat16 -tt=1 -ts=1 -w=640 -h=480: ALL TESTS ARE FINISHED SUCCESSFULLY (Base / SSE4.1 / AVX2 / AVX-512BW / AMX).

Test log

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Replace the software rounding path with hardware BFCVT/BFCVTNT conversion
(svcvt_bf16_f32_x + svcvtnt_bf16_f32_x) and unroll the main loop.

Co-authored-by: igor.ermolaev <igor.ermolaev@altezza.org>
@ermig1979
ermig1979 marked this pull request as ready for review August 24, 2026 12:57
@ermig1979
ermig1979 merged commit 822f98a into dev Aug 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants