AdamNiederer / faster

SIMD for humans
Mozilla Public License 2.0
1.56k stars 51 forks source link

Make the striding iterator clonable #34

Closed vorner closed 6 years ago

vorner commented 6 years ago

It's sometimes expensive to build them (because a Vec is allocated for it), so it makes sense to reuse them.

I discovered this when I wanted to write matrix multiplication (for arbitrary matrix sizes) ‒ I had to do a strided iterators for the columns, but they were for single use. Because the stride returns a Vec, it needs to be allocated every time, which is expensive ‒ it's cheaper to clone the iterators themselves.

Or, would it make sense derive clone for some more iterator types as well?

AdamNiederer commented 6 years ago

That makes sense; I think deriving Clone for all non-mutable iterators would be reasonable. I'll do so once I port the backend to std::simd.