HyperspaceExplorer 0.7.1
|
Functions for multithreaded manipulation of data containers. More...
Namespaces | |
namespace | Private |
Implementation details for multithreading. | |
Functions | |
template<class RandomAccessContainer , typename Function > | |
RandomAccessContainer | mapped (const RandomAccessContainer &container, Function function) |
template<class RandomAccessContainer , typename Function > | |
void | partitionedMap (const RandomAccessContainer &container, RandomAccessContainer &output, Function function, unsigned tasks_per_processor=1) |
Run a function concurrently on every element of a random access container, writing every modified element of the container to another container. | |
template<class RandomAccessContainer , typename Function > | |
void | partitionedMap (RandomAccessContainer &container, Function function, unsigned tasks_per_processor=1) |
Run a function concurrently on every element of a random access container, modifying every element of the container in place. | |
template<class RandomAccessContainer , typename Function > | |
RandomAccessContainer | partitionedMapped (const RandomAccessContainer &container, Function function, unsigned tasks_per_processor=1) |
Run a function concurrently on every element of a random access container, collecting the results of each operation in another container and returning them. |
Functions for multithreaded manipulation of data containers.
The namespace Multithreading
contains functions that run concurrently on a random access container using the minimum necessary number of threads (usually the number of processors available in the system).
QThread
and QtConcurrent
, but C++11's std::thread
is also feasible). void Multithreading::partitionedMap | ( | const RandomAccessContainer & | container, |
RandomAccessContainer & | output, | ||
Function | function, | ||
unsigned | tasks_per_processor = 1 |
||
) |
Run a function concurrently on every element of a random access container, writing every modified element of the container to another container.
The number of threads started is controlled by the parameter tasks_per_processor
. The container is partitioned so that every thread works on as many elements are necessary so that tasks_per_processor
threads are started per available processor.
RandomAccessContainer | Type of the container on which the operation is run. Must support operator[]() . |
Function | Type of the operation that is run on every element of the container . Either a function with the signature T function(const T &argument)
operator()() has that signature. |
container | The container on whose elements the Function is run. |
output | The result of the operation run on container . |
function | The Function that is called on every element of container . |
tasks_per_processor | number of tasks that is started for every available processor or core. |
Referenced by partitionedMap(), and partitionedMapped().
void Multithreading::partitionedMap | ( | RandomAccessContainer & | container, |
Function | function, | ||
unsigned | tasks_per_processor = 1 |
||
) |
Run a function concurrently on every element of a random access container, modifying every element of the container in place.
The number of threads started is controlled by the parameter tasks_per_processor
. The container is partitioned so that every thread works on as many elements are necessary so that tasks_per_processor
threads are started per available processor.
RandomAccessContainer | Type of the container on which the operation is run. Must support operator[]() . |
Function | Type of the operation that is run on every element of the container . Either a function with the signature T function(const T &argument)
operator()() has that signature. |
container | The container on whose elements the Function is run. |
function | The Function that is called on every element of container . |
tasks_per_processor | number of tasks that is started for every available processor or core. |
References partitionedMap().
RandomAccessContainer Multithreading::partitionedMapped | ( | const RandomAccessContainer & | container, |
Function | function, | ||
unsigned | tasks_per_processor = 1 |
||
) |
Run a function concurrently on every element of a random access container, collecting the results of each operation in another container and returning them.
The number of threads started is controlled by the parameter tasks_per_processor
. The container is partitioned so that every thread works on as many elements are necessary so that tasks_per_processor
threads are started per available processor.
RandomAccessContainer | Type of the container on which the operation is run. Must support operator[]() . |
Function | Type of the operation that is run on every element of the container . Either a function with the signature T function(const T &argument)
operator()() has that signature. |
container | The container on whose elements the Function is run. |
function | The Function that is called on every element of container . |
tasks_per_processor | number of tasks that is started for every available processor or core. |
container
. References partitionedMap().
Referenced by MultithreadedTransformation< N, 1, NUM >::transform().