Function uw12::parallel::parallel_for

Function Documentation

inline void uw12::parallel::parallel_for(size_t start, size_t stop, const std::function<void(size_t)> &func, bool parallel = true)

Run a for loop in parallel

Calls a function which takes an integer as argument and calls it for each integer between start and stop (exclusive).

Useful for looping through arrays and calculating each entry in parllel. Should not be used to manipulate the same result multiple times, such as summation. If this is required, the parallel_sum function should be used instead.

Parameters
  • start – Initial integer value

  • stop – Final integer value (exclusive)

  • func – Function to call

  • parallel – Whether to run in parallel