ExecutionPolicy - SeqAn API Documentation

# Class ExecutionPolicy
Policy to select runtime execution mode for algorithms.

All Subcl's | WavefrontExecutionPolicy
Defined in | <seqan/parallel.h>
Signature | `template<typename TThreadingMode, typename TVectorizationMode> struct ExecutionPolicy;`

## Template Parameters

`TThreadingMode` | Type specifying the threading model. Can be Parallel or Serial (default).
`TVectorizationMode` | Type specifying the vectorization model. Can be Vectorial or Serial (default).

## Interface Function Overview

- `auto numThreads(exec);`
  Getter function for the thread number.
- `void setNumThreads(exec, n);`
  Setter function for the thread number.

## Interface Metafunction Overview

- `IsExecutionPolicy<T>::VALUE`
  Checks if a given type is an ExecutionPolicy.
- `IsParallel<TExecPolicy>::VALUE`
  Evaluates to True if the execution policy is specialized with Parallel.
- `IsVectorized<TExecPolicy>::VALUE`
  Evaluates to True if the execution policy is specialized with Vectorial.

## Member Variable Overview

- `size_t ExecutionPolicy::numThreads`
  The number of threads to use for the parallel execution. Defaults to 1.

## Detailed Description

The `ExecutionPolicy` class is used to select different execution models for certain algorithms. Depending on the specialization of the template parameters 4 different modes are possible: sequential, parallel, vectorized and parallel+vectorized. The number of threads for the parallel execution modes can be configured via a member variable.

## Interface Functions Detail

### `auto numThreads(exec);`

Getter function for the thread number.

#### Parameters

`exec` | The ExecutionPolicy to get the number of threads for.

#### Returns

`auto` | The number of threads.

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

### `void setNumThreads(exec, n);`

Setter function for the thread number.

#### Parameters

`exec` | The ExecutionPolicy to set the number of threads for.
`n` | The number of threads used for the parallel execution.

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

## Interface Metafunctions Detail

### `IsExecutionPolicy<T>::VALUE`

Checks if a given type is an ExecutionPolicy.

#### Template Parameters

`T` | The type to check.

#### Returns

`bool` | `true` if the `T` is an ExecutionPolicy type, otherwise `false`.

### `IsParallel<TExecPolicy>::VALUE`

Evaluates to True if the execution policy is specialized with Parallel.

#### Template Parameters

`TTExecPolicy` | The ExecutionPolicy to check.

#### Returns

`bool` | `true` if ExecutionPolicy is Parallel, otherwise `false`.

### `IsVectorized<TExecPolicy>::VALUE`

Evaluates to True if the execution policy is specialized with Vectorial.

#### Template Parameters

`TTExecPolicy` | The ExecutionPolicy to check.

#### Returns

`bool` | `true` if ExecutionPolicy is Vectorial, otherwise `false`.

## Member Variables Detail

### `size_t ExecutionPolicy::numThreads`

The number of threads to use for the parallel execution. Defaults to 1.

#### Dox Sources

    /*!
     * @class ExecutionPolicy
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Policy to select runtime execution mode for algorithms.
     *
     * @signature template<typename TThreadingMode, typename TVectorizationMode>
     *            struct ExecutionPolicy;
     *
     * @tparam TThreadingMode Type specifying the threading model. Can be @link
     *                        ParallelismTags#Parallel @endlink or @link
     *                        ParallelismTags#Serial @endlink (default).
     * @tparam TVectorizationMode Type specifying the vectorization model. Can be
     *                            @link ParallelismTags#Vectorial @endlink or @link
     *                            ParallelismTags#Serial @endlink (default).
     *
     * The <tt>ExecutionPolicy</tt> class is used to select different execution
     * models for certain algorithms. Depending on the specialization of the
     * template parameters 4 different modes are possible: sequential, parallel,
     * vectorized and parallel+vectorized. The number of threads for the parallel
     * execution modes can be configured via a member variable.
     *
     * @mfn ExecutionPolicy#IsVectorized
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Evaluates to @link LogicalValuesTags#True @endlink if the execution
     *        policy is specialized with @link ParallelismTags#Vectorial @endlink.
     *
     * @signature IsVectorized<TExecPolicy>::VALUE
     *
     * @tparam TTExecPolicy The @link ExecutionPolicy @endlink to check.
     *
     * @return bool <tt>true</tt> if @link ExecutionPolicy @endlink is @link
     *              ParallelismTags#Vectorial @endlink, otherwise <tt>false</tt>.
     *
     * @mfn ExecutionPolicy#IsParallel
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Evaluates to @link LogicalValuesTags#True @endlink if the execution
     *        policy is specialized with @link ParallelismTags#Parallel @endlink.
     *
     * @signature IsParallel<TExecPolicy>::VALUE
     *
     * @tparam TTExecPolicy The @link ExecutionPolicy @endlink to check.
     *
     * @return bool <tt>true</tt> if @link ExecutionPolicy @endlink is @link
     *              ParallelismTags#Parallel @endlink, otherwise <tt>false</tt>.
     *
     * @mfn ExecutionPolicy#IsExecutionPolicy
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Checks if a given type is an @link ExecutionPolicy @endlink.
     *
     * @signature IsExecutionPolicy<T>::VALUE
     *
     * @tparam T The type to check.
     *
     * @return bool <tt>true</tt> if the <tt>T</tt> is an @link ExecutionPolicy
     *              @endlink type, otherwise <tt>false</tt>.
     *
     * @var size_t ExecutionPolicy::numThreads;
     *
     * @brief The number of threads to use for the parallel execution. Defaults to
     *        1.
     *
     * @fn ExecutionPolicy#numThreads
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Getter function for the thread number.
     *
     * @signature auto numThreads(exec);
     *
     * @param[in] exec The @link ExecutionPolicy @endlink to get the number of
     *                 threads for.
     *
     * @return auto The number of threads.
     *
     * @fn ExecutionPolicy#setNumThreads
     *
     * @headerfile <seqan/parallel.h>
     *
     * @brief Setter function for the thread number.
     *
     * @signature void setNumThreads(exec, n);
     *
     * @param[in,out] exec The @link ExecutionPolicy @endlink to set the number of
     *                     threads for.
     * @param[in] n The number of threads used for the parallel execution.
     */