I know this is weird to ask here but well i know you are all devs (well mostly devs) so whats scatter/gather exactly ? And what its used for ?
I heard it the first time today when debugging AMDGPU. I newer heard it in 9 years of programming. So i suppose its not so known.

  • 8
    Scatter/gather is when you use one operation to shovel data into multiple buffers (scatter) or read data from multiple buffers (gather). It's a general pattern. Think of it as write and read operations respectively which work over multiple buffers instead of a single one.

    Eg. In MPI (a framework for writing parallel programs as cooperating processes) a scatter operation takes an array of data and send different chunks of that array to different MPI processes, all in one procedure call. Similarly, a gather operation fills an array with different bits of data from different MPI processes.
  • 6
    @Haxk20 You'll see this come up when you're doing parallel or vector programming.

    As an example imagine you have a hypothetical processor with N processing cores, each with one input register and one output register. Suppose you want to compute the sum of squares of elements of an array. Instead of sending data one by one to registers, such a processor would generally have scatter/gather functionality.

    So you have an input array of numbers. You'll scatter that array to the input registers of said cores so that each input register now holds one number from the array. Then all the cores compute squares in parallel and put that value in their output registers. Then you gather all the output registers to some other array and sum them.

    The advantage is that scatter/gather can be implemented to be more efficient than individual read/write to each buffer and it is a useful primitive for parallel/vector algorithms.
  • 2
    @rememberme really cool indeed but CPU has to have functionality to do that because if not then it wouldnt work right ?
  • 4
    oh wait as you said i could just use more cores to do it. really cool indeed.
  • 2
    @RememberMe thanks a lot for answering that.

    @Haxk20 and thanks for asking and debugging amdgpu : )
Add Comment