3 ms·
Is there an optimal solution to that for all sizes of the arrays? E.g. I’d expect for small/medium then re-writing as a fold over the input arrays would be fas
by CraigJPerry 4y ago
Is there an optimal solution to that for all sizes of the arrays?
E.g. I’d expect for small/medium then re-writing as a fold over the input arrays would be fastest because you’d only traverse once & everything would fit in cache.
However if the 3 arrays combined size is larger than L1 cache, I’d be strongly tempted to bet on the naïve 3 operation approach to be faster. You’d save so much time on cache line flush / reload activities.
But then if 2 arrays are larger than L3 i’d expect going back to the fold / single traversal to win again because the iterating 2 arrays at a time behaviour is no longer any different to iterating 3 at a time.
Untested hypothesis.