00001
00005
00006 #include "elements.h"
00007 #include "ckheap.h"
00008 #include "RefineLB.h"
00009
00010 CreateLBFunc_Def(RefineLB, "Move objects away from overloaded processor to reach average")
00011
00012 RefineLB::RefineLB(const CkLBOptions &opt): CentralLB(opt)
00013 {
00014 lbname = (char *)"RefineLB";
00015 if (CkMyPe() == 0)
00016 CkPrintf("[%d] RefineLB created\n",CkMyPe());
00017 }
00018
00019 void RefineLB::work(LDStats* stats)
00020 {
00021 int obj;
00022 int n_pes = stats->nprocs();
00023
00024
00025
00026
00027
00028
00029 int* from_procs = Refiner::AllocProcs(n_pes, stats);
00030 for(obj=0;obj<stats->n_objs;obj++) {
00031 int pe = stats->from_proc[obj];
00032 from_procs[obj] = pe;
00033 }
00034
00035
00036 int* to_procs = Refiner::AllocProcs(n_pes, stats);
00037
00038 Refiner refiner(1.003);
00039
00040 refiner.Refine(n_pes, stats, from_procs, to_procs);
00041
00042
00043 for(obj=0;obj<stats->n_objs;obj++) {
00044 int pe = stats->from_proc[obj];
00045 if (to_procs[obj] != pe) {
00046 if (_lb_args.debug()>=2) {
00047 CkPrintf("[%d] Obj %d migrating from %d to %d\n",
00048 CkMyPe(),obj,pe,to_procs[obj]);
00049 }
00050 stats->to_proc[obj] = to_procs[obj];
00051 }
00052 }
00053
00054
00055 Refiner::FreeProcs(from_procs);
00056 Refiner::FreeProcs(to_procs);
00057 }
00058
00059 #include "RefineLB.def.h"
00060