[swift-users] Design and performance of Vector2/3/4 and Matrix
Joe Groff
jgroff at apple.com
Fri Dec 18 17:30:37 CST 2015
> On Dec 18, 2015, at 3:13 PM, David Turnbull via swift-users <swift-users at swift.org> wrote:
>
> On Fri, Dec 18, 2015 at 2:31 PM, Janosch Hildebrand via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
> 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.
>
> 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 specializations. But it doesn't solve everything so not a priority.
I know that cross-module whole-program optimization is a long term goal for the build system; at what priority, I'm not sure. We do have some totally not-ready-for-primetime functionality for cross-module inlining and optimization that's used by the standard library and overlays; these libraries use special flags to serialize SIL bytecode into the module file. You can poke around the cmake files to see how the stdlib is built, though you're off the supported path if you try to mimic it. Since you're going down the code generation path already, though, you might also take a peek at the guts of the `simd` overlay:
https://github.com/apple/swift/blob/master/stdlib/public/SDK/simd/simd.swift.gyb <https://github.com/apple/swift/blob/master/stdlib/public/SDK/simd/simd.swift.gyb>
Though there isn't a portable `simd` module supporting it on Linux, it shows how LLVM vector types are exported as Swift builtins that can be used to implement vector types in terms of machine SIMD types.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151218/93299a39/attachment.html>
More information about the swift-users
mailing list