HPX - High Performance ParalleX

PrevUpHomeNext

Function template inclusive_scan

hpx::parallel::v1::inclusive_scan

Synopsis

// In header: <hpx/parallel/algorithms/inclusive_scan.hpp>


template<typename ExPolicy, typename InIter, typename OutIter, typename T> 
  unspecified inclusive_scan(ExPolicy && policy, InIter first, InIter last, 
                             OutIter dest, T init);

Description

Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(+, init, *first, ..., *(first + (i - result))).

[Note] Note

Complexity: O(last - first) applications of the predicate op.

The reduce operations in the parallel inclusive_scan algorithm invoked with an execution policy object of type sequential_execution_policy execute in sequential order in the calling thread.

The reduce operations in the parallel inclusive_scan algorithm invoked with an execution policy object of type parallel_execution_policy or parallel_task_execution_policy are permitted to execute in an unordered fashion in unspecified threads, and indeterminately sequenced within each thread.

[Note] Note

GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aN) is defined as:

  • a1 when N is 1

  • GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK) + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) where 1 < K+1 = M <= N.

The difference between exclusive_scan and inclusive_scan is that inclusive_scan includes the ith input element in the ith sum.

Parameters:

dest

Refers to the beginning of the destination range.

first

Refers to the beginning of the sequence of elements the algorithm will be applied to.

init

The initial value for the generalized sum.

last

Refers to the end of the sequence of elements the algorithm will be applied to.

policy

The execution policy to use for the scheduling of the iterations.

Template Parameters:

ExPolicy

The type of the execution policy to use (deduced). It describes the manner in which the execution of the algorithm may be parallelized and the manner in which it executes the assignments.

InIter

The type of the source iterators used (deduced). This iterator type must meet the requirements of an input iterator.

OutIter

The type of the iterator representing the destination range (deduced). This iterator type must meet the requirements of an output iterator.

T

The type of the value to be used as initial (and intermediate) values (deduced).

Returns:

The copy_n algorithm returns a hpx::future<OutIter> if the execution policy is of type sequential_task_execution_policy or parallel_task_execution_policy and returns OutIter otherwise. The inclusive_scan algorithm returns the output iterator to the element in the destination range, one past the last element copied.


PrevUpHomeNext