1 // Copyright (C) 2005 Douglas Gregor.
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)
7 // Compute parents, children, levels, etc. to effect a parallel
9 #ifndef BOOST_MPI_COMPUTATION_TREE_HPP
10 #define BOOST_MPI_COMPUTATION_TREE_HPP
12 namespace boost
{ namespace mpi
{ namespace detail
{
15 * @brief Aids tree-based parallel collective algorithms.
17 * Objects of this type
19 class computation_tree
22 computation_tree(int rank
, int size
, int root
, int branching_factor
= -1);
24 /// Returns the branching factor of the tree.
25 int branching_factor() const { return branching_factor_
; }
27 /// Returns the level in the tree on which this process resides.
28 int level() const { return level_
; }
31 * Returns the index corresponding to the n^th level of the tree.
33 * @param n The level in the tree whose index will be returned.
35 int level_index(int n
) const;
38 * @brief Returns the parent of this process.
40 * @returns If this process is the root, returns itself. Otherwise,
41 * returns the process number that is the parent in the computation
46 /// Returns the index for the first child of this process.
47 int child_begin() const;
50 * @brief The default branching factor within the computation tree.
52 * This is the default branching factor for the computation tree, to
53 * be used by any computation tree that does not fix the branching
54 * factor itself. The default is initialized to 3, but may be
55 * changed by the application so long as all processes have the same
58 static int default_branching_factor
;
61 /// The rank of this process in the computation tree.
64 /// The number of processes participating in the computation tree.
67 /// The process number that is acting as the root in the computation
72 * @brief The branching factor within the computation tree.
74 * This is the default number of children that each node in a
75 * computation tree will have. This value will be used for
76 * collective operations that use tree-based algorithms.
78 int branching_factor_
;
80 /// The level in the tree at which this process resides.
84 } } } // end namespace boost::mpi::detail
86 #endif // BOOST_MPI_COMPUTATION_TREE_HPP