Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-19 Thread Janosch Hildebrand via swift-users
> On 19 Dec 2015, at 06:19, David Turnbull wrote: > > On Fri, Dec 18, 2015 at 4:34 PM, Janosch Hildebrand > wrote: > If you only care about having a simple cross-platform library, doing a simple > implementation by yourself is

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Janosch Hildebrand via swift-users
> On 19 Dec 2015, at 00:46, Michael Gottesman via swift-users > wrote: >> >> This is becoming clear. Hopefully these patterns can be optimized across >> modules eventually. It's easy enough to write a pre-processor that expands >> the generics into four

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Joe Groff via swift-users
> On Dec 18, 2015, at 3:13 PM, David Turnbull via swift-users > wrote: > > On Fri, Dec 18, 2015 at 2:31 PM, Janosch Hildebrand via swift-users > > wrote: > You will also want to have this code in the same module that

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Michael Gottesman via swift-users
> On Dec 18, 2015, at 5:13 PM, David Turnbull via swift-users > wrote: > > On Fri, Dec 18, 2015 at 2:31 PM, Janosch Hildebrand via swift-users > > wrote: > You will also want to have this code in the same module that

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Jens Alfke via swift-users
> On Dec 18, 2015, at 12:07 PM, David Turnbull via swift-users > wrote: > > In order to be performant, scalars, vectors, and matrices must all be values > types aka structs. This way, for example, an Array can be > passed directly to OpenGL without any

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Janosch Hildebrand via swift-users
You will also want to have this code in the same module that is using this type. If you're using these types from another module you're limited to unspecialized generics which are (unsurprisingly) very slow. I assume these types are intended for your SwiftGL library. If they are only for

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread Joe Groff via swift-users
Do you have the optimizer enabled (using -O)? I see inlining happening as you'd expect. This: let x = Vector2(x: 1, y: 1) foo(x.x) foo(x.r) optimizes down to: %15 = integer_literal $Builtin.Int64, 1 // user: %16 %16 = struct $Int (%15 : $Builtin.Int64)// users: %17, %17,

Re: [swift-users] Design and performance of Vector2/3/4 and Matrix

2015-12-18 Thread David Turnbull via swift-users
On Fri, Dec 18, 2015 at 4:34 PM, Janosch Hildebrand 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