4 ms·
It's O(n) to gather and to scatter. So it's definitely expensive if you are doing only a single pass. But if you are doing any big o bigger than O(n) (ex: matr
by dragontamer 6y ago
It's O(n) to gather and to scatter. So it's definitely expensive if you are doing only a single pass.
But if you are doing any big o bigger than O(n) (ex: matrix multiplication, which is O(n^2.4) or so), then it's relatively cheap. Indeed, optimized matrix multiplications transpose the data to speed it up!!
There is something to be said about gather and scatter patterns as a methodology, especially as a first step into optimizing your algorithms. It's not the ultimate speed form, but relatively straightforward and simple to implement.