OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BinaryBalancer.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef BINARY_BALANCER_H
12 #define BINARY_BALANCER_H
13 
15 /*
16 
17  A fairly simple load balancer inspired by Dan Quinlan's MLB.
18 
19  It does recursive binary subdivision of a FieldLayout domain,
20  restricting the cuts to coordinate directions, so as to balance the
21  workload. The "workload" is given by a Field of weights passed in.
22  It decides on the cut axis by cutting the longest axis of a brick,
23  and the location of that cut by balancing the weights on each side
24  of the cut. The resulting distribution has one vnode per processor.
25 
26  This is restricted to a processor number that is a power of two.
27 
28  It performs log(P) parallel reductions.
29 
30  It does nothing fancy when deciding on the splits to try to make the
31  new paritioning close to the previous. The same set of weights will
32  always give the same repartitioning, but similar sets of weights
33  could result in quite different partitionings.
34 
35  There are two functions defined here:
36 
37  NDIndex<Dim>
38  CalcBinaryRepartion(FieldLayout<Dim>&, BareField<double,Dim>&);
39 
40  Given a FieldLayout and a Field of weights, find the domain for this
41  processor. This does not repartition the FieldLayout, it just
42  calculates the domain. If you want to further subdivide these
43  domains, just cut up what this function returns.
44 
45  void
46  BinaryRepartition(FieldLayout<Dim>&, BareField<double,Dim>&);
47 
48  Just call the above function and then repartition the FieldLayout
49  (and all the Fields defined on it).
50 
51  */
53 
54 // forward declarations
55 template<unsigned Dim> class FieldLayout;
56 template<class T, unsigned Dim> class BareField;
57 
59 
60 // Calculate the local domain for a binary repartition.
61 template<unsigned Dim>
64 
65 // Calculate and apply a local domain for a binary repartition.
66 template<unsigned Dim>
67 inline void
69 {
70  layout.Repartition( CalcBinaryRepartition(layout,weights) );
71 }
72 
74 
76 
77 #endif // BINARY_BALANCER_H
78 
79 /***************************************************************************
80  * $RCSfile: BinaryBalancer.h,v $ $Author: adelmann $
81  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:27 $
82  * IPPL_VERSION_ID: $Id: BinaryBalancer.h,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $
83  ***************************************************************************/
void Repartition(const NDIndex< Dim > *, const NDIndex< Dim > *)
void BinaryRepartition(FieldLayout< Dim > &layout, BareField< double, Dim > &weights)
Definition: FFT.h:30
NDIndex< Dim > CalcBinaryRepartition(FieldLayout< Dim > &, BareField< double, Dim > &)