mbutrovich commented on PR #11467: URL: https://github.com/apache/arrow-rs/pull/11467#issuecomment-6511688786
Thanks for running all nine comparisons, @sdf-jkl. > The rewrite has substantial x86 wins, but the ARM results remain mixed. I'd like to keep [figure 5.1](https://gmplib.org/~tege/divcnst-pldi94.pdf) as it is in this PR. The biggest wins are on x86-64 before the v3 target: 1.7-2.1x for `i32` at the baseline target and at `x86-64-v2`, and 1.7x for `i64` `%` at `x86-64-v2`. The other large win is `i64` on AVX-512, at 1.2-1.35x. On the targets that DataFusion and Comet typically target, the rewrite is slower for `i32`. It runs at 0.76-0.97x at `x86-64-v3` and 0.85-0.88x at the default arm64 target, and `i64` `%` runs at 0.76x on arm64. DataFusion [recommends](https://github.com/apache/datafusion/blob/da3cb0a2a973191b19207bff125ae7286e8feb3d/docs/source/user-guide/crate-configuration.md?plain=1#L72-L78) `target-cpu=native`, and Comet [publishes](https://github.com/apache/datafusion-comet/blob/7f73d86fb841f5662f1343cf52b6e6b31eb17dfb/Makefile#L70-L80) binaries built for `x86-64-v3` and `neoverse-n1` (https://github.com/apache/datafusion-comet/pull/3368). The generated code explains the split. On baseline x86-64 and at `x86-64-v2`, LLVM doesn't use a signed widening multiply for `MULSH`. It sign-extends each lane and builds a 64-bit product from three `pmuludq` per two lanes, so the unsigned form cuts the `i32` loop from 36 to 20 instructions per four values. At `x86-64-v3` LLVM uses `vpmuldq`, so there is nothing to save. On aarch64, `smull` and `smulh` compute the signed high product directly, so the sign correction is extra work. The `i32` loop grows from 16 to 20 instructions per eight values, and the `i64` `%` loop loses its 4x unrolling. Taking only the wins would need a variant per target and per type. The kernel PR will measure each type through `unary`, and we can revisit the unsigned form there if baseline x86-64 matters. If we do, I'd cite program (1) in section 8-3 of Warren, "Hacker's Delight", 2nd edition. Your rewrite is that program with the last term equal to `n`, because `m'` is always negative. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
