]>
git.proxmox.com Git - ceph.git/blob - 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)
6 // Authors: Alain Miniussi
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>
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
;
24 int main(int argc
, char* argv
[])
27 mpi::communicator world
;
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
) {
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';