Better HN
topnewbestaskshowjobs
Log inSign up

vvimpcrvsh

34 karma · joined Nov 30, 2017 (9y ago) · 4 submissions

Submissions

comment 9y ago · link · parent

I'll add benchmarks soon; I'm trying to make it usable first ;).

Right now, it's within 5% of ugly-style explicit SIMD code in the absolute worst case (the example in the README is more like 1%). The hot bit (the body of the map) compiles down to 100% simd instructions in the order LLVM thinks will be the fastest, and the load/store bit has an extra branch per load/store. This is because faster is mainly a bunch of 1-line wrappers around SIMD intrinsics, and a bunch of polyfills which only get used on machines which don't support those intrinsics.

The main reasons you'd experience a perf hit compared to explicit SIMD when using this library would be using runtime feature detection (minimal, and not implemented yet - would add around 2 branches per simd_iter call), getting lazy with gathers/scatters rather than ugly bit-level hacks, and accidentally using operations which aren't vectorizable on your machine (scatters on non-avx512, reductive operations on non-sse4.2, etc) and not realizing it (explicit simd will throw a SIGILL; faster will use a scalar polyfill).

comment 9y ago · link · parent

LLVM and rustc are pretty fickle with what they'll autovectorize. The idea of faster is to make things which are impossible to autovectorize easy to write as SIMD.

A few examples I'm targeting for the next point release are matrix determinants, cross products, byte-aligned encoding (like https://github.com/AdamNiederer/base100/blob/master/src/lib....), and reductive operations like strcmp. AFAIK none of that can be autovectorized at all.

comment 9y ago · link · parent

Sadly, even something like [1.0f32].map(|s| s.sqrt().abs().recip()).collect() doesn't get vectorized 99% of the time; you can check the disassembly and you'll see sqrtss et al.

comment 9y ago · link · parent

Author of Faster here. Thanks so much for posting this; I was wondering where the flood of stars was coming from!