defines lbinit() in macro CreateLBFunc_Def to simplify code and future extensions.
authorGengbin Zheng <gzheng@illinois.edu>
Tue, 28 Dec 2004 00:24:38 +0000 (00:24 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Tue, 28 Dec 2004 00:24:38 +0000 (00:24 +0000)
18 files changed:
src/ck-ldb/BaseLB.h
src/ck-ldb/CentralLB.C
src/ck-ldb/ComboCentLB.C
src/ck-ldb/Comm1LB.C
src/ck-ldb/DummyLB.C
src/ck-ldb/GreedyCommLB.C
src/ck-ldb/GreedyLB.C
src/ck-ldb/LBDatabase.C
src/ck-ldb/MetisLB.C
src/ck-ldb/NeighborCommLB.C
src/ck-ldb/NeighborLB.C
src/ck-ldb/OrbLB.C
src/ck-ldb/RandCentLB.C
src/ck-ldb/RecBisectBfLB.C
src/ck-ldb/RefineCommLB.C
src/ck-ldb/RefineLB.C
src/ck-ldb/RotateLB.C
src/ck-ldb/WSLB.C

index f35298eaa4c7b6785176cff3b5acaecf9f3bd633..f91e9ec5873bff0ee3cc9071382135628e09d4fe 100644 (file)
@@ -69,23 +69,31 @@ public:
   double * expectedLoad;
 };
 
-// for a FooLB, the following macro defines function:
+// for a FooLB, the following macro defines these functions for each LB:
 // CreateFooLB(): which register with LBDatabase with sequence ticket
-// and 
+// , 
 // AllocateFooLB(): which only locally allocate the class
+// static void lbinit(): which is an init call
 #if CMK_LBDB_ON
-#define CreateLBFunc_Def(x)            \
+#define CreateLBFunc_Def(x, str)               \
 void Create##x(void) {         \
   int seqno = LBDatabaseObj()->getLoadbalancerTicket();        \
   CProxy_##x::ckNew(CkLBOptions(seqno));       \
 }      \
 BaseLB *Allocate##x(void) { \
   return new x((CkMigrateMessage*)NULL);       \
+}      \
+static void lbinit(void) {     \
+  LBRegisterBalancer(#x,       \
+                     Create##x,        \
+                     Allocate##x,      \
+                     str);     \
 }
 #else          /* CMK_LBDB_ON */
-#define CreateLBFunc_Def(x)    \
+#define CreateLBFunc_Def(x, str)       \
 void Create##x(void) {}        \
-BaseLB *Allocate##x(void) { return NULL; }
+BaseLB *Allocate##x(void) { return NULL; }     \
+static void lbinit(void) {}
 #endif
 
 #endif
index e0c236a3b44ea05990f455fcec4d507de8f2f881..f5f355e4eac33ff7ecdf8b1a1aad7ff23d124d31 100644 (file)
@@ -22,11 +22,7 @@ CkGroupID loadbalancer;
 int * lb_ptr;
 int load_balancer_created;
 
-CreateLBFunc_Def(CentralLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("CentralLB", CreateCentralLB, AllocateCentralLB, "CentralLB base class");
-}
+CreateLBFunc_Def(CentralLB, "CentralLB base class");
 
 static void getPredictedLoad(CentralLB::LDStats* stats, int count, 
                             LBMigrateMsg *, double *peLoads, 
index 9cd70bfcd5aed03bc242d947c09a6206ead32580..8e2f800d40f72147a86f1d16f670a9b00afe590d 100644 (file)
@@ -22,14 +22,7 @@ Status:
 
 extern LBAllocFn getLBAllocFn(char *lbname);
 
-CreateLBFunc_Def(ComboCentLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("ComboCentLB", 
-                    CreateComboCentLB, 
-                    AllocateComboCentLB, 
-                    "Allow multiple strategies to work serially");
-}
+CreateLBFunc_Def(ComboCentLB, "Allow multiple strategies to work serially");
 
 ComboCentLB::ComboCentLB(const CkLBOptions &opt): CentralLB(opt)
 {
index 2a8c5e20eee10d5c5c28f43db32435bb32fe7ad0..75b208e18ec2badc3fda2076ce99b1161f55f3fd 100644 (file)
 #define UPPER_FACTOR 0.67
 #define MAX_WEIGHT 5.0
 
-CreateLBFunc_Def(Comm1LB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("Comm1LB", 
-                     CreateComm1LB, 
-                     AllocateComm1LB, 
-                    "another variation of CommLB");
-}
-
-#include "Comm1LB.def.h"
+CreateLBFunc_Def(Comm1LB, "another variation of CommLB");
 
 Comm1LB::Comm1LB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -270,6 +261,7 @@ void Comm1LB::work(CentralLB::LDStats* stats, int count)
   }
 }
 
+#include "Comm1LB.def.h"
 
 /*@}*/
 
index 2d75d53f4568a21e4f778be8a64351094a2bc550..36670f2686c733dd92de0a81e9292a8f10a545fb 100644 (file)
 
 #include "DummyLB.h"
 
-CreateLBFunc_Def(DummyLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("DummyLB", CreateDummyLB, AllocateDummyLB, "Dummy load balancer, like a normal one but with empty strategy");
-}
+CreateLBFunc_Def(DummyLB, "Dummy load balancer, like a normal one but with empty strategy");
 
 #include "DummyLB.def.h"
 
index 848a3078af1d5cc812710b7a512d59f72e16a192..c99a5ecf167c08e59c4027198d1e296b8a37d95a 100644 (file)
@@ -30,16 +30,7 @@ Status:
 #define alpha PER_MESSAGE_SEND_OVERHEAD  /*Startup time per message, seconds*/
 #define beeta PER_BYTE_SEND_OVERHEAD     /*Long-message time per byte, seconds*/
 
-CreateLBFunc_Def(GreedyCommLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("GreedyCommLB", 
-                    CreateGreedyCommLB, 
-                    AllocateGreedyCommLB, 
-                    "Greedy algorithm which takes communication graph into account");
-}
-
-#include "GreedyCommLB.def.h"
+CreateLBFunc_Def(GreedyCommLB, "Greedy algorithm which takes communication graph into account");
 
 #include "manager.h"
 
@@ -299,6 +290,7 @@ void GreedyCommLB::work(CentralLB::LDStats* _stats, int count)
     delete [] object_graph;
 }
 
+#include "GreedyCommLB.def.h"
 
 /*@}*/
 
index 5ca22f28ee56fde40842fbb10dac2d8b71fab6e7..3d0c71a6d110a1db145bfcf35efb8df7d521d7d8 100644 (file)
@@ -14,6 +14,8 @@
  status:
   * support processor avail bitvector
   * support nonmigratable attrib
+      nonmigratable object load is added to its processor's background load
+      and the nonmigratable object is not taken in the objData array
 */
 
 #include <charm++.h>
 #include "cklists.h"
 #include "GreedyLB.h"
 
-CreateLBFunc_Def(GreedyLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("GreedyLB", 
-                     CreateGreedyLB, 
-                     AllocateGreedyLB, 
-                     "always assign the heaviest obj onto lightest loaded processor.");
-}
-
-#include "GreedyLB.def.h"
+CreateLBFunc_Def(GreedyLB, "always assign the heaviest obj onto lightest loaded processor.");
 
 GreedyLB::GreedyLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -238,7 +231,7 @@ void GreedyLB::work(CentralLB::LDStats* stats, int count)
   delete [] objData;
 }
 
-
+#include "GreedyLB.def.h"
 
 /*@}*/
 
index 30c28f83a55eed2247b2308647c9f3c0dfc160a0..3f61abac7a4a38d39102f689039593addc9faf53 100644 (file)
@@ -259,7 +259,7 @@ void _loadbalancerInit()
       CkPrintf("LB> Topology %s\n", _lbtopo);
     }
     if (_lb_args.ignoreBgLoad())
-      CmiPrintf("LB> Load balancer only balance migratable object.\n");
+      CmiPrintf("LB> Load balancer ignores processor background load.\n");
     if (_lb_args.samePeSpeed())
       CmiPrintf("LB> Load balancer assumes all CPUs are same.\n");
     if (_lb_args.useCpuTime())
index e2f18d3d6928359070cf50eb706d39fd6aa7ed7f..a9ad82d25cfafbc23e8cf0a3e195a2ba37e79488 100644 (file)
 
 #include "MetisLB.h"
 
-CreateLBFunc_Def(MetisLB);
-
-static void lbinit(void) {
-//        LBSetDefaultCreate(CreateMetisLB);
-  LBRegisterBalancer("MetisLB", CreateMetisLB, AllocateMetisLB, "Use Metis(tm) to partition object graph");
-}
-
-#include "MetisLB.def.h"
+CreateLBFunc_Def(MetisLB, "Use Metis(tm) to partition object graph");
 
 MetisLB::MetisLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -302,4 +295,6 @@ void MetisLB::work(CentralLB::LDStats* stats, int count)
     delete[] newmap;
 }
 
+#include "MetisLB.def.h"
+
 /*@}*/
index 5d12d28644dd65414db833b32ab0af5265790a97..7e96234842ed725848349fcba9f7eeb3def76362 100644 (file)
 #define PER_MESSAGE_RECV_OVERHEAD   0.0
 #define PER_BYTE_RECV_OVERHEAD      0.0
 
-CreateLBFunc_Def(NeighborCommLB);
-
-static void lbinit(void) {
-//  LBSetDefaultCreate(CreateNeighborCommLB);
-  LBRegisterBalancer("NeighborCommLB", 
-                     CreateNeighborCommLB, 
-                     AllocateNeighborCommLB, 
-                     "The neighborhood load balancer with communication");
-}
-
-#include "NeighborCommLB.def.h"
+CreateLBFunc_Def(NeighborCommLB, "The neighborhood load balancer with communication");
 
 NeighborCommLB::NeighborCommLB(const CkLBOptions &opt):NborBaseLB(opt)
 {
@@ -319,5 +309,6 @@ bool _lb_debug2=0;
 #endif
 };
 
+#include "NeighborCommLB.def.h"
 
 /*@}*/
index e9564c7b59638618cc6015e7b4e12a72d7300023..d1049dbc11b16396eef74974c893031110b9a233 100644 (file)
 #include "heap.h"
 #include "NeighborLB.h"
 
-CreateLBFunc_Def(NeighborLB);
-
-static void lbinit(void) {
-//  LBSetDefaultCreate(CreateNeighborLB);        
-  LBRegisterBalancer("NeighborLB", 
-                     CreateNeighborLB, 
-                     AllocateNeighborLB, 
-                     "The neighborhood load balancer");
-}
-
-#include "NeighborLB.def.h"
+CreateLBFunc_Def(NeighborLB, "The neighborhood load balancer");
 
 NeighborLB::NeighborLB(const CkLBOptions &opt):NborBaseLB(opt)
 {
@@ -179,5 +169,6 @@ LBMigrateMsg* NeighborLB::Strategy(NborBaseLB::LDStats* stats, int count)
 #endif
 };
 
+#include "NeighborLB.def.h"
 
 /*@}*/
index a8ef96c31859d05ed0483c518a1708651735ead6..61ad1180327a35652a444b95578875117ee9b236 100644 (file)
 
 //#define DEBUG
 
-CreateLBFunc_Def(OrbLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("OrbLB", CreateOrbLB, AllocateOrbLB, "partition objects based on coordinates");
-}
-
-#include "OrbLB.def.h"
+CreateLBFunc_Def(OrbLB, "partition objects based on coordinates");
 
 OrbLB::OrbLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -477,7 +471,6 @@ void OrbLB::work(CentralLB::LDStats* stats, int count)
 #endif
 }
 
-
-
+#include "OrbLB.def.h"
 
 /*@}*/
index ad09b171df2ec76a518beeea942e21f483e11a0d..1d83006dd0bdc638defbfd64eb111b51fed057d2 100644 (file)
@@ -22,13 +22,7 @@ Status:
 
 #include "RandCentLB.h"
 
-CreateLBFunc_Def(RandCentLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("RandCentLB", CreateRandCentLB, AllocateRandCentLB, "Assign objects to processors randomly");
-}
-
-#include "RandCentLB.def.h"
+CreateLBFunc_Def(RandCentLB, "Assign objects to processors randomly");
 
 RandCentLB::RandCentLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -73,5 +67,6 @@ void RandCentLB::work(CentralLB::LDStats* stats, int count)
   }
 }
 
+#include "RandCentLB.def.h"
 
 /*@}*/
index 9dbaeaa9ceb2a755d5580577703d1036a3520bee..05d063bbad140b92a24d72d580bcd3a951199b53 100644 (file)
@@ -46,14 +46,7 @@ extern "C" {
 
 
 
-CreateLBFunc_Def(RecBisectBfLB);
-
-static void lbinit(void) {
-//        LBSetDefaultCreate(CreateRecBisectBfLB);
-  LBRegisterBalancer("RecBisectBfLB", CreateRecBisectBfLB, AllocateRecBisectBfLB, "Recursive partitioning with Breadth first enumeration");
-}
-
-#include "RecBisectBfLB.def.h"
+CreateLBFunc_Def(RecBisectBfLB, "Recursive partitioning with Breadth first enumeration");
 
 RecBisectBfLB::RecBisectBfLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -332,5 +325,6 @@ void RecBisectBfLB::recursivePartition(int numParts, Graph *g,
   }  
 }
 
+#include "RecBisectBfLB.def.h"
 
 /*@}*/
index 187e8b4b538b8fcefa6182bd82482348110f823c..c04fc61f4152510a9857eb04d136e9e5b2e87128 100644 (file)
 
 #include "RefineCommLB.h"
 
-CreateLBFunc_Def(RefineCommLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("RefineCommLB", 
-                     CreateRefineCommLB, 
-                     AllocateRefineCommLB, 
-                     "Average load among processors by moving objects away from overloaded processor, communication aware");
-}
-
-#include "RefineCommLB.def.h"
+CreateLBFunc_Def(RefineCommLB, "Average load among processors by moving objects away from overloaded processor, communication aware");
 
 RefineCommLB::RefineCommLB(const CkLBOptions &opt): RefineLB(opt)
 {
@@ -77,5 +68,6 @@ void RefineCommLB::work(CentralLB::LDStats* stats, int count)
 #endif
 };
 
+#include "RefineCommLB.def.h"
 
 /*@}*/
index 3711175bd1e7dde68b312a3aaeb3aa7fb3870878..154074bfa94c3d063ddba0e4a2824d38e52a60a2 100644 (file)
 
 #include "RefineLB.h"
 
-CreateLBFunc_Def(RefineLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("RefineLB", 
-                     CreateRefineLB, 
-                     AllocateRefineLB, 
-                     "Move objects away from overloaded processor to reach average");
-}
-
-#include "RefineLB.def.h"
+CreateLBFunc_Def(RefineLB, "Move objects away from overloaded processor to reach average");
 
 RefineLB::RefineLB(const CkLBOptions &opt): CentralLB(opt)
 {
@@ -70,4 +61,6 @@ void RefineLB::work(CentralLB::LDStats* stats, int count)
   Refiner::FreeProcs(to_procs);
 };
 
+#include "RefineLB.def.h"
+
 /*@}*/
index 31212c33ac7d19e69c0802d042bb288f6242f381..29154eba6871e816582bf90b3a0479dd9fd46ef3 100644 (file)
 
 #include "RotateLB.h"
 
-CreateLBFunc_Def (RotateLB);
-
-
-/**************************************************************************
-**
-*/
-static void lbinit (void)
-{
-  LBRegisterBalancer ("RotateLB",
-                     CreateRotateLB,
-                     AllocateRotateLB,
-                     "Rotate each object to the next higher PE");
-}
 
+CreateLBFunc_Def (RotateLB, "Rotate each object to the next higher PE");
 
 /**************************************************************************
 **
index 929ccc35dc912556b8f9fc52c3c8896f8484bdd8..4571504226a0edda89cd84098f823aeb17ce3582 100644 (file)
 #define VACATE_AFTER 30
 #define UNVACATE_AFTER 15
 
-CreateLBFunc_Def(WSLB);
-
-static void lbinit(void) {
-  LBRegisterBalancer("WSLB", 
-                     CreateWSLB, 
-                    AllocateWSLB, 
-                     "Workstation load balancer");
-}
-
+CreateLBFunc_Def(WSLB, "Workstation load balancer");
 
 void WSLB::staticMigrated(void* data, LDObjHandle h, int waitBarrier)
 {