3 ms·
No, they're not cache friendly. The problem is row-based vs column-based. Array of structs vs Structure of arrays. With arrays of structs/objects you get row-ba
by ndh2 10y ago
No, they're not cache friendly. The problem is row-based vs column-based. Array of structs vs Structure of arrays. With arrays of structs/objects you get row-based access patterns. Especially for cases where you only want to access one or two columns, you always pull in everything else.
https://www.youtube.com/watch?v=rX0ItVEVjHc https://www.youtube.com/watch?v=rX0ItVEVjHc
- lossolo 10y agoSoA layout is of advantage when the components that you split into separate arrays are usually accessed separately which in most cases is not true. For most cases it is cache friendly (unless you use niche DoD).
- corysama 10y agoAre there any popular languages that support SOA 1st-class? C++ is largely competing with GC languages where it is difficult to avoid separated heap allocations for every tiny bit of data.
- nicwilson 10y agoWhile not 1st class, in D you can do a completely transparent library solution, because you can introspect the fields of the struct you want to be SoA and insert arrays of those fields in to the SoA'd type. Á la https://github.com/economicmodeling/soa https://github.com/economicmodeling/soa
- netheril96 10y agoAnd in what languages are structure of arrays common?
- smitherfield 10y agoIt's common to structure data as arrays in Fortran and other scientific computing. No reason you couldn't in C or C++.