[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
Option base class for parallel algorithms. More...
#include <vigra/threadpool.hxx>
Public Types | |
| enum | { Auto = -1 , Nice = -2 , NoThreads = 0 } |
Public Member Functions | |
| int | getActualNumThreads () const |
| Get desired number of threads. | |
| int | getNumThreads () const |
| Get desired number of threads. | |
| ParallelOptions & | numThreads (const int n) |
| Set the number of threads or one of the constants Auto, Nice and NoThreads. | |
Option base class for parallel algorithms.
#include <vigra/threadpool.hxx>
Namespace: vigra
| anonymous enum |
Constants for special settings.
| Enumerator | |
|---|---|
| Auto | Determine number of threads automatically (from threading::thread::hardware_concurrency()). |
| Nice | Use half as many threads as Auto would. |
| NoThreads | Switch off multi-threading (i.e. execute tasks sequentially). |
| int getNumThreads | ( | ) | const |
Get desired number of threads.
Note: This function may return 0, which means that multi-threading shall be switched off entirely. If an algorithm receives this value, it should revert to a sequential implementation. In contrast, if numThread() == 1, the parallel algorithm version shall be executed with a single thread.
| int getActualNumThreads | ( | ) | const |
Get desired number of threads.
In contrast to numThread(), this will always return a value >=1.
| ParallelOptions & numThreads | ( | const int | n | ) |
Set the number of threads or one of the constants Auto, Nice and NoThreads.
Default: ParallelOptions::Auto (use system default)
This setting is ignored if the preprocessor flag VIGRA_SINGLE_THREADED is defined. Then, the number of threads is set to 0 and all tasks revert to sequential algorithm implementations. The same can be achieved at runtime by passing n = 0 to this function. In contrast, passing n = 1 causes the parallel algorithm versions to be executed with a single thread. Both possibilities are mainly useful for debugging.
|
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |