Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
A singleton class to manage parallel code tasks. More...
#include <quickmp.h>
Public Member Functions | |
void | setNumThreads (unsigned int numThreads=0) |
Specifies the number of threads to use in subsequent parallel for loops. More... | |
unsigned int | getNumThreads () const |
Returns the number of threads currently being used. More... | |
unsigned int | getMaxThreads () const |
Returns the total number of threads allocated for use in all parallel for loops. More... | |
unsigned int | getNumProcessors () const |
Returns the number of processors in the current machine at runtime. More... | |
bool | inParallel () const |
Returns true if called within a parallel for loop and false otherwise. More... | |
void | setLoopIndices (int loopFirstIndex, unsigned int numIterations, quickmp::ScheduleHint scheduleHint) |
Defines the range of the loop index. More... | |
void | setLoopIndices (int loopFirstIndex, unsigned int numIterations) |
Separate version which is used when no schedule hint is supplied. More... | |
void | process (ParallelTask *task) |
Unleashes the threads on the new task/loop. More... | |
void | processSubset (unsigned int threadIndex) |
Called by individual threads to process a subset of the loop iterations. More... | |
void | criticalSectionBegin (unsigned int id) |
Defines the beginning of a critical section used for synchronization. More... | |
void | criticalSectionEnd (unsigned int id) |
Defines the end of a critical section used for synchronization. More... | |
void | barrier () |
Defines a barrier routine used to synchronize threads. More... | |
PlatformThreadObjects * | getPlatformThreadObjects () |
Provides access to the internal platform-specific data, like thread handles and synchronization objects. More... | |
bool | shouldWorkerThreadsExit () const |
Returns true if the main thread has requested the worker threads to exit. More... | |
Static Public Member Functions | |
static ParallelTaskManager & | instance () |
Provides access to the singleton instance. More... | |
A singleton class to manage parallel code tasks.
This enables automatic init on first use and destroy on exit.
|
inline |
Defines a barrier routine used to synchronize threads.
Each thread blocks at the barrier until all threads have reached it.
|
inline |
Defines the beginning of a critical section used for synchronization.
This is necessary to protect shared variables which are read and written by multiple threads. The given id should be unique for each critical section within a parallel for loop. Keep the ids low to avoid allocating too many internal critical sections.
|
inline |
Defines the end of a critical section used for synchronization.
The given id must match the id given at the beginning of the critical section. Keep the ids low to avoid allocating too many internal critical sections.
|
inline |
Returns the total number of threads allocated for use in all parallel for loops.
|
inline |
Returns the number of processors in the current machine at runtime.
|
inline |
Returns the number of threads currently being used.
In sequential code sections this returns 1; in parallel for loops this returns the total number of threads allocated for use in parallel for loops.
|
inline |
Provides access to the internal platform-specific data, like thread handles and synchronization objects.
This gives access to these things to the thread function.
|
inline |
Returns true if called within a parallel for loop and false otherwise.
|
inlinestatic |
Provides access to the singleton instance.
|
inline |
Unleashes the threads on the new task/loop.
|
inline |
Called by individual threads to process a subset of the loop iterations.
|
inline |
Defines the range of the loop index.
Assumes the index begins at the first index and counts up. Internally, this sets the loop indices to be used by each thread.
|
inline |
Separate version which is used when no schedule hint is supplied.
|
inline |
Specifies the number of threads to use in subsequent parallel for loops.
If not called explicitly by the user, this will be called with the default value (zero), which uses one thread per processor. Can be called multiple times.
|
inline |
Returns true if the main thread has requested the worker threads to exit.