Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:57

0001 // Copyright (C) 2005 Douglas Gregor.
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // Compute parents, children, levels, etc. to effect a parallel
0008 // computation tree.
0009 #ifndef BOOST_MPI_COMPUTATION_TREE_HPP
0010 #define BOOST_MPI_COMPUTATION_TREE_HPP
0011 
0012 namespace boost { namespace mpi { namespace detail {
0013 
0014 /**
0015  * @brief Aids tree-based parallel collective algorithms.
0016  *
0017  * Objects of this type
0018  */
0019 class computation_tree
0020 {
0021  public:
0022   computation_tree(int rank, int size, int root, int branching_factor = -1);
0023 
0024   /// Returns the branching factor of the tree.
0025   int branching_factor() const { return branching_factor_; }
0026 
0027   /// Returns the level in the tree on which this process resides.
0028   int level() const { return level_; }
0029 
0030   /**
0031    * Returns the index corresponding to the n^th level of the tree.
0032    *
0033    * @param n The level in the tree whose index will be returned.
0034    */
0035   int level_index(int n) const;
0036 
0037   /**
0038    *  @brief Returns the parent of this process.
0039    *
0040    *  @returns If this process is the root, returns itself. Otherwise,
0041    *  returns the process number that is the parent in the computation
0042    *  tree.
0043    */
0044   int parent() const;
0045 
0046   /// Returns the index for the first child of this process.
0047   int child_begin() const;
0048 
0049   /**
0050    * @brief The default branching factor within the computation tree.
0051    *
0052    * This is the default branching factor for the computation tree, to
0053    * be used by any computation tree that does not fix the branching
0054    * factor itself. The default is initialized to 3, but may be
0055    * changed by the application so long as all processes have the same
0056    * branching factor.
0057    */
0058   static int default_branching_factor;
0059 
0060  protected:
0061   /// The rank of this process in the computation tree.
0062   int rank;
0063 
0064   /// The number of processes participating in the computation tree.
0065   int size;
0066 
0067   /// The process number that is acting as the root in the computation
0068   /// tree.
0069   int root;
0070 
0071   /**
0072    * @brief The branching factor within the computation tree.
0073    *
0074    * This is the default number of children that each node in a
0075    * computation tree will have. This value will be used for
0076    * collective operations that use tree-based algorithms.
0077    */
0078   int branching_factor_;
0079 
0080   /// The level in the tree at which this process resides.
0081   int level_;
0082 };
0083 
0084 } } } // end namespace boost::mpi::detail
0085 
0086 #endif // BOOST_MPI_COMPUTATION_TREE_HPP