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