class Pool

Define a pool of threads, each with their own MonteCarlo object and relevant quantities for reversion.

class Prefetch : public feasst::MonteCarlo

Farm a trial to each processor, then reconstruct the serial Markov chain.

Although its quite a simple strategy, the trickiest part is efficiently reproducing the accepted perturbation on all threads (e.g., the synchronizing step) in a way that’s general to all MC trials (and potential functions/ optimizations). This can get really complicated by cell lists, neighbor lists and k-space. For the synchronize step, I’ve used two different strategies, sometimes both at the same time, which span the range of ease of implementation vs efficiency.

  1. Cache every random number and energy term generated during the trial, and if that trial is the accepted one, revert the others, then feed those cached RNG/energies back to the other threads to reproduce the same perturbations. There are some issues with FEASST here because the energy calcs are also part of the neighbor/cell/kvector updates. Also, this means going through each config bias step, etc, so its not the most efficient synchronization possible.

  2. A more efficient synchronization method is to give objects a synchronize method which takes as input a reference to the base class its trying to copy and the list of particles/sites that were changed in the trial. For example, in Ewald, VisitModel is the base class of Ewald, and Select has the list of particles/sites that were perturbed. The base class also needs a data structure (SynchronizeData) that all the derived classes use. In the most complex cases, the data is separated between ones that are automatically copied every time, or ones manually choosen based on which sites were perturbed.

Prefetch is not used for the until_num_particles argument in Run.

Public Functions

Prefetch(argtype args = argtype())


  • trials_per_check: number of steps between check (default: 1e6)

  • load_balance: batches contain all of the same trial type (default: false). This violates detailed balance, and is known in cases of high acceptance to give erroneous results. Only use load_balance for equilibration and never for production simulations.

  • synchronize: synchronize data with accepted thread (default: false).

  • ghost: update transition matrix even for trials after acceptance (default: false).

int trials_per_check() const

Return the number of steps between checking equality of threads.

void activate_prefetch(const bool active = true)

Activate prefetch.

void reset_trial_stats()

Reset stats of trials of all threads.

void run(std::shared_ptr<Action> action)

Perform an Action on all processors.

void run_num_trials(int num_trials)

Run a number of trials.

void run_until_num_particles(const int num_particles, const int particle_type, const int configuration_index)

Run until a number of particles is reached.

void run_until_file_exists(const std::string &file_name)

Attempt Monte Carlo trials until the given file name exists.