Skip to content

Aggregated sort arrays

Matthieu Schaller requested to merge smaller_sort_arrays into master

This is the next step in the on-going saga to reduce the memory footprint. @nnrw56 you will also be interested.

Currently, the sort arrays are stored as an array of 13 pointers in each cell. We then allocate sort arrays when we need a sort in a given direction and assign the array to the corresponding pointer. They remain NULL if that direction is not needed. The change introduced here replaces the array of 13 pointers by a single pointer (and hence array) and allocate the 13 sort arrays as a single linear chunk. I then provide function returning the array along a given direction by returning a pointer in that unified array at the appropriate position.

The only trick is that we sometimes need to demand a new direction. In the old approach we would allocate a new array and set it in the array of 13. Now, we need to reallocate and copy the whole thing.

This allows us to replace the 13 pointers by a single pointer and a short int to keep track of what was allocated. And we do this for both the gas and star sorting arrays.

The cell structure goes down from 1184 bytes to 992 bytes. (1216 to 1024 in the MPI case, 16% gain)

Other improvements coming soon in a separate MR.

Edited by Matthieu Schaller

Merge request reports