
On 10/19/2016 11:59 PM, Michael Marcin wrote:
On 10/19/2016 7:32 AM, Larry Evans wrote:
Michael, the attached is an outline of how to do it. As noted in the comments, a lot of member functions still need implementation; however, the offset calculations I think are correct.
Code has been updated to implement most of the "essentials" of soa_block. You can now call begin<Index> to get the begin iterator for the Index'th vector.
The code now is on github at:
Still digesting this
You may be having trouble with digesting: soa_impl<...>::get_self soa_impl<...>::get_vec and also digesting: ~soa_impl() { using swallow = int[]; // guaranties left to right order (void)swallow{0, (void(this->template destruct<Indices>()), 0)...}; both techniques I copied from elsewhere (I can't remember where). If so, I could explain a bit. If it's something else, I'd be happy to try and explain that.
but one small tidbit I stood out for me
//The c++ standard, IIRC, says all alignments are power of 2.
I didn't actually know this was a requirement.
"Every alignment value shall be a non-negative integral power of two." ยง 3.11/4 http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/n4606.pdf
Thanks!
You're welcome. One change I made to the vec_offsets function could lead to a problem in some very special application. You might think that you could, instead of: , my_storage(new char[my_offsets.back()]) in the soa_block CTOR initialization list, you wanted to create a vector of vectors, or matrx, of soa's. Then you might think you could: soa_impl(std::size_t a_row_size, std::size_t a_col_size) : my_row_size(a_row_size) , my_col_size(a_col_size) , my_offsets(vec_offsets<Ts...>(my_row_size)) , my_storage(new char[my_offsets.back()*my_col_size]) { ... } However, you couldn't because the 2nd column of the matrix *might* not have the correct alignment. That's because, I changed the vec_offsets function by replacing, in the vec_offsets function, this: result[sizeTs]=nxt_offset( result[sizeTs-1], sizes[sizeTs-1]*vec_size, max_align); with this: result[sizeTs]=result[sizeTs-1]+sizes[sizeTs-1]*vec_size; My justification for doing that was I assumed nobody would want to do that; however, who knows. Also, if I left in the original, and there was no need for it, then people reviewing the code would wonder why I put it in :( I'll try to find some comments to put in the vec_offsets function to warn people of this unlikely problem. HTH, Larry