# auto_partitioner Class

## Summary

Specify that a parallel loop should optimize its range subdivision based on work-stealing events.

## Header

    #include "tbb/partitioner.h"

## Syntax

    class auto_partitioner;

## Description

A loop template with an `auto_partitioner` attempts to minimize range splitting while providing ample opportunities for work-stealing.

The range subdivision is initially limited to S subranges, where S is proportional to the number of threads specified by the `task_scheduler_init`. Each of these subranges is not divided further unless it is stolen by an idle thread. If stolen, it is further subdivided to create additional subranges. Thus a loop template with an `auto_partitioner` creates additional subranges only when necessary to balance load.

### Tip

When using `auto_partitioner` and a `blocked_range` for a parallel loop, the body may be passed a subrange larger than the `blocked_range`'s grainsize. Therefore do not assume that the grainsize is an upper bound on the size of the subrange. Use a`simple_partitioner` if an upper bound is required.

## Members

    namespace tbb {
        class auto_partitioner {
        public:
            auto_partitioner();
            ~auto_partitioner();
        }
    }

The following table provides additional information on the members of this template class.
Member | Description
--- | ---
auto_partitioner() | Construct an `auto_partitioner`.
~auto_partitioner() | Destroy this `auto_partitioner`.

Parent topic: Partitioners

## See Also

task_scheduler_init Class