Skip to content
Snippets Groups Projects

Replace tuple-style cast with pointer/stride access

Merged 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

Approval is optional

Merged by Slattery, StuartSlattery, Stuart 7 years ago (Mar 9, 2018 7:25pm UTC)

Merge details

  • Changes merged into master with 0faac5b6.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading