]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpi/example/random_gather.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / mpi / example / random_gather.cpp
CommitLineData
7c673cae
FG
1// Copyright (C) 2006 Douglas Gregor <doug.gregor@gmail.com>
2
3// Use, modification and distribution is subject to the Boost Software
4// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
11fdf7f2 7// An example using Boost.MPI's gather(): [main]
7c673cae
FG
8
9#include <boost/mpi.hpp>
10#include <iostream>
11#include <cstdlib>
12namespace mpi = boost::mpi;
13
14int main(int argc, char* argv[])
15{
16 mpi::environment env(argc, argv);
17 mpi::communicator world;
18
19 std::srand(time(0) + world.rank());
20 int my_number = std::rand();
21 if (world.rank() == 0) {
22 std::vector<int> all_numbers;
23 gather(world, my_number, all_numbers, 0);
24 for (int proc = 0; proc < world.size(); ++proc)
25 std::cout << "Process #" << proc << " thought of " << all_numbers[proc]
26 << std::endl;
27 } else {
28 gather(world, my_number, 0);
29 }
7c673cae
FG
30 return 0;
31}