Subject: Re: [boost] interest in structure of arrays container?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2016-10-18 11:29:34
On 10/14/2016 09:43 PM, Michael Marcin wrote:
> Structure of arrays is a pretty well known pattern for improving memory
> density and enabling vectorization in high performance code. Also known
> as parallel arrays.
> After hand-rolling yet another of these it occurred to me that you make
> a reasonable first implementation with a simple alias template.
> template< typename... Ts >
> using soa = std::tuple< std::vector<Ts>... >;
> soa<int,float,std::string> data;
> This is decent start but has several issues including:
> * nothing to preserve the invariant keeping the arrays the same length
> * missing coalesced interface for vector methods (size, reserve, etc)
> * no iterator
> * wasted storage for duplicated allocators, capacities, sizes
> * sizeof...(Ts) allocations could be a single large block
> The work required to address these issues is not too great I think.
The purpose of item:
* sizeof...(Ts) allocations could be a single large block
is to just require 1 heap allocation instead of N, where N
is the number of vectors in soa<T1,T2,...,TN>?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk