
on Sun Dec 23 2012, Mathias Gaunard <mathias.gaunard-AT-ens-lyon.org> wrote:
On 23/12/12 13:41, Mathias Gaunard wrote:
Technical problem: for each segment, the type of the iterator needs to be the same. The code for incrementing or dereferencing the iterator is therefore the same. This gives us two solutions: - Do a branch in the dereferencing function of the iterator to load normal data and trailing data differently (at every iteration, not ok -- this approach also works with normal iterators) - Pre-emptively build the last vector of the data and copy it into the iterator (which implies unnecessary loads, stores and cache misses and makes the iterator expensive to copy), and consider that as an additional segment of contiguous memory.
The above only stands for input iterators. I forgot mentioning output ones. The first solution still works for output iterators, but the second one clearly does not.
The only way we would have to make efficient segmented output iterators for this case would be to allow iterator of different segments to be of different types, which would require making the number of segments per level a compile-time constant.
Certainly not. You can do one runtime dispatch per top-level algorithm call, depending on segment alignment, just as the Austern paper does... and just as your approach would have to do AFAICT. -- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost