|
Boost Users : |
Subject: Re: [Boost-users] mpi all_reduce
From: Philipp Kraus (philipp.kraus_at_[hidden])
Date: 2010-12-03 04:39:20
On 2010-12-02 23:37:34 +0100, Riccardo Murri said:
> Hi Phillip,
>
> On Thu, Dec 2, 2010 at 7:08 PM, Kraus Philipp
> <philipp.kraus_at_[hidden]> wrote:
>> how can I use the mpi::all_reduce with std::accumulate? I would reduce the
>> values of each process with a sum function
>>
>
> You can use mpi::all_reduce like this::
>
> int local_value = ...; // local computation
> int global_value = 0;
> mpi::all_reduce(comm_, local_value, global_value, std::plus<int>());
> // now `global_value` holds the sum of `local_value` of all MPI ranks
>
> where `comm_` is an instance of mpi::communicator; other binary
> operations are available besides std::plus (or you can define your
> own).
Thank's
Phil
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net