On 10/18/2016 11:00 AM, Joaquin M López Muñoz wrote:
I played with these concepts some months ago and came up with some sketches:
http://bannalia.blogspot.com/2015/08/c-encapsulation-for-data-oriented-desig...
http://bannalia.blogspot.com/2015/09/c-encapsulation-for-data-oriented.html http://bannalia.blogspot.com/2015/11/soa-container-for-encapsulated-c-dod.ht...
( http://tinyurl.com/qb7gmbk http://tinyurl.com/nhhz9l8 http://tinyurl.com/zmdsqyf )
The key idea of this approach is to decouple user's code from actual access to the data making the former templatized on an Access policy, which can then be changed from AOS to SOA and back without further modifications. The sketch also includes a SOA container along this line. With a little more work it is possible to have not only "pure" AOS and SOA but also mixed layouts where some data members are given their own cache line while others are grouped together etc. Switching from one to other quckly would allow for easy profiling and tuning for the specific access profiles of a given application.
Of course eveything above was a mere experiment very far away from production-ready code, but maybe someone can take advantage of the ideas to write something more robust.
How wonderful that you also chose to a particle system as your example. Very enjoyable articles, thanks! Your dod::access and dod::pointer types looks to be quite similar to what I call a view and view_iterator respectively. I need to study your examples more. I saw https://github.com/gnzlbg/scattered in the comments, which also looks interesting.