GrPPI  0.3.1
Generic and Reusable Parallel Pattern Interface
Public Member Functions | List of all members
grppi::parallel_execution_omp Class Reference

OpenMP parallel execution policy. More...

#include <parallel_execution_omp.h>

Public Member Functions

 parallel_execution_omp () noexcept
 Default construct an OpenMP parallel execution policy. More...
 
 parallel_execution_omp (int concurrency_degree, bool order=true) noexcept
 Set num_threads to _threads in order to run in parallel. More...
 
void set_concurrency_degree (int degree) noexcept
 Set number of grppi threads. More...
 
int concurrency_degree () const noexcept
 Get number of grppi trheads. More...
 
void enable_ordering () noexcept
 Enable ordering. More...
 
void disable_ordering () noexcept
 Disable ordering. More...
 
bool is_ordered () const noexcept
 Is execution ordered. 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. 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...
 
int get_thread_id () const noexcept
 Get index of current thread in the thread table. 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 trasnformation to multiple sequences leaving the result in another sequence using available OpenMP parallelism. 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 &&divide_op, Solver &&solve_op, Combiner &&combine_op) const
 Invoke Divide/conquer pattern. More...
 
template<typename Input , typename Divider , typename Predicate , typename Solver , typename Combiner >
auto divide_conquer (Input &&input, Divider &&divide_op, Predicate &&predicate_op, Solver &&solve_op, Combiner &&combine_op) const
 Invoke Divide/conquer pattern. More...
 
template<typename Generator , typename... Transformers>
void pipeline (Generator &&generate_op, Transformers &&...transform_op) 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 comming from another context that uses mpmc_queues as communication channels. More...
 

Detailed Description

OpenMP parallel execution policy.

This policy uses OpenMP as implementation back-end.

Constructor & Destructor Documentation

grppi::parallel_execution_omp::parallel_execution_omp ( )
inlinenoexcept

Default construct an OpenMP parallel execution policy.

Creates an OpenMP parallel execution object.

The concurrency degree is determined by the platform according to OpenMP rules.

grppi::parallel_execution_omp::parallel_execution_omp ( int  concurrency_degree,
bool  order = true 
)
inlinenoexcept

Set num_threads to _threads in order to run in parallel.

Parameters
_threadsnumber of threads used in the parallel mode Constructs an OpenMP parallel execution policy.

Creates an OpenMP parallel execution object selecting the concurrency degree and ordering.

Parameters
concurrency_degreeNumber of threads used for parallel algorithms.
orderWhether ordered executions is enabled or disabled.

Member Function Documentation

int grppi::parallel_execution_omp::concurrency_degree ( ) const
inlinenoexcept

Get number of grppi trheads.

void grppi::parallel_execution_omp::disable_ordering ( )
inlinenoexcept

Disable ordering.

template<typename Input , typename Divider , typename Solver , typename Combiner >
auto grppi::parallel_execution_omp::divide_conquer ( Input &&  input,
Divider &&  divide_op,
Solver &&  solve_op,
Combiner &&  combine_op 
) const

Invoke Divide/conquer pattern.

Template Parameters
InputType used for the input problem.
DividerCallable type for the divider operation.
SolverCallable type for the solver operation.
CombinerCallable type for the combiner operation.
Parameters
exSequential execution policy object.
inputInput problem to be solved.
divider_opDivider operation.
solver_opSolver operation.
combine_opCombiner operation.
template<typename Input , typename Divider , typename Predicate , typename Solver , typename Combiner >
auto grppi::parallel_execution_omp::divide_conquer ( Input &&  input,
Divider &&  divide_op,
Predicate &&  predicate_op,
Solver &&  solve_op,
Combiner &&  combine_op 
) const

Invoke Divide/conquer pattern.

Template Parameters
InputType used for the input problem.
DividerCallable type for the divider operation.
PredicateCallable type for the stop condition predicate.
SolverCallable type for the solver operation.
CombinerCallable type for the combiner operation.
Parameters
exSequential execution policy object.
inputInput problem to be solved.
divider_opDivider operation.
predicate_opPredicate operation.
solver_opSolver operation.
combine_opCombiner operation.
void grppi::parallel_execution_omp::enable_ordering ( )
inlinenoexcept

Enable ordering.

template<typename T , typename... Transformers>
mpmc_queue<T>& grppi::parallel_execution_omp::get_output_queue ( mpmc_queue< T > &  queue,
Transformers &&  ... 
) const
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.

Template Parameters
TElement type for the queue.
TransformersList of the next transformers.
Parameters
queueReference of a queue of type T
template<typename T , typename... Transformers>
mpmc_queue<T> grppi::parallel_execution_omp::get_output_queue ( Transformers &&  ...) const
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.

Template Parameters
TElement type for the queue.
TransformersList of the next transformers.
int grppi::parallel_execution_omp::get_thread_id ( ) const
inlinenoexcept

Get index of current thread in the thread table.

bool grppi::parallel_execution_omp::is_ordered ( ) const
inlinenoexcept

Is execution ordered.

template<typename T >
mpmc_queue<T> grppi::parallel_execution_omp::make_queue ( ) const
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.

template<typename... InputIterators, typename OutputIterator , typename Transformer >
void grppi::parallel_execution_omp::map ( std::tuple< InputIterators... >  firsts,
OutputIterator  first_out,
std::size_t  sequence_size,
Transformer  transform_op 
) const

Applies a trasnformation to multiple sequences leaving the result in another sequence using available OpenMP parallelism.

Template Parameters
InputIteratorsIterator types for input sequences.
OutputIteratorIterator type for the output sequence.
TransformerCallable object type for the transformation.
Parameters
firstsTuple of iterators to input sequences.
first_outIterator to the output sequence.
sequence_sizeSize of the input sequences.
transform_opTransformation callable object.
Precondition
For every I iterators in the range [get<I>(firsts), next(get<I>(firsts),sequence_size)) are valid.
Iterators in the range [first_out, next(first_out,sequence_size)] are valid.
template<typename... InputIterators, typename Identity , typename Transformer , typename Combiner >
auto grppi::parallel_execution_omp::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.

Template Parameters
InputIteratorIterator type for the input sequence.
IdentityType for the identity value.
TransformerCallable object type for the transformation.
CombinerCallable object type for the combination.
Parameters
firstIterator to the first element of the sequence.
sequence_sizeSize of the input sequence.
identityIdentity value for the reduction.
transform_opTransformation callable object.
combine_opCombination callable object.
Precondition
Iterators in the range [first,last) are valid.
Returns
The map/reduce result.
template<typename Generator , typename... Transformers>
void grppi::parallel_execution_omp::pipeline ( Generator &&  generate_op,
Transformers &&...  transform_op 
) const

Invoke Pipeline pattern.

Template Parameters
GeneratorCallable type for the generator operation.
TransformersCallable types for the transformers in the pipeline.
Parameters
generate_opGenerator operation.
transform_opsTransformer operations.
template<typename InputType , typename Transformer , typename OutputType >
void grppi::parallel_execution_omp::pipeline ( mpmc_queue< InputType > &  input_queue,
Transformer &&  transform_op,
mpmc_queue< OutputType > &  output_queue 
) const
inline

Invoke Pipeline pattern comming from another context that uses mpmc_queues as communication channels.

Template Parameters
InputTypeType of the input stream.
TransformersCallable types for the transformers in the pipeline.
InputTypeType of the output stream.
Parameters
input_queueInput stream communicator.
transform_opsTransformer operations.
output_queueInput stream communicator.
template<typename InputIterator , typename Identity , typename Combiner >
auto grppi::parallel_execution_omp::reduce ( InputIterator  first,
std::size_t  sequence_size,
Identity &&  identity,
Combiner &&  combine_op 
) const

Applies a reduction to a sequence of data items.

Template Parameters
InputIteratorIterator type for the input sequence.
IdentityType for the identity value.
CombinerCallable object type for the combination.
Parameters
firstIterator to the first element of the sequence.
sequence_sizeSize of the input sequence.
identityIdentity value for the reduction.
combine_opCombination callable object.
Precondition
Iterators in the range [first,last) are valid.
Returns
The reduction result
void grppi::parallel_execution_omp::set_concurrency_degree ( int  degree)
inlinenoexcept

Set number of grppi threads.

void grppi::parallel_execution_omp::set_queue_attributes ( int  size,
queue_mode  mode 
)
inlinenoexcept

Sets the attributes for the queues built through make_queue<T>(()

template<typename... InputIterators, typename OutputIterator , typename StencilTransformer , typename Neighbourhood >
void grppi::parallel_execution_omp::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.

Template Parameters
InputIteratorsIterator types for input sequences.
OutputIteratorIterator type for the output sequence.
StencilTransformerCallable object type for the stencil transformation.
NeighbourhoodCallable object for generating neighbourhoods.
Parameters
firstsTuple of iterators to input sequences.
first_outIterator to the output sequence.
sequence_sizeSize of the input sequences.
transform_opStencil transformation callable object.
neighbour_opNeighbourhood callable object.
Precondition
For every I iterators in the range [get<I>(firsts), next(get<I>(firsts),sequence_size)) are valid.
Iterators in the range [first_out, next(first_out,sequence_size)] are valid.

The documentation for this class was generated from the following file: