Overture  Version 25
LoadBalancer.h
Go to the documentation of this file.
1 #ifndef LOAD_BALANCER_H
2 #define LOAD_BALANCER_H
3 
4 #include "Overture.h"
5 #include "GridDistribution.h"
6 
7 
9 {
10 public:
11 
13 {
16  sequentialAssignment, // grid g is placed on processor p= g % np;
17  randomAssignment, // grid g is placed in a random processor -- this is used for testing
18  allToAll, // grid g is given all processors
21 };
22 
23 
24 LoadBalancer();
26 
27 // Actually assign the load balance to the grids in the GridCollection:
28 int assignLoadBalance( GridCollection & gc, GridDistributionList & gridDistributionList,
29  int refinementLevel = 0 ) const;
30 
31 // Assign work loads for each grid based on the number of grid points
32 int assignWorkLoads( GridCollection & gc, GridDistributionList & gridDistributionList,
33  int refinementLevel = 0 ) const;
34 
35 // Assign work loads for each grid based on the number of grid points (this version takes a GridCollectionData)
36 int assignWorkLoads( GridCollectionData & gc, GridDistributionList & gridDistributionList,
37  int refinementLevel = 0 ) const;
38 
39 // main function for load balancing - determine the load balance (but do not apply)
40 int determineLoadBalance( GridDistributionList & gridDistributionList,
41  int refinementLevel = 0 ) const;
42 
43 // get the load for a gridCollection using the default work-loads based on the number of grid points
44 int determineLoadBalance( GridCollection & gc, GridDistributionList & gridDistributionList,
45  int refinementLevel = 0 ) const;
46 
47 // implementations of different load balancing algorithms:
48 int determineLoadBalanceKernighanLin( GridDistributionList & gridDistributionList,
49  int refinementLevel = 0 ) const;
50 int determineLoadBalanceUserDefined( GridDistributionList & gridDistributionList,
51  int refinementLevel = 0 ) const;
52 
55 
56 // print statistics from the load balancing
57 int printStatistics(FILE *file= NULL);
58 
59 // Specify which processors to load balance over:
60 int setProcessors(int pStart, int pEnd);
61 
62 // specify which load balancing algorithm to use:
64 
65 // set target maximum realtive load imbalance:
67 
69 
70 protected:
71 
72 // update statistics
73 int saveStatistics(GridDistributionList & gridDistributionList ) const;
74 
75 int np; // number of processors we load balance over
76 int *processorID; // list of processor id's we load balance over
77 
79 real targetMaximumLoadImbalance; // gives the target maximum relative load imbalance
80 
81 static int debug;
82 
83 // These are for statistics:
86 
87 };
88 
89 
90 #endif