7 * Author: jjgalvez@illinois.edu (Juan Galvez)
8 * Greedy algorithm to minimize cpu max_load and object migrations.
9 * Can find solution equal or close to regular Greedy with less (sometimes much less) migrations.
10 * The amount of migrations that the user can tolerate is passed via the command-line
11 * option +LBNumMoves (as percentage of chares that can be moved).
13 * If LBNumMoves is not passed, strategy assumes it can move all objects.
14 * In this case, the algorithm will give preference to minimizing cpu max_load.
15 * It will still move less than greedy, but the amount of migrations
16 * will depend very much on the particular case (object load distribution and processor background loads),
18 * supports processor avail bitvector
19 * supports nonmigratable attrib
23 #ifndef _GREEDY_REFINE_LB_H_
24 #define _GREEDY_REFINE_LB_H_
26 #include "CentralLB.h"
27 #include "GreedyRefineLB.decl.h"
29 void CreateGreedyRefineLB();
30 BaseLB
*AllocateGreedyRefineLB();
32 #define __DEBUG_GREEDY_REFINE_ 0
34 class GreedyRefineLB
: public CBase_GreedyRefineLB
{
36 GreedyRefineLB(const CkLBOptions
&);
37 GreedyRefineLB(CkMigrateMessage
*m
);
38 void work(LDStats
* stats
);
39 void receiveSolutions(CkReductionMsg
*msg
);
40 void receiveTotalTime(double time
);
41 void setMigrationTolerance(float tol
) { migrationTolerance
= tol
; }
44 bool QueryBalanceNow(int step
) { return true; }
48 GProc() : available(true), load(0) {}
51 int pos
; // position in min heap
53 double bgload
; // background load
64 class ObjLoadGreater
{
66 inline bool operator() (const GObj
*o1
, const GObj
*o2
) const {
67 return (o1
->load
> o2
->load
);
74 double fillData(LDStats
*stats
,
75 std::vector
<GObj
> &objs
,
76 std::vector
<GObj
*> &pobjs
,
77 std::vector
<GProc
> &procs
,
80 double greedyLB(const std::vector
<GObj
*> &pobjs
, PHeap
&procHeap
, const BaseLB::LDStats
*stats
) const;
81 void sendSolution(double maxLoad
, int migrations
);
83 double strategyStartTime
;
86 float migrationTolerance
;
89 #if __DEBUG_GREEDY_REFINE_
90 void dumpObjLoads(std::vector
<GObj
> &objs
);
91 void dumpProcLoads(std::vector
<GProc
> &procs
);