You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is meant to serve as an issue to address the specific question of how Zig can, should, and (eventually) will provide support for smoothly transitioning between SoA and AoS.
The AoS strategy (an array of structures) is often more natural, and allows simpler code. However, the SoA strategy (where there is only a single structure, embedding arrays) is often more performance friendly for cache layout and SIMD optimization. Unfortunately, in most languages (as in Zig for the moment), switching between these strategies requires large refactoring.
The experimental (and still only privately-available) programming language named jai provides for novel tooling to dramatically simplify this transition. Jai offers a special tag that can be placed on structure definitions (SOA). When a struct is tagged with SOA, the code is still written as it would be for the AoS strategy, but the memory layout will transparently be SoA. This allows for several pros:
developers can write code in the most intuitive fashion regardless of which memory layout is more performant for the situation
this language support offers the refactor as a single-line change rather than refactoring all the related code
The obvious con is that this bit of tooling is very specific (rather than being something more generalized for memory layout). Additionally, it is an extra bit of special syntax rather than something implemented in the language itself.
From one of the latest video on Jai, the author said something like an idea of a better option for the problem than SoA / AoS. Though he did not return to this afterward.
Prior Art
This issue is meant to serve as an issue to address the specific question of how Zig can, should, and (eventually) will provide support for smoothly transitioning between SoA and AoS.
The AoS strategy (an array of structures) is often more natural, and allows simpler code. However, the SoA strategy (where there is only a single structure, embedding arrays) is often more performance friendly for cache layout and SIMD optimization. Unfortunately, in most languages (as in Zig for the moment), switching between these strategies requires large refactoring.
The experimental (and still only privately-available) programming language named jai provides for novel tooling to dramatically simplify this transition. Jai offers a special tag that can be placed on structure definitions (
SOA
). When a struct is tagged withSOA
, the code is still written as it would be for the AoS strategy, but the memory layout will transparently be SoA. This allows for several pros:The obvious con is that this bit of tooling is very specific (rather than being something more generalized for memory layout). Additionally, it is an extra bit of special syntax rather than something implemented in the language itself.
@tgschultz put together a short prototype of implementing this behavior within Zig which relies on this helper struct.
This issue can be considered an open question and request for proposal for solution.
The text was updated successfully, but these errors were encountered: