SE-0229 — SIMD Vectors

Review Update

The core team met and discussed the feedback received so far, and has made the following recommendations:

Intention to accept

The core team feels this is an important addition to the language that will open up SIMD programming to a wide audience in an approachable way.

The core team also made the following decisions for when the proposal is accepted:

  • There were many requests for additional math operations. These are certainly important, but can be left to later proposals once this foundational proposal has landed.
  • The initializers for VectorN from an Array should instead be generic from any Sequence.
  • The . prefix should be used on all mask-producing operators:
    • In case of .==, this helps disambiguate between the Bool and Mask-returning forms
    • In case of .& and .| this helps resolve the precedence problem of & and the inconsistency of a non-short-circuiting &&
    • While it doesn't have similar motivations, for consistency .< & co should also have a leading dot.
  • Pointwise arithmetic operations will not have a leading dot.
  • To avoid confusion with Collection semantics and future types like matrices, count should be renamed elementCount
  • The element properties x, y, z and w will be available on vectors of up to 4, along with the common named swizzles even, odd, high and low.
    • The general swizzle operation init(gathering:at:) feels unsatisfactory, and so should be deferred for a later proposal after more thought.
    • Brute-forcing all possible swizzles on the smaller vectors as properties was also ruled out.

Prototype of "generic"-style vectors

The majority of the feedback received during the thread was regarding the alternate "generic" spelling: Vector3<Int8> rather than Int8.Vector3.

It is still unclear which is the better form. However, in order to better make the decision, the core team has asked the proposal author to implement a prototype showing the alternate form. Reviewers will then be able to try out either form in order to help make the decision. (since @scanon is on vacation this week, @moiseev is kindly helping out with this prototype)

In addition, the proposal should be revised to spell out more explicitly some of the details, for example, of what masks are and the role they play.

We will hold the review open pending that prototype, and I'll post again when it's available.

21 Likes