Parallel map.
Parallel map class.
A function is applied to all elements of a std::vector in parallel with n worker threads. The worker threads are persistent until the destruction of the parmap.
If there are more than n elements in the vector, the worker threads are allowed to fetch themselves remaining work with method next() and execute it.
◆ e_xbt_parmap_mode_t
Synchronization mode of the worker threads of a parmap.
Enumerator |
---|
XBT_PARMAP_POSIX | use POSIX synchronization primitives
|
XBT_PARMAP_FUTEX | use Linux futex system call
|
XBT_PARMAP_BUSY_WAIT | busy waits (no system calls, maximum CPU usage)
|
XBT_PARMAP_DEFAULT | futex if available, posix otherwise
|
◆ Parmap()
Creates a parallel map object.
- Parameters
-
num_workers | number of worker threads to create |
mode | how to synchronize the worker threads |
◆ ~Parmap()
◆ apply()
Applies a list of tasks in parallel.
- Parameters
-
fun | the function to call in parallel |
data | each element of this vector will be passed as an argument to fun |
◆ next()
Returns a next task to process.
Worker threads call this function to get more work.
- Returns
- the next task to process, or throws a std::out_of_range exception if there is no more work
◆ PosixSynchro()
◆ ~PosixSynchro()
◆ master_signal() [1/2]
◆ master_wait() [1/2]
◆ worker_signal() [1/2]
◆ worker_wait() [1/2]
◆ master_signal() [2/2]
◆ master_wait() [2/2]
◆ worker_signal() [2/2]
◆ worker_wait() [2/2]