Commit a5c8943
feat(simd): I8/I16 SIMD vectors + slice-level int ops (#124, sprint A3)
Adds the signed-byte / signed-half SIMD parity surface for the burn↔ndarray
sprint:
Item 4 — types
• simd_avx512.rs: native I8x64 (__m512i) + I16x32 (__m512i) via
AVX-512BW intrinsics (add/sub/min/max/cmp_gt/saturating/abs/neg).
Plus AVX2-native I8x32 / I16x16 (__m256i) so the 256-bit signed
types live in the same module as F32x8 / F64x4.
• simd_avx2.rs: scalar-array polyfills for I8x64 / I16x32 (the AVX2
tier doesn't have a 64-byte signed type) and re-exports of the
AVX2-native I8x32 / I16x16 from simd_avx512.rs for unified imports.
• simd_neon.rs: NEON-native I8x16 (int8x16_t) + I16x8 (int16x8_t)
via vaddq_s8 / vminq_s8 / vcgtq_s8 + paired/quadrupled scalar
polyfills for I8x32 / I8x64 / I16x16 / I16x32.
• simd.rs: scalar fallbacks for non-x86_64/aarch64 targets and
re-exports for every active tier so consumers write
use ndarray::simd::{I8x32, I8x64, I16x16, I16x32};
Item 5 — slice ops (new file simd_int_ops.rs)
add_i8 / add_i16 / sub_i8 / sub_i16 (mutate-in-place, wrapping)
dot_i8 -> i32 (overflow-safe accumulator)
dot_i16 -> i64 (overflow-safe accumulator)
min_i8 / max_i8 / min_i16 / max_i16
Each chunks via the natural SIMD width of the active tier (64-byte
AVX-512BW when available, 32-byte AVX2, 16-byte NEON) and finishes
with a scalar tail.
Tests (+21 lib tests vs master baseline 1741 -> 1762):
• simd_avx512::int_simd_tests: 9 tests (gated on target_feature=avx512f)
pair-sum 64, signed boundaries, cmp_gt mask, saturating arithmetic.
• simd_int_ops::tests: 11 tests
misaligned tail lengths (63/65/127/129), 127i8 dot 127i8 x 64
overflow safety, signed boundary min/max, empty-slice identity.
• simd_avx2 polyfill build verified with
RUSTFLAGS="-C target-feature=-avx512f".
Build host (this commit): AVX2 path (no avx512f at compile time -> uses
the polyfill in simd_avx2.rs and simd.rs scalar mod for I8x64/I16x32).
Co-authored-by: Claude <noreply@anthropic.com>1 parent f7d2406 commit a5c8943
6 files changed
Lines changed: 1399 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
| 193 | + | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
197 | 198 | | |
198 | 199 | | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
226 | | - | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
| |||
630 | 634 | | |
631 | 635 | | |
632 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
633 | 693 | | |
634 | 694 | | |
635 | 695 | | |
| |||
1012 | 1072 | | |
1013 | 1073 | | |
1014 | 1074 | | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1015 | 1079 | | |
1016 | 1080 | | |
1017 | 1081 | | |
| |||
1036 | 1100 | | |
1037 | 1101 | | |
1038 | 1102 | | |
| 1103 | + | |
1039 | 1104 | | |
1040 | 1105 | | |
1041 | 1106 | | |
| 1107 | + | |
1042 | 1108 | | |
1043 | 1109 | | |
1044 | 1110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
772 | 776 | | |
773 | 777 | | |
774 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
775 | 820 | | |
776 | 821 | | |
777 | 822 | | |
| |||
1007 | 1052 | | |
1008 | 1053 | | |
1009 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1010 | 1059 | | |
1011 | 1060 | | |
1012 | 1061 | | |
| |||
0 commit comments