Use shared mem prefix scan in reshuffling. Memorize the data.