3 ms·
Is it possible to automatically convert an AoS-based algorithm to SoA? Does this require anything more than transposing some struct member accesses? IIRC, Futh
by kd0amg 9y ago
Is it possible to automatically convert an AoS-based algorithm to SoA?
Does this require anything more than transposing some struct member accesses? IIRC, Futhark already does that kind of conversion.
- jnordwick 9y agoYou could do a fairly straightforward conversion but it would be terribly slow for many things. Take the sorting example i gave. In a column-oriented program you would generate a list of indices and apply them to each column. That has very good cache locality as you work on each independently. Also you tend to manipulate that index list instead of the data and after all is done, filtered, and whatever then apply it to the data. If you did things the AoS way you would be bouncing around in memory going from column to column. Dealing with SoA and column orientated data is more than just a storage decision.
- kd0amg 9y agoYou could do a fairly straightforward conversion but it would be terribly slow for many things. Is there a non-straightforward conversion that isn't? It seems to me like any SoA->AoS transformation is going to have pretty much the same effect on locality.
- jnordwick 9y ago> It seems to me like any SoA-AoS transformation is going to have pretty much the same effect on locality Not at all. In a SoA system you want to operate on each attribute individually but on an AoS system you operates across structs. Besides improved cache locality it keeps loops small so they operate out of the iop loop/stream cache among other things like better packing off data etc. If you haven't worked on a system little this sometimes it can be difficult to see how different things can be. It's literally APL vs C.