Boost logo

Boost :

Subject: Re: [boost] tuple_vector (was poly_collection)
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2014-08-24 18:03:22


On 24/08/2014 13:29, Adam Wulkiewicz wrote:
> Ion Gaztañaga wrote:
>> An interesting addition to Boost.Container? ;-)
>
> Some time ago I tested a container which should also improve the
> cacheing, depending on the access pattern.
> The key point is to separate the hot and cold data so its purpose is
> slightly different than poly_collection but the idea is similar, to
> group the same objects together.
> The idea is to transform a vector of tuples into a tuple of vectors and
> store tuple's components in separated containers, e.g.:
>
> std::vector<std::tuple<T1, T2>> -> std::tuple<std::vector<T1>,
> std::vector<T2>>

This is AoS -> SoA conversion.
We also do that kind of thing with NT2 containers (this is necessary for
vectorization).

>
> The usage should be as close to std::vector as possible, so e.g.:
>
> |tuple_vector<std::tuple<T1, T2, T3, ...>> v;
> v.resize(count);
>
> for (int i = 0; i < count; ++i)
> {
> T1 t = std::get<0>(v[i]);
> std::get<0>(v[i]) = ...;
> }|
>
>
> A thing worth noticing is that the tuple_vector's reference type is a
> tuple of references:
>
> std::tuple<T1&, T2&>

Could also be any proxy type, that's more flexible.
The important aspect is that tuple_vector's reference cannot be value_type&.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk