00001 00005 00006 #include "elements.h" 00007 #include "ckheap.h" 00008 #include "RefineCommLB.h" 00009 00010 extern int quietModeRequested; 00011 00012 CreateLBFunc_Def(RefineCommLB, "Average load among processors by moving objects away from overloaded processor, communication aware") 00013 00014 RefineCommLB::RefineCommLB(const CkLBOptions &opt): CBase_RefineCommLB(opt) 00015 { 00016 lbname = (char *)"RefineCommLB"; 00017 if (CkMyPe() == 0 && !quietModeRequested) 00018 CkPrintf("CharmLB> RefineCommLB created.\n"); 00019 } 00020 00021 bool RefineCommLB::QueryBalanceNow(int _step) 00022 { 00023 return true; 00024 } 00025 00026 void RefineCommLB::work(LDStats* stats) 00027 { 00028 #if CMK_LBDB_ON 00029 int obj; 00030 int n_pes = stats->nprocs(); 00031 00032 // CkPrintf("[%d] RefineLB strategy\n",CkMyPe()); 00033 00034 // RemoveNonMigratable(stats, n_pes); 00035 00036 // get original object mapping 00037 int* from_procs = RefinerComm::AllocProcs(n_pes, stats); 00038 for(obj=0;obj<stats->n_objs;obj++) { 00039 int pe = stats->from_proc[obj]; 00040 from_procs[obj] = pe; 00041 } 00042 00043 // Get a new buffer to refine into 00044 int* to_procs = RefinerComm::AllocProcs(n_pes, stats); 00045 00046 RefinerComm refiner(1.003); // overload tolerance=1.05 00047 00048 refiner.Refine(n_pes, stats, from_procs, to_procs); 00049 00050 // Save output 00051 for(obj=0;obj<stats->n_objs;obj++) { 00052 int pe = stats->from_proc[obj]; 00053 if (to_procs[obj] != pe) { 00054 // CkPrintf("[%d] Obj %d migrating from %d to %d\n", 00055 // CkMyPe(),obj,pe,to_procs[obj]); 00056 stats->to_proc[obj] = to_procs[obj]; 00057 } 00058 } 00059 00060 // Free the refine buffers 00061 RefinerComm::FreeProcs(from_procs); 00062 RefinerComm::FreeProcs(to_procs); 00063 #endif 00064 } 00065 00066 #include "RefineCommLB.def.h" 00067