00001 #ifndef _GRIDMETISLB_H_
00002 #define _GRIDMETISLB_H_
00003
00004 #include "CentralLB.h"
00005
00006 #define CK_LDB_GRIDMETISLB_MODE 0
00007 #define CK_LDB_GRIDMETISLB_BACKGROUND_LOAD 1
00008
00009 #ifndef MAXINT
00010 #define MAXINT 2147483647
00011 #endif
00012
00013 #ifndef MAXDOUBLE
00014 #define MAXDOUBLE 1e10
00015 #endif
00016
00017 extern "C" void METIS_PartGraphRecursive (int*, int*, int*, int*, int*, int*,
00018 int*, int*, int*, int*, int*);
00019
00020 extern "C" void METIS_PartGraphKway (int*, int*, int*, int*, int*, int*,
00021 int*, int*, int*, int*, int*);
00022
00023 extern "C" void METIS_PartGraphVKway (int*, int*, int*, int*, int*, int*,
00024 int*, int*, int*, int*, int*);
00025
00026 extern "C" void METIS_WPartGraphRecursive (int*, int*, int*, int*,
00027 int*, int*, int*, int*,
00028 float*, int*, int*, int*);
00029
00030 extern "C" void METIS_WPartGraphKway (int*, int*, int*, int*,
00031 int*, int*, int*, int*,
00032 float*, int*, int*, int*);
00033
00034 extern "C" void METIS_mCPartGraphRecursive (int*, int*, int*, int*,
00035 int*, int*, int*, int*,
00036 int*, int*, int*, int*);
00037
00038 extern "C" void METIS_mCPartGraphKway (int*, int*, int*, int*, int*,
00039 int*, int*, int*, int*, int*,
00040 int*, int*, int*);
00041
00042 void CreateGridMetisLB ();
00043
00044 class PE_Data_T
00045 {
00046 public:
00047 bool available;
00048 int cluster;
00049 int num_objs;
00050 double relative_speed;
00051 double scaled_load;
00052 };
00053
00054 class Object_Data_T
00055 {
00056 public:
00057 bool migratable;
00058 int cluster;
00059 int from_pe;
00060 int to_pe;
00061 double load;
00062 int secondary_index;
00063 };
00064
00065 class Cluster_Data_T
00066 {
00067 public:
00068 int num_pes;
00069 double total_cpu_power;
00070 double scaled_cpu_power;
00071 };
00072
00073 class GridMetisLB : public CBase_GridMetisLB
00074 {
00075 public:
00076 GridMetisLB (const CkLBOptions &);
00077 GridMetisLB (CkMigrateMessage *msg);
00078
00079 bool QueryBalanceNow (int step);
00080 void work (LDStats *stats);
00081 void pup (PUP::er &p) { }
00082
00083 private:
00084 int Get_Cluster (int pe);
00085 void Initialize_PE_Data (CentralLB::LDStats *stats);
00086 int Available_PE_Count ();
00087 int Compute_Number_Of_Clusters ();
00088 void Initialize_Object_Data (CentralLB::LDStats *stats);
00089 void Initialize_Cluster_Data ();
00090 void Partition_Objects_Into_Clusters (CentralLB::LDStats *stats);
00091 void Partition_ClusterObjects_Into_PEs (CentralLB::LDStats *stats, int cluster);
00092
00093 int CK_LDB_GridMetisLB_Mode;
00094 int CK_LDB_GridMetisLB_Background_Load;
00095
00096 int Num_PEs;
00097 int Num_Objects;
00098 int Num_Clusters;
00099 PE_Data_T *PE_Data;
00100 Object_Data_T *Object_Data;
00101 Cluster_Data_T *Cluster_Data;
00102 };
00103
00104 #endif