00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef VNODE_MULTI_BALANCER_H 00012 #define VNODE_MULTI_BALANCER_H 00013 00014 //----------------------------------------------------------------------------- 00015 // Description: 00016 // Vnode-granularity load balancer, based on input container of bool weight 00017 // BareFields 00018 //----------------------------------------------------------------------------- 00019 00020 // include files 00021 #ifdef IPPL_STDSTL 00022 #include <vector> 00023 using std::vector; 00024 #else 00025 #include <vector.h> 00026 #endif // IPPL_STDSTL 00027 00028 // Forward declarations: 00029 template<unsigned Dim> class FieldLayout; 00030 template<class T, unsigned Dim> class BareField; 00031 00032 //----------------------------------------------------------------------------- 00033 // Full Description: 00034 00035 // A fairly simple load balancer inspired by Dan Quinlan's MLB, which balances 00036 // at the level of granularity of the vnode, rather than the individual Field 00037 // element (BinaryBalancer does the latter). 00038 00039 // It requires a FieldLayout expressed as a product of vnodes along each 00040 // direction, meaning a power-of-two vnode count or else use of the special 00041 // [Centered]FieldLayout constructors specifying vnodes per direction. 00042 00043 // Internally, it constructs a Field<...,double,....> having one element for 00044 // each vnode along each direction in the input FieldLayout, called vf. It 00045 // assigns a weight of 1.0 to each element equal to the total number of unique 00046 // Field's having any true elements in each vnode for all the Field's in the 00047 // input container (STL vector) of boolean weight Fields. If any vnode is 00048 // compressed to false, the corresponding vf element value is left unchanged; 00049 // if a vnode is uncompressed, this means that there is at least one true 00050 // element in it, and the vf element value is incremented by one; if a vnode is 00051 // compressed to true, this means all elements are true and the vf element is 00052 // also incremented by 1. Then, it invokes BinaryBalancer on this small Field 00053 // of weights, vf, to partition it elementwise among the processors, one 00054 // element per PE. Finally, it maps this back to the input FieldLayout (used by 00055 // the input Fields of weights), and repartitions the input FieldLayout's 00056 // vnodes in a corresponding way among the PE's. 00057 00058 // There is one function defined here: 00059 00060 // Calculate and apply a local domain for a binary repartition. 00061 template<unsigned Dim> 00062 void VnodeMultiRepartition(FieldLayout<Dim>& layout, 00063 vector<BareField<bool,Dim>* >& weights); 00064 00065 #include "FieldLayout/VnodeMultiBalancer.cpp" 00066 00067 #endif // VNODE_MULTI_BALANCER_H 00068 00069 /*************************************************************************** 00070 * $RCSfile: VnodeMultiBalancer.h,v $ $Author: adelmann $ 00071 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:27 $ 00072 * IPPL_VERSION_ID: $Id: VnodeMultiBalancer.h,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $ 00073 ***************************************************************************/ 00074