How are the various similar simd_ functions different from each other?

Viewed 170

In typical Apple fashion, there's no documentation (and what little there borders on trolling). For example, what is simd_precise_normalize(_:)? You’d be forgiven for thinking it was a slower, more precise normalization than simd_fast_normalize(_:). But then why does simd_normalize(_:) exist?

Why is there simd_cross(simd_float3, simd_float3) and cross(SIMD3<Float>, SIMD3<Float>) when typealias simd_float3 = SIMD3<Float>?

And what about the Swift operator overloads on simd_float3?

I've written a bug to Apple about it, but does anyone know?

1 Answers

But then why does simd_normalize(_:) exist?

This comment explains it. simd_normalize is equivalent to simd_precise_normalize unless you are compiling with -ffast-math specified, in which case it is equivalent to simd_fast_normalize. I never used swift only objective-c, but it’s possible there’s equivalent option somewhere in compiler switches or xcode project settings.

Why is there simd_cross(simd_float3, simd_float3) and cross(SIMD3, SIMD3)

I think they are equivalent. Note that comments in the header discuss both C-style API like simd_cross(x,y) and C++ API simd::cross(x,y). It could be that in Swift both are available for some of these functions.

Related