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

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 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...
 
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 trasnformation 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 &&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_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 comming from another context that uses mpmc_queues as communication channels. More...
 

Detailed Description

Native parallel execution policy. This policy uses ISO C++ threads as implementation building block allowing usage in any ISO C++ compliant platform.

Constructor & Destructor Documentation

grppi::parallel_execution_native::parallel_execution_native ( )
inlinenoexcept

Default construct a native parallel execution policy.

Creates a parallel execution native object.

The concurrency degree is determined by the platform.

Note
The concurrency degree is fixed to 2 times the hardware concurrency degree.
grppi::parallel_execution_native::parallel_execution_native ( int  concurrency_degree,
bool  ordering = true 
)
inlinenoexcept

Constructs a native parallel execution policy.

Creates a parallel execution native object selecting the concurrency degree and ordering mode.

Parameters
concurrency_degreeNumber of threads used for parallel algorithms.
orderWhether ordered executions is enabled or disabled.
grppi::parallel_execution_native::parallel_execution_native ( const parallel_execution_native ex)
inline

Member Function Documentation

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

Get number of grppi trheads.

void grppi::parallel_execution_native::disable_ordering ( )
inlinenoexcept

Disable ordering.

template<typename Input , typename Divider , typename Solver , typename Combiner >
auto grppi::parallel_execution_native::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_native::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_native::enable_ordering ( )
inlinenoexcept

Enable ordering.

template<typename T , typename... Transformers>
mpmc_queue<T>& grppi::parallel_execution_native::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_native::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_native::get_thread_id ( ) const
inlinenoexcept

Get index of current thread in the thread table.

Precondition
The current thread is currently registered.
bool grppi::parallel_execution_native::is_ordered ( ) const
inlinenoexcept

Is execution ordered.

template<typename T >
mpmc_queue<T> grppi::parallel_execution_native::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 Parameters
TElement type for the queue.
template<typename... InputIterators, typename OutputIterator , typename Transformer >
void grppi::parallel_execution_native::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 by chunks according to concurrency degree.

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_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.

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_native::pipeline ( Generator &&  generate_op,
Transformers &&...  transform_ops 
) 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_native::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_native::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_native::set_concurrency_degree ( int  degree)
inlinenoexcept

Set number of grppi threads.

void grppi::parallel_execution_native::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_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.

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.
native_thread_manager grppi::parallel_execution_native::thread_manager ( ) const
inline

Get a manager object for registration/deregistration in the thread index table for current thread.


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