# mpcd.update¶

Overview

 sort Sorts MPCD particles in memory to improve cache coherency.

Details

MPCD particle updaters

class hoomd.mpcd.update.sort(system, period=50)

Sorts MPCD particles in memory to improve cache coherency.

Parameters: system (hoomd.mpcd.data.system) – MPCD system to create sorter for period (int) – Sort whenever the timestep is a multiple of period. .. versionadded:: 2.6

Warning

Do not create hoomd.mpcd.update.sort explicitly in your script. HOOMD creates a sorter by default.

Every period time steps, particles are reordered in memory based on the cell list generated at the current timestep. Sorting can significantly improve performance of all other cell-based steps of the MPCD algorithm. The efficiency of the sort operation obviously depends on the number of particles, and so the period should be tuned to give the maximum performance.

Note

The period should be no smaller than the MPCD collision period, or unnecessary cell list builds will occur.

Essentially all MPCD systems benefit from sorting, and so a sorter is created by default with the MPCD system. To disable it or modify parameters, save the system and access the sorter through it:

s = mpcd.init.read_snapshot(snap)
# the sorter is only available after initialization
s.sorter.set_period(period=5)
s.sorter.disable()

set_period(period)

Change the sorting period.

Parameters: period (int) – New period to set.

Examples:

sorter.set_period(100)
sorter.set_period(1)


While the simulation is running, the action of each updater is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.

tune(start, stop, step, tsteps, quiet=False)

Tune the sorting period.

Parameters: start (int) – Start of tuning interval to scan (inclusive). stop (int) – End of tuning interval to scan (inclusive). step (int) – Spacing between tuning points. tsteps (int) – Number of timesteps to run at each tuning point. quiet (bool) – Quiet the individual run calls. The optimal sorting period from the scanned range. int

The optimal sorting period for the MPCD particles is determined from a sequence of short runs. The sorting period is first set to start. The TPS value is determined for a run of length tsteps. This run is repeated 3 times, and the median TPS of the runs is saved. The sorting period is then incremented by step, and the process is repeated until stop is reached. The period giving the fastest TPS is determined, and the sorter period is updated to this value. The results of the scan are also reported as output, and the fastest sorting period is also returned.

Note

A short warmup run is required before calling tune() in order to ensure the runtime autotuners have found optimal kernel launch parameters.

Examples:

# warmup run
hoomd.run(5000)

# tune sorting period
sorter.tune(start=5, stop=50, step=5, tsteps=1000)