| Home | Libraries | People | FAQ | More

## Function scatter

boost::mpi::scatter — Scatter the values stored at the root to all processes within the communicator.

## Synopsis

    template<typename T>
      void scatter(const communicator & comm, const std::vector< T > & in_values,
                   T & out_value, int root);
    template<typename T>
      void scatter(const communicator & comm, const T * in_values, T & out_value,
                   int root);
    template<typename T>
      void scatter(const communicator & comm, T & out_value, int root);
    template<typename T>
      void scatter(const communicator & comm, const std::vector< T > & in_values,
                   T * out_values, int n, int root);
    template<typename T>
      void scatter(const communicator & comm, const T * in_values, T * out_values,
                   int n, int root);
    template<typename T>
      void scatter(const communicator & comm, T * out_values, int n, int root);

## Description

`scatter` is a collective algorithm that scatters the values stored in the `root` process (inside a vector) to all of the processes in the communicator. The vector `out_values` (only significant at the `root`) is indexed by the process number to which the corresponding value will be sent. The type `T` of the values may be any type that is serializable or has an associated MPI data type.

When the type `T` has an associated MPI data type, this routine invokes `MPI_Scatter` to scatter the values.

Parameters: |
`comm` | The communicator over which the gather will occur.
`in_values` | A vector or pointer to storage that will contain the values to send to each process, indexed by the process rank. For non-root processes, this parameter may be omitted. If it is still provided, however, it will be unchanged.
`out_value` | The value received by each process. When scattering an array of values, `out_values` points to the `n` values that will be received by each process.
`root` | The process ID number that will scatter the values. This value must be the same on all processes.