Skip to content

Replace tuple-style cast with pointer/stride access

Slattery, Stuart requested to merge (removed):member_pointers into master

It was noted in #1 (closed) that the get operator will not fully vectorize due to the tuple-style cast hidden in getStructMember. The pointers upfront are now cached in attempts to alleviate this. This changes the manner of data access in the AoSoA for arrays:

return getStructMember<I>(_raw_data[idx.s()]);

to:

return static_cast<struct_member_array_type<I> >( data<I>() + idx.s() * _strides[I] );

If this allows vectorization, then it may be well worth the extra arithmetic needed to index into the data block. Furthermore, if loop-invariant hoisting were done well by the compiler, idx.s() * _strides[I] would be hoisted above the inner loop over arrays as a further optimization.

Cacheing pointers and strides also had a nice side effect for future C interfaces - template-free pointer and stride access! A user can now get strides and (un-typed void*) pointers directly through the following interface:

size_t PosX = 0;
double* pos_x = (double*) aosoa.pointer(PosX);
size_t pos_x_stride = aosoa.stride(PosX);
Edited by Slattery, Stuart

Merge request reports

Loading