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 #if CONVERSE_VERSION_VMI
00043 extern "C" int CmiGetCluster (int process);
00044 #endif
00045
00046 void CreateGridMetisLB ();
00047
00048 class PE_Data_T
00049 {
00050 public:
00051 CmiBool available;
00052 int cluster;
00053 int num_objs;
00054 double relative_speed;
00055 double scaled_load;
00056 };
00057
00058 class Object_Data_T
00059 {
00060 public:
00061 CmiBool migratable;
00062 int cluster;
00063 int from_pe;
00064 int to_pe;
00065 double load;
00066 int secondary_index;
00067 };
00068
00069 class Cluster_Data_T
00070 {
00071 public:
00072 int num_pes;
00073 double total_cpu_power;
00074 double scaled_cpu_power;
00075 };
00076
00077 class GridMetisLB : public CentralLB
00078 {
00079 public:
00080 GridMetisLB (const CkLBOptions &);
00081 GridMetisLB (CkMigrateMessage *msg);
00082
00083 CmiBool QueryBalanceNow (int step);
00084 void work (LDStats *stats);
00085 void pup (PUP::er &p) { CentralLB::pup (p); }
00086
00087 private:
00088 int Get_Cluster (int pe);
00089 void Initialize_PE_Data (CentralLB::LDStats *stats);
00090 int Available_PE_Count ();
00091 int Compute_Number_Of_Clusters ();
00092 void Initialize_Object_Data (CentralLB::LDStats *stats);
00093 void Initialize_Cluster_Data ();
00094 void Partition_Objects_Into_Clusters (CentralLB::LDStats *stats);
00095 void Partition_ClusterObjects_Into_PEs (CentralLB::LDStats *stats, int cluster);
00096
00097 int CK_LDB_GridMetisLB_Mode;
00098 int CK_LDB_GridMetisLB_Background_Load;
00099
00100 int Num_PEs;
00101 int Num_Objects;
00102 int Num_Clusters;
00103 PE_Data_T *PE_Data;
00104 Object_Data_T *Object_Data;
00105 Cluster_Data_T *Cluster_Data;
00106 };
00107
00108 #endif