Subsections

3.12 Advanced Load Balancing

3.12.1 Write a Measurement-based Object Migration Strategy

Charm++ programmers can pick load balancing strategy from Charm++'s built-in strategies(see 3.11.2) for the best performance based on the characteristics of their applications, they can also choose to write their own load balancing strategies.

Charm++ load balancing framework provides a simple scheme to incorporate new load balancing strategies. To write a new load balancing strategy involves the following steps (We use an example of writing a centralized load balancer fooLB to illustrate the steps).

  1. Create files named fooLB.ci, fooLB.h and fooLB.C. One can choose to copy and rename the files RandCentLB (a random centralized load balancer) and rename the class name in those files.

  2. Implement the fooLB class method -- fooLB::work(CentralLB::LDStats* stats, int count) This method takes the load balancing database (stats) as an input, and output the new mapping of objects to processors in stats->to_proc array.

  3. To compile the strategy files, first add fooLB into the load balancer list in charm/tmp/Makefile_lb.sh. Run the script in charm/tmp, which creates the new Makefile namded ``Make.lb''.

  4. Run ``make depends'' to update dependence rule of Charm++ files. And run ``make charm++'' to compile Charm++ which includes the new load balancing strategy files.

3.12.2 Understand Load Balancing Database Data Structure

To write a load balancing strategy, one may want to know what information is measured during the runtime and how it is represented in the load balancing database data structure?

There are mainly 3 categories of information: a) processor information including processor speed, background load; b) object information including per object cpu/wallclock compute time and c) communication information .

The database data structure named LDStats is defined in CentralLB.h:

  struct ProcStats {  // per processor
    double total_walltime;
    double total_cputime;
    double idletime;
    double bg_walltime;
    double bg_cputime;
    int pe_speed;
    double utilization;
    CmiBool available;
    int   n_objs;
  }

  struct LDStats { // load balancing database
    ProcStats  *procs;
    int count;

    int   n_objs;
    int   n_migrateobjs;
    LDObjData* objData;

    int   n_comm;
    LDCommData* commData;

    int  *from_proc, *to_proc;
  }

  1. procs array defines processor attributes and usage data for each processor;
  2. objData array records per object information, LDObjData is defined in lbdb.h;
  3. commData array records per communication information. LDCommData is defined in lbdb.h.

August 04, 2008
Charm Homepage