00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "RotateLB.decl.h"
00013 #include "RotateLB.h"
00014
00015
00016 CreateLBFunc_Def (RotateLB, "Rotate each object to the next higher PE")
00017
00018
00019
00020
00021 RotateLB::RotateLB (const CkLBOptions &opt) : CentralLB (opt)
00022 {
00023 lbname = "RotateLB";
00024
00025 if (CkMyPe () == 0) {
00026 CkPrintf ("[%d] RotateLB created\n", CkMyPe ());
00027 }
00028 }
00029
00030
00031
00032
00033
00034 CmiBool RotateLB::QueryBalanceNow (int _step)
00035 {
00036 return CmiTrue;
00037 }
00038
00039
00040
00041
00042
00043 void RotateLB::work(LDStats *stats)
00044 {
00045 int proc;
00046 int obj;
00047 int dest;
00048 LDObjData *odata;
00049 int n_pes = stats->nprocs();
00050
00051
00052 for (proc = 0; proc < n_pes; proc++) {
00053 if (stats->procs[proc].available) {
00054 break;
00055 }
00056 }
00057 if (proc == n_pes) {
00058 CmiAbort ("RotateLB: no available processors!");
00059 }
00060
00061
00062 for (obj = 0; obj < stats->n_objs; obj++) {
00063 odata = &(stats->objData[obj]);
00064 if (odata->migratable) {
00065 dest = ((stats->from_proc[obj] + 1) % n_pes);
00066 while ((!stats->procs[dest].available) &&
00067 (dest != stats->from_proc[obj])) {
00068 dest = ((dest + 1) % n_pes);
00069 }
00070 if (dest != stats->from_proc[obj]) {
00071 stats->to_proc[obj] = dest;
00072
00073 }
00074 }
00075 }
00076 }
00077
00078
00079 #include "RotateLB.def.h"