00001
00005
00006 #ifndef _RECBISECTBFLB_H_
00007 #define _RECBISECTBFLB_H_
00008
00009 #include "CentralLB.h"
00010 #include "RecBisectBfLB.decl.h"
00011
00012 #include "ObjGraph.h"
00013 #include "graph.h"
00014 #include "bitvecset.h"
00015 #include "cklists.h"
00016
00017 typedef CkQ<int> IntQueue;
00018
00019 void CreateRecBisectBfLB();
00020 BaseLB * AllocateRecBisectBfLB();
00021
00022 typedef struct {
00023 int size;
00024 int * nodeArray;
00025 } PartitionRecord;
00026
00027
00028 typedef struct {
00029 int next;
00030 int max;
00031 PartitionRecord * partitions;
00032 } PartitionList;
00033
00034
00035 class RecBisectBfLB : public CentralLB {
00036 public:
00037 RecBisectBfLB(const CkLBOptions &);
00038 RecBisectBfLB(CkMigrateMessage *m):CentralLB(m) {}
00039 private:
00040 CmiBool QueryBalanceNow(int step);
00041 void work(LDStats* stats);
00042
00043 Graph * convertGraph(ObjGraph *og);
00044
00045 void partitionInTwo(Graph *g, int nodes[], int numNodes,
00046 int ** pp1, int *numP1, int **pp2, int *numP2,
00047 int ratio1, int ratio2);
00048 int findNextUnassigned(int max, BV_Set * all, BV_Set * s1, BV_Set * s2);
00049 float addToQ(IntQueue * q, Graph *g, BV_Set * all, BV_Set * s1, BV_Set * s2);
00050
00051 void enqChildren(IntQueue * q, Graph *g, BV_Set * all,
00052 BV_Set * s1, BV_Set * s2, int node) ;
00053
00054 void addPartition(PartitionList * partitions, int * nodes, int num) ;
00055 void printPartitions(PartitionList * partitions) ;
00056 void recursivePartition(int numParts, Graph *g, int nodes[], int numNodes,
00057 PartitionList *partitions);
00058
00059 };
00060
00061
00062
00063 #endif
00064
00065