GrPPI
1.0
Generic and Reusable Parallel Pattern Interface
|
Native parallel execution policy. This policy uses ISO C++ threads as implementation building block allowing usage in any ISO C++ compliant platform. More...
#include <parallel_execution_native.h>
Public Member Functions | |
parallel_execution_native () noexcept | |
Default construct a native parallel execution policy. More... | |
parallel_execution_native (int concurrency_degree, bool ordering=true) noexcept | |
Constructs a native parallel execution policy. More... | |
parallel_execution_native (const parallel_execution_native &ex) | |
void | set_concurrency_degree (int degree) noexcept |
Set number of grppi threads. More... | |
int | concurrency_degree () const noexcept |
Get number of grppi threads. More... | |
void | enable_ordering () noexcept |
Enable ordering. More... | |
void | disable_ordering () noexcept |
Disable ordering. More... | |
bool | is_ordered () const noexcept |
Is execution ordered. More... | |
native_thread_manager | thread_manager () const |
Get a manager object for registration/deregistration in the thread index table for current thread. More... | |
int | get_thread_id () const noexcept |
Get index of current thread in the thread table. More... | |
void | set_queue_attributes (int size, queue_mode mode) noexcept |
Sets the attributes for the queues built through make_queue<T>() More... | |
template<typename T > | |
mpmc_queue< T > | make_queue () const |
Makes a communication queue for elements of type T. Constructs a queue using the attributes that can be set via set_queue_attributes(). The value is returned via move semantics. More... | |
template<typename T , typename ... Transformers> | |
mpmc_queue< T > & | get_output_queue (mpmc_queue< T > &queue, Transformers &&...) const |
Returns the reference of a communication queue for elements of type T if the queue has been created in an outer pattern. Returns the reference of the queue received as argument. More... | |
template<typename T , typename ... Transformers> | |
mpmc_queue< T > | get_output_queue (Transformers &&...) const |
Makes a communication queue for elements of type T if the queue has not been created in an outer pattern. Call to the make_queue function and the value is returned via move semantics. More... | |
template<typename ... InputIterators, typename OutputIterator , typename Transformer > | |
void | map (std::tuple< InputIterators... > firsts, OutputIterator first_out, std::size_t sequence_size, Transformer transform_op) const |
Applies a transformation to multiple sequences leaving the result in another sequence by chunks according to concurrency degree. More... | |
template<typename InputIterator , typename Identity , typename Combiner > | |
auto | reduce (InputIterator first, std::size_t sequence_size, Identity &&identity, Combiner &&combine_op) const |
Applies a reduction to a sequence of data items. More... | |
template<typename ... InputIterators, typename Identity , typename Transformer , typename Combiner > | |
auto | map_reduce (std::tuple< InputIterators... > firsts, std::size_t sequence_size, Identity &&identity, Transformer &&transform_op, Combiner &&combine_op) const |
Applies a map/reduce operation to a sequence of data items. More... | |
template<typename ... InputIterators, typename OutputIterator , typename StencilTransformer , typename Neighbourhood > | |
void | stencil (std::tuple< InputIterators... > firsts, OutputIterator first_out, std::size_t sequence_size, StencilTransformer &&transform_op, Neighbourhood &&neighbour_op) const |
Applies a stencil to multiple sequences leaving the result in another sequence. More... | |
template<typename Input , typename Divider , typename Solver , typename Combiner > | |
auto | divide_conquer (Input &&input, Divider &÷_op, Solver &&solve_op, Combiner &&combine_op) const |
Invoke md_divide-conquer. More... | |
template<typename Input , typename Divider , typename Predicate , typename Solver , typename Combiner > | |
auto | divide_conquer (Input &&input, Divider &÷_op, Predicate &&predicate_op, Solver &&solve_op, Combiner &&combine_op) const |
Invoke md_divide-conquer. More... | |
template<typename Generator , typename ... Transformers> | |
void | pipeline (Generator &&generate_op, Transformers &&... transform_ops) const |
Invoke Pipeline pattern. More... | |
template<typename InputType , typename Transformer , typename OutputType > | |
void | pipeline (mpmc_queue< InputType > &input_queue, Transformer &&transform_op, mpmc_queue< OutputType > &output_queue) const |
Invoke Pipeline pattern coming from another context that uses mpmc_queues as communication channels. More... | |
template<typename Queue , typename Transformer , typename Predicate , template< typename T, typename P > class Iteration, typename ... OtherTransformers, requires_iteration< Iteration< Transformer, Predicate >> , requires_pipeline< Transformer > > | |
void | do_pipeline (Queue &, Iteration< Transformer, Predicate > &&, OtherTransformers &&...) const |
template<typename T , typename... Others> | |
void | do_pipeline (mpmc_queue< T > &, mpmc_queue< T > &, Others &&...) const |
Native parallel execution policy. This policy uses ISO C++ threads as implementation building block allowing usage in any ISO C++ compliant platform.
|
inlinenoexcept |
Default construct a native parallel execution policy.
Creates a parallel execution native object.
The concurrency degree is determined by the platform.
|
inlinenoexcept |
Constructs a native parallel execution policy.
Creates a parallel execution native object selecting the concurrency degree and ordering mode.
concurrency_degree | Number of threads used for parallel algorithms. |
order | Whether ordered executions is enabled or disabled. |
|
inline |
|
inlinenoexcept |
Get number of grppi threads.
|
inlinenoexcept |
Disable ordering.
auto grppi::parallel_execution_native::divide_conquer | ( | Input && | input, |
Divider && | divide_op, | ||
Predicate && | predicate_op, | ||
Solver && | solve_op, | ||
Combiner && | combine_op | ||
) | const |
Invoke md_divide-conquer.
Input | Type used for the input problem. |
Divider | Callable type for the divider operation. |
Predicate | Callable type for the stop condition predicate. |
Solver | Callable type for the solver operation. |
Combiner | Callable type for the combiner operation. |
ex | Sequential execution policy object. |
input | Input problem to be solved. |
divider_op | Divider operation. |
predicate_op | Predicate operation. |
solver_op | Solver operation. |
combine_op | Combiner operation. |
auto grppi::parallel_execution_native::divide_conquer | ( | Input && | input, |
Divider && | divide_op, | ||
Solver && | solve_op, | ||
Combiner && | combine_op | ||
) | const |
Invoke md_divide-conquer.
Input | Type used for the input problem. |
Divider | Callable type for the divider operation. |
Solver | Callable type for the solver operation. |
Combiner | Callable type for the combiner operation. |
ex | Sequential execution policy object. |
input | Input problem to be solved. |
divider_op | Divider operation. |
solver_op | Solver operation. |
combine_op | Combiner operation. |
void grppi::parallel_execution_native::do_pipeline | ( | mpmc_queue< T > & | , |
mpmc_queue< T > & | , | ||
Others && | ... | ||
) | const |
void grppi::parallel_execution_native::do_pipeline | ( | Queue & | , |
Iteration< Transformer, Predicate > && | , | ||
OtherTransformers && | ... | ||
) | const |
|
inlinenoexcept |
Enable ordering.
|
inline |
Returns the reference of a communication queue for elements of type T if the queue has been created in an outer pattern. Returns the reference of the queue received as argument.
T | Element type for the queue. |
Transformers | List of the next transformers. |
queue | Reference of a queue of type T |
|
inline |
Makes a communication queue for elements of type T if the queue has not been created in an outer pattern. Call to the make_queue function and the value is returned via move semantics.
T | Element type for the queue. |
Transformers | List of the next transformers. |
|
inlinenoexcept |
Get index of current thread in the thread table.
|
inlinenoexcept |
Is execution ordered.
|
inline |
Makes a communication queue for elements of type T. Constructs a queue using the attributes that can be set via set_queue_attributes(). The value is returned via move semantics.
T | Element type for the queue. |
void grppi::parallel_execution_native::map | ( | std::tuple< InputIterators... > | firsts, |
OutputIterator | first_out, | ||
std::size_t | sequence_size, | ||
Transformer | transform_op | ||
) | const |
Applies a transformation to multiple sequences leaving the result in another sequence by chunks according to concurrency degree.
InputIterators | Iterator types for input sequences. |
OutputIterator | Iterator type for the output sequence. |
Transformer | Callable object type for the transformation. |
firsts | Tuple of iterators to input sequences. |
first_out | Iterator to the output sequence. |
sequence_size | Size of the input sequences. |
transform_op | Transformation callable object. |
[get<I>(firsts), next(get<I>(firsts),sequence_size))
are valid. [first_out, next(first_out,sequence_size)]
are valid. auto grppi::parallel_execution_native::map_reduce | ( | std::tuple< InputIterators... > | firsts, |
std::size_t | sequence_size, | ||
Identity && | identity, | ||
Transformer && | transform_op, | ||
Combiner && | combine_op | ||
) | const |
Applies a map/reduce operation to a sequence of data items.
InputIterator | Iterator type for the input sequence. |
Identity | Type for the identity value. |
Transformer | Callable object type for the transformation. |
Combiner | Callable object type for the combination. |
first | Iterator to the first element of the sequence. |
sequence_size | Size of the input sequence. |
identity | Identity value for the reduction. |
transform_op | Transformation callable object. |
combine_op | Combination callable object. |
[first,last)
are valid. void grppi::parallel_execution_native::pipeline | ( | Generator && | generate_op, |
Transformers &&... | transform_ops | ||
) | const |
Invoke Pipeline pattern.
Generator | Callable type for the generator operation. |
Transformers | Callable types for the transformers in the pipeline. |
generate_op | Generator operation. |
transform_ops | Transformer operations. |
|
inline |
Invoke Pipeline pattern coming from another context that uses mpmc_queues as communication channels.
InputType | Type of the input stream. |
Transformers | Callable types for the transformers in the pipeline. |
InputType | Type of the output stream. |
input_queue | Input stream communicator. |
transform_ops | Transformer operations. |
output_queue | Input stream communicator. |
auto grppi::parallel_execution_native::reduce | ( | InputIterator | first, |
std::size_t | sequence_size, | ||
Identity && | identity, | ||
Combiner && | combine_op | ||
) | const |
Applies a reduction to a sequence of data items.
InputIterator | Iterator type for the input sequence. |
Identity | Type for the identity value. |
Combiner | Callable object type for the combination. |
first | Iterator to the first element of the sequence. |
sequence_size | Size of the input sequence. |
identity | Identity value for the reduction. |
combine_op | Combination callable object. |
[first,last)
are valid.
|
inlinenoexcept |
Set number of grppi threads.
|
inlinenoexcept |
Sets the attributes for the queues built through make_queue<T>()
void grppi::parallel_execution_native::stencil | ( | std::tuple< InputIterators... > | firsts, |
OutputIterator | first_out, | ||
std::size_t | sequence_size, | ||
StencilTransformer && | transform_op, | ||
Neighbourhood && | neighbour_op | ||
) | const |
Applies a stencil to multiple sequences leaving the result in another sequence.
InputIterators | Iterator types for input sequences. |
OutputIterator | Iterator type for the output sequence. |
StencilTransformer | Callable object type for the stencil transformation. |
Neighbourhood | Callable object for generating neighbourhoods. |
firsts | Tuple of iterators to input sequences. |
first_out | Iterator to the output sequence. |
sequence_size | Size of the input sequences. |
transform_op | Stencil transformation callable object. |
neighbour_op | Neighbourhood callable object. |
[get<I>(firsts), next(get<I>(firsts),sequence_size))
are valid. [first_out, next(first_out,sequence_size)]
are valid.
|
inline |
Get a manager object for registration/deregistration in the thread index table for current thread.