Contents

capnslipp/vuckt

Vuckt is Swift library providing Obj-C-compatible integral & floating vector struct types with zero-cost SIMD vector bridging, and convenience methods to bridge to/from other vector-ish types throughout Cocoa. Vuckt is designed to be a “plumbing-level” vector library, that is, it

Performance

Vuckt is fast. Vuckt achieves its swiftness by backing every possible calculation with a C-side call into a simd method (which compiles down to little more than just a SIMD CPU instruction in optimized/release builds), and a few tricks like using @_transparent in Swift (which seems to encourage the Swift compiler to inline the method, eliminating function overhead), and building on a C struct that matches the memory layout of native SIMD types for zero-cost casts (reinforced by C++ static_asserts ensuring everything lines up at c9mpile-time.

Vuckt performs significantly faster than Swift-native SIMD, both in Release builds:

| | iPhone 13 Pro<br/><sub>Geekbench 6 CPU<br/>single-core score: 2364</sub> | iPad Pro M4 11"<br/><sub>Geekbench 6 CPU<br/>single-core score: 3744</sub> | Mac Studio M2 Max<br/><sub>Geekbench 6 CPU<br/>single-core score: 2727</sub> | |-----------------------|--------------------|--------------------|--------------------| | Vuckt Float3 | 0.277 s | 0.265 s | 0.286 s | | Swift SIMD3<Float> | 0.803 s (+190%) | 0.465 s (+75%) | 0.497 s (+74%) | | C/Obj-C GLKVector3 | 0.275 s (-1%) | 0.271 s (+2%) | 0.273 s (-5%) | | C/Obj-C simd_float3 | 0.927 s (+235%) | 0.540 s (+104%) | 0.581 s (+103%) |

and Debug builds:

| | iPhone 13 Pro<br/><sub>Geekbench 6 CPU<br/>single-core score: 2364</sub> | iPad Pro M4 11"<br/><sub>Geekbench 6 CPU<br/>single-core score: 3744</sub> | Mac Studio M2 Max<br/><sub>Geekbench 6 CPU<br/>single-core score: 2727</sub> | |-----------------------|--------------------|--------------------|---------------------| | Vuckt Float3 | 3.323 s | 2.176 s | 2.979 s | | Swift SIMD3<Float> | 18.005 s (+442%) | 9.556 s (+339%) | 14.038 s (+371%) | | C/Obj-C GLKVector3 | 2.712 s (-18%) | 1.858 s (-15%) | 2.319 s (-22%) | | C/Obj-C simd_float3 | 1.615 s (-51%) | 1.108 s (-49%) | 1.287 s (-57%) |

<sub>(Lower seconds and percentages are better. Tests performed with VucktPerformanceTests.swift and VucktCPerformanceTests.m using Xcode 26.4.1 and Swift 6.3.1.)</sub>

License

Vuckt is provided with a fully-permissive Public Domain license, because it really should've been built-into Swift.  I'm not one to claim rights over something so straight-forward and essential as a solid, interoperable, effecient vector library.

To Do List

  • [ ] Implement Float2x2
  • [ ] Finish implementing FloatRotor (feature/float-rotor branch)
  • [ ] Make the Package.swift use the C backend (which is significantly faster), eliminating the …_NoObjCBridge.swift variants

‣ Perhaps still offer “…_NoObjCBridge” as an alternate target, for cases/platforms where Obj-C isn't available.

  • [ ] More unit test coverage
  • [ ] More thorough performance tests
  • [ ] Double & Half floating vectors
  • [ ] Char, UChar, Short, UShort, UInt, Long, & ULong integer vectors
  • [ ] Add conversions to/from Spatial types

* [ ] Add performance tests for Spatial Vector3D operations, and add perf results to README

* [ ] Especially for rotations (which is a rarity for vector math libs)

Package Metadata

Repository: capnslipp/vuckt

Default branch: master

README: README.md