Skip to content

Algorithms Library: Partitioners

Algorithms / Partitioners

Classes

Classes Description
halve_partitioner A partitioner that always splits the problem in half.
(class)
thread_partitioner A partitioner that always splits the problem when moving to new threads.
(class)

Types

Member Types Definition
default_partitioner Default partitioner used by parallel algorithms.
(using)
is_partitioner_for Determine if P is a valid partitioner for the iterator range [I,S].
(using)

Functions

Member Functions Description
make_grain_size Determine a reasonable minimum grain size depending on the number of elements in a sequence.
(function)
make_default_partitioner Create an instance of the default partitioner with a reasonable grain size for n elements.
(function)

Attributes

Member Attributes Description
is_partitioner_for_v Determine if P is a valid partitioner for the iterator range [I,S].
(public variable template)
partitioner_for Determines if a type is an partitioner.
(public concept template)

Types

using default_partitioner

Defined in header <futures/algorithm/partitioner/default_partitioner.hpp>

using default_partitioner = /* see below */;

Default partitioner used by parallel algorithms.

Description

Its type and parameters might change

using is_partitioner_for

Defined in header <futures/algorithm/partitioner/partitioner_for.hpp>

template <class P, class I, class S = I>
using is_partitioner_for = 
    std::bool_constant< partitioner_for< P, I, S > >;

Determine if P is a valid partitioner for the iterator range [I,S].

Functions

function make_grain_size

Defined in header <futures/algorithm/partitioner/default_partitioner.hpp>

constexpr std::size_t
make_grain_size(std::size_t n);

Determine a reasonable minimum grain size depending on the number of elements in a sequence.

Parameters

  • n - Sequence size

Return value

The recommended grain size for a range of the specified size

Description

The grain size considers the number of threads available. It's never more than 2048 elements.

Exception Safety

Basic exception guarantee.

function make_default_partitioner

Defined in header <futures/algorithm/partitioner/default_partitioner.hpp>

(1)
default_partitioner
make_default_partitioner(size_t n);
(2)
template <std::input_iterator I, std::sentinel_for< I > S>
default_partitioner
make_default_partitioner(I first, S last);
(3)
template <class R>
requires is_input_range_v<R>
default_partitioner
make_default_partitioner(R && r);
  1. Create an instance of the default partitioner with a reasonable grain size for n elements.
  2. Create an instance of the default partitioner with a reasonable grain for the range first, last
  3. Create an instance of the default partitioner with a reasonable grain for the range r

Description

The default partitioner type and parameters might change

Exception Safety

Basic exception guarantee.

Attributes

variable is_partitioner_for_v

Defined in header <futures/algorithm/partitioner/partitioner_for.hpp>

constexpr bool is_partitioner_for_v = is_partitioner_for<P, I, S>::value;

Determine if P is a valid partitioner for the iterator range [I,S].

concept partitioner_for

Defined in header <futures/algorithm/partitioner/partitioner_for.hpp>

template<class P, class I, class S I>
concept partitioner_for = std::input_iterator<I> && std::sentinel_for<S, I>
                              && std::invocable<P, I, S>;

Determines if a type is an partitioner.


Updated on 2023-01-04