Thursday, June 25, 2015

Swift 2: SIMD

Russ Bishop:

In Swift 1.2 you could @import simd but it wouldn’t do you much good. The compiler has to map the types to intrinsics, support certain alignment requirements and padding, etc. Swift 1.2 didn’t know how to do any of that so vector extensions were basically unusable.

In Swift 2 that has changed. All the types are present and have full operator implementations. They all have handy initializers (vector initialized to a scalar value, a matrix with diagonals set, and so on). They can convert between the C/Objective-C types quite easily. They have full operator support, including between types so you can multiply a vector and a matrix with wild abandon[…]

[…]

Looking at the SIMD results we can see there may still be a branch somewhere but it isn’t nearly as expensive. We also see that SIMD is faster all cases and in the worst-case scenario it’s three times as fast.

Comments RSS · Twitter

Leave a Comment