]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpi/example/cartesian_communicator.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / mpi / example / cartesian_communicator.cpp
1 // Copyright Alain Miniussi 2014.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // Authors: Alain Miniussi
7
8 #include <vector>
9 #include <iostream>
10
11 #include <boost/mpi/communicator.hpp>
12 #include <boost/mpi/collectives.hpp>
13 #include <boost/mpi/environment.hpp>
14 #include <boost/mpi/cartesian_communicator.hpp>
15
16 namespace mpi = boost::mpi;
17 // Curly brace init make this useless, but
18 // - Need to support obsolete like g++ 4.3.x. for some reason
19 // - Can't conditionnaly compile with bjam (unless you find
20 // the doc, and read it, which would only make sense if you
21 // actually wan't to use bjam, which does not (make sense))
22 typedef mpi::cartesian_dimension cd;
23
24 int main(int argc, char* argv[])
25 {
26 mpi::environment env;
27 mpi::communicator world;
28
29 if (world.size() != 24) return -1;
30 mpi::cartesian_dimension dims[] = {cd(2, true), cd(3,true), cd(4,true)};
31 mpi::cartesian_communicator cart(world, mpi::cartesian_topology(dims));
32 for (int r = 0; r < cart.size(); ++r) {
33 cart.barrier();
34 if (r == cart.rank()) {
35 std::vector<int> c = cart.coordinates(r);
36 std::cout << "rk :" << r << " coords: "
37 << c[0] << ' ' << c[1] << ' ' << c[2] << '\n';
38 }
39 }
40 return 0;
41 }
42