Boost logo

Boost :

Subject: Re: [boost] interest in structure of arrays container?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2016-10-28 10:09:54


On 10/26/2016 10:00 AM, Michael Marcin wrote:
[snip]
>
> The sse emitter test used an aligned_allocator to guarantee 16 byte
> alignment for the std::vector data.
>
> template< typename T >
> using sse_vector = vector<T, aligned_allocator<T,16> >;
>
I assume that vector<T>'s data is allocated with new,
and new, IIUC, guarantees maximum alignment; hence,
   boost::alignment::is_aligned(std::vector<T>::data(),16)
should always be true. What am I missing?

BTW, see the new push:

https://github.com/cppljevans/soa/commit/ea28ff814c8c1ea879fa5ac2453c12fc382ad17f

I've *not tested* it in:

   https://github.com/cppljevans/soa/blob/master/soa_compare.benchmark.cpp

but I think it should work. IOW, instead of:

     sse_vector<float> position_x;
     sse_vector<float> position_y;
     sse_vector<float> position_z;
     sse_vector<float> velocity_x;
     sse_vector<float> velocity_y;
     sse_vector<float> velocity_z;
     sse_vector<float> acceleration_x;
     sse_vector<float> acceleration_y;
     sse_vector<float> acceleration_z;
     vector<float2> size;
     vector<float4> color;
     sse_vector<float> energy;
     vector<char> alive;

I think you could use:

       soa_block
       <
         type_align<float,16>,// position_x;
         type_align<float,16>,// position_y;
         type_align<float,16>,// position_z;
         type_align<float,16>,// velocity_x;
         type_align<float,16>,// velocity_y;
         type_align<float,16>,// velocity_z;
         type_align<float,16>,// acceleration_x;
         type_align<float,16>,// acceleration_y;
         type_align<float,16>,// acceleration_z;
         float2_t,// size;
         float4_t,// color;
         type_align<float,16>,// energy;
         char// alive;
> particles;

where type_align is found here:

https://github.com/cppljevans/soa/blob/master/vec_offsets.hpp#L14

HTH.

-regards,
Larry.


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