Coverage Report

Created: 2026-11-08 13:02

/home/runner/work/charm/charm/src/ck-ldb/DistributedLB.h
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * Author: gplkrsh2@illinois.edu (Harshitha Menon)
3
 *
4
 * A distributed load balancer which consists of two phases.
5
 * 1. Information propagation
6
 * 2. Probabilistic transfer of load
7
 *
8
 * Information propagation is done using Gossip protocol where the information
9
 * about the underloaded processors in the system is spread to the overloaded
10
 * processors.
11
 * Once the overloaded processors receive the partial information about the
12
 * underloaded processors in the system, it does probabilistic load transfer.
13
 * The probability of a PE receiving load is inversely proportional to its
14
 * current load.
15
*/
16
17
#ifndef _DISTLB_H_
18
#define _DISTLB_H_
19
20
#include "DistBaseLB.h"
21
#include "DistributedLB.decl.h"
22
23
#include "ckheap.h"
24
25
#include <vector>
26
27
void CreateDistributedLB();
28
29
class DistributedLB : public CBase_DistributedLB {
30
public:
31
  DistributedLB(const CkLBOptions &);
32
  DistributedLB(CkMigrateMessage *m);
33
  static void initnodeFn(void);
34
35
  void GossipLoadInfo(int, int, int[], double[]);
36
  void LoadReduction(CkReductionMsg* msg);
37
  void AfterLBReduction(CkReductionMsg* msg);
38
  void DoneGossip();
39
  void InformMigration(int obj_id, int from_pe, double obj_load, bool force);
40
  void RecvAck(int obj_id, int assigned_pe, bool can_accept);
41
42
private:
43
  // Load information obtained via gossipping
44
  int underloaded_pe_count;
45
  std::vector<int> pe_no;
46
  std::vector<double> loads;
47
  std::vector<double> distribution;
48
  bool underloaded;
49
50
  minHeap* objs;
51
52
  int total_migrates_ack;
53
  int total_migrates;
54
  std::vector<MigrateInfo*> migrateInfo;
55
56
  // Constant variables for configuring how the strategy works
57
  bool kUseAck;
58
  int kPartialInfoCount;
59
  int kMaxTrials;
60
  int kMaxGossipMsgCount;
61
  int kMaxObjPickTrials;
62
  int kMaxPhases;
63
  double kTargetRatio;
64
65
  // Global stats about the load gather from reductions
66
  double avg_load;
67
  double max_load;
68
  double load_ratio;
69
70
  // Information about this PEs load
71
  double my_load;
72
  double init_load;
73
  double b_load;
74
  double b_load_per_obj;
75
76
  // Control flow variables
77
  bool lb_started;
78
  int phase_number;
79
  int gossip_msg_count;
80
  int objs_count;
81
  int negack_count;
82
  double transfer_threshold;
83
84
  double start_time;
85
86
  const DistBaseLB::LDStats* my_stats;
87
88
  void InitLB(const CkLBOptions &);
89
  void SendLoadInfo();
90
  void LoadBalance();
91
  void MapObjsToPe(minHeap *objs, std::vector<int> &obj_no, std::vector<int> &obj_pe_no);
92
  int PickRandReceiverPeIdx() const;
93
  void CalculateCumulateDistribution();
94
  void Strategy(const DistBaseLB::LDStats* const stats);
95
  void Setup();
96
  void Cleanup();
97
  void PackAndSendMigrateMsgs();
98
  void StartNextLBPhase();
99
  void DoneWithLBPhase();
100
101
  // TODO: Should this use the lb_started flag?
102
0
  bool QueryBalanceNow(int step) { return true; };
103
};
104
105
#endif /* _DistributedLB_H_ */