OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ConejoBalancer.hpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  * This program was prepared by PSI.
7  * All rights in the program are reserved by PSI.
8  * Neither PSI nor the author(s)
9  * makes any warranty, express or implied, or assumes any liability or
10  * responsibility for the use of this software
11  *
12  * Visit www.amas.web.psi for more details
13  *
14  ***************************************************************************/
15 
16 // -*- C++ -*-
17 /***************************************************************************
18  *
19  * The IPPL Framework
20  *
21  *
22  * Visit http://people.web.psi.ch/adelmann/ for more details
23  *
24  ***************************************************************************/
25 
26 // include files
29 #include "Utility/IpplInfo.h"
30 
32 
33 //
34 // reduceLocalWeights
35 //
36 // Input:
37 // BareField<T,D> with weights
38 // bool dropCompressed, which is true if compressed vnodes in weights
39 // should have the weight of a single element instead of multipplied
40 // by the number of elements.
41 // Outout: a container of doubles.
42 //
43 // Given a BareField and a container,
44 // loop over each vnode, finding the maximum weight
45 // on each vnode.
46 // Put those reduced weights in the container.
47 //
48 // This is a bare function, since it does not depend on anything
49 // in the class ConejoBalancer.
50 // This is an inline function so it does not generate an additional
51 // prelink step.
52 //
53 
54 template<class T, unsigned int D>
55 inline void
57  std::vector<double>& vnodeWeights,
58  bool dropCompressed)
59 {
60  // Get an iterator and loop over the LFields of the BareField.
61  typename BareField<T,D>::iterator_if lf = weights.begin_if();
62  for ( ; lf != weights.end_if() ; ++lf )
63  {
64  // Get an iterator and loop over the contents of this LField.
65  typename LField<T,D>::iterator lp = (*lf).second->begin();
66 
67  // A place to record the total weight.
68  // Start with just the first element.
69  double x = *lp;
70 
71  // If the LField is compressed and and dropCompressed is true,
72  // then the weight from this vnode comes from just the one element.
73  if ( !(dropCompressed && (*lf).second->IsCompressed()) )
74  {
75  // Add up all the values in the vnode.
76  for ( ++lp ; lp != (*lf).second->end() ; ++lp )
77  x += *lp;
78  }
79 
80  // Append the largest value to the container.
81  vnodeWeights.push_back( x );
82  }
83 }
84 
86 //
87 // PRIVATE member functions
88 //
90 //mwerks Moved into class definition (.h file).
91 
92 
93 /***************************************************************************
94  * $RCSfile: ConejoBalancer.cpp,v $ $Author: adelmann $
95  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:27 $
96  * IPPL_VERSION_ID: $Id: ConejoBalancer.cpp,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $
97  ***************************************************************************/
ac_id_larray::iterator iterator_if
Definition: BareField.h:91
iterator_if end_if()
Definition: BareField.h:100
void reduceLocalWeights(BareField< T, D > &weights, std::vector< double > &vnodeWeights, bool dropCompressed)
Definition: FFT.h:30
iterator_if begin_if()
Definition: BareField.h:99