|
| 1 | +# Benchmark Rust explicit simd |
| 2 | + |
| 3 | +This repository contains benchmarks for common vertical and horizontal operations that |
| 4 | +leverage SIMD, comparing different implementations of the same algorithms |
| 5 | +in them using `packed_simd2` and `core_simd`. |
| 6 | + |
| 7 | +Things implemented: |
| 8 | + |
| 9 | +* sum of values |
| 10 | +* sum of nullable values where nulls are represented as `Vec<bool>` |
| 11 | +* sum of nullable values where nulls are represented as `Bitmap` |
| 12 | + |
| 13 | +Algorithms implemented: |
| 14 | + |
| 15 | +* `core_simd`: vertical sum over lanes with a reduce at the end using `core_simd` |
| 16 | +* `packed_simd`: vertical sum over lanes with a reduce at the end using `packed_simd` |
| 17 | +* `nonsimd`: vertical sum over lanes with a reduce at the end using Rust arrays |
| 18 | +* `naive`: sum using rust iterators |
| 19 | + |
| 20 | +## Bench results on my computer |
| 21 | + |
| 22 | +### Sum of values |
| 23 | + |
| 24 | +``` |
| 25 | +core_simd_sum 2^20 f32 [184.95 us 185.86 us 186.97 us] |
| 26 | +packed_simd_sum 2^20 f32 [184.97 us 186.85 us 189.59 us] |
| 27 | +nonsimd_sum 2^20 f32 [191.35 us 192.67 us 194.46 us] |
| 28 | +naive_sum 2^20 f32 [1.6385 ms 1.6426 ms 1.6466 ms] |
| 29 | +``` |
| 30 | + |
| 31 | +### Sum of nullable values (`Vec<bool>`) |
| 32 | + |
| 33 | +``` |
| 34 | +core_simd_sum null 2^20 f32 [882.21 us 889.56 us 897.74 us] |
| 35 | +packed_simd_sum null 2^20 f32 [824.37 us 835.77 us 849.63 us] |
| 36 | +nonsimd_sum null 2^20 f32 [695.79 us 707.87 us 721.98 us] |
| 37 | +naive_sum null 2^20 f32 [1.6418 ms 1.6520 ms 1.6660 ms] |
| 38 | +``` |
| 39 | + |
| 40 | +### Sum of nullable values (`Bitmap`) |
| 41 | + |
| 42 | +``` |
| 43 | +core_simd_sum bitmap 2^20 f32 [929.95 us 936.31 us 943.64 us] |
| 44 | +nonsimd_sum bitmap 2^20 f32 [454.78 us 462.08 us 471.82 us] |
| 45 | +naive_sum bitmap 2^20 f32 [1.7633 ms 1.7736 ms 1.7855 ms] |
| 46 | +``` |
| 47 | + |
| 48 | +### Conclusions so far: |
| 49 | + |
| 50 | +* for non-null sums, it is advantageous to use SIMD |
| 51 | +* for sums with nulls, it is not advantageous to use SIMD |
| 52 | + |
| 53 | +## License |
| 54 | + |
| 55 | +Licensed under either of |
| 56 | + |
| 57 | + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 58 | + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 59 | + |
| 60 | +at your option. |
| 61 | + |
| 62 | +### Contribution |
| 63 | + |
| 64 | +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
0 commit comments