Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit support for AoS/SoA #2634

Closed
HalosGhost opened this issue Jun 7, 2019 · 3 comments
Closed

Explicit support for AoS/SoA #2634

HalosGhost opened this issue Jun 7, 2019 · 3 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@HalosGhost
Copy link

HalosGhost commented Jun 7, 2019

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 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.

@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.

@andrewrk andrewrk added this to the 0.6.0 milestone Jun 7, 2019
@dadhi
Copy link

dadhi commented Sep 30, 2019

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.

@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Jan 7, 2020
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 2020
@ghost
Copy link

ghost commented Nov 30, 2020

Potentially relevant: #7257

@andrewrk
Copy link
Member

#7920 and #7854 demonstrate two perfectly reasonable ways to implement this in the std lib. There is no language feature needed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

3 participants