00001 00005 00006 /* 00007 A Hybrid strategy that uses 3 level tree 00008 The top level applies refinement strategy 00009 The test applies greedy strategy 00010 */ 00011 00012 #include "HybridLB.h" 00013 #include "LBDBManager.h" 00014 00015 #include "GreedyLB.h" 00016 #include "GreedyRefineLB.h" 00017 #include "GreedyCommLB.h" 00018 #include "RefineCommLB.h" 00019 #include "RefineLB.h" 00020 #include "MetisLB.h" 00021 00022 #define DEBUGF(x) // CmiPrintf x; 00023 00024 CreateLBFunc_Def(HybridLB, "Hybrid load balancer") 00025 00026 HybridLB::HybridLB(const CkLBOptions &opt): CBase_HybridLB(opt) 00027 { 00028 #if CMK_LBDB_ON 00029 lbname = (char *)"HybridLB"; 00030 00031 // defines topology in base class 00032 // tree = new ThreeLevelTree; 00033 00034 // decide which load balancer to call 00035 // IMPORTANT: currently, the greedy LB must allow objects that 00036 // are not from existing processors. 00037 refine = (CentralLB *)AllocateRefineLB(); 00038 // greedy = (CentralLB *)AllocateMetisLB(); 00039 greedy = (CentralLB *)AllocateGreedyRefineLB(); 00040 greedy->setConcurrent(false); 00041 00042 initTree(); 00043 #endif 00044 } 00045 00046 HybridLB::~HybridLB() 00047 { 00048 delete greedy; 00049 delete refine; 00050 } 00051 00052 void HybridLB::work(LDStats* stats) 00053 { 00054 #if CMK_LBDB_ON 00055 theLbdb->ResetAdaptive(); 00056 LevelData *lData = levelData[currentLevel]; 00057 00058 // TODO: let's generate LBMigrateMsg ourself 00059 // take into account the outObjs 00060 //if (currentLevel == tree->numLevels()-1) 00061 if (currentLevel == 1) 00062 greedy->work(stats); 00063 else 00064 refine->work(stats); 00065 #endif 00066 } 00067 00068 #include "HybridLB.def.h" 00069