[swift-users] Design and performance of Vector2/3/4 and Matrix
dturnbull at gmail.com
Fri Dec 18 23:19:17 CST 2015
On Fri, Dec 18, 2015 at 4:34 PM, Janosch Hildebrand <jnosh at jnosh.com> wrote:
> If you only care about having a simple cross-platform library, doing a
> simple implementation by yourself is fine. Also Swift (well, LLVM) is also
> pretty good at auto-vectorization so you get decent results for custom
> vector/matrix types.
> However OpenGL-related code is usually pretty performance sensitive and
> the math parts doubly so, so I'd recommend wrapping some appropriate
> libraries instead of writing your own...
Multiplying two mat4x4 is one of the most complex and common operations.
Doing 2 million of these...
C++: 1.3 seconds
Swift: 1.9 seconds
The C++ code is glm using packed SIMD operations. Swift is just plain
whatever LLVM gave me with -O.
While implementing the multiplication I darn near fell out of my chair when
the compiler said, "Expression was too complex to be solved in reasonable
time; consider breaking up the expression into distinct sub-expressions." I
had to break it in half twice before the compiler stopped complaining about
the math being too hard.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-users