00001 #ifndef _GRIDHYBRIDSEEDLB_H_
00002 #define _GRIDHYBRIDSEEDLB_H_
00003
00004 #include "CentralLB.h"
00005
00006 #define CK_LDB_GRIDHYBRIDSEEDLB_MODE 0
00007 #define CK_LDB_GRIDHYBRIDSEEDLB_BACKGROUND_LOAD 1
00008 #define CK_LDB_GRIDHYBRIDSEEDLB_LOAD_TOLERANCE 0.10
00009
00010 #ifndef MAXINT
00011 #define MAXINT 2147483647
00012 #endif
00013
00014 #ifndef MAXDOUBLE
00015 #define MAXDOUBLE 1e10
00016 #endif
00017
00018 extern "C" void METIS_PartGraphRecursive (int*, int*, int*, int*, int*, int*,
00019 int*, int*, int*, int*, int*);
00020
00021 extern "C" void METIS_PartGraphKway (int*, int*, int*, int*, int*, int*,
00022 int*, int*, int*, int*, int*);
00023
00024 extern "C" void METIS_PartGraphVKway (int*, int*, int*, int*, int*, int*,
00025 int*, int*, int*, int*, int*);
00026
00027 extern "C" void METIS_WPartGraphRecursive (int*, int*, int*, int*,
00028 int*, int*, int*, int*,
00029 float*, int*, int*, int*);
00030
00031 extern "C" void METIS_WPartGraphKway (int*, int*, int*, int*,
00032 int*, int*, int*, int*,
00033 float*, int*, int*, int*);
00034
00035 extern "C" void METIS_mCPartGraphRecursive (int*, int*, int*, int*,
00036 int*, int*, int*, int*,
00037 int*, int*, int*, int*);
00038
00039 extern "C" void METIS_mCPartGraphKway (int*, int*, int*, int*, int*,
00040 int*, int*, int*, int*, int*,
00041 int*, int*, int*);
00042
00043 void CreateGridHybridSeedLB ();
00044
00045 class PE_Data_T
00046 {
00047 public:
00048 bool available;
00049 int cluster;
00050 int num_objs;
00051 int num_lan_objs;
00052 int num_lan_msgs;
00053 int num_wan_objs;
00054 int num_wan_msgs;
00055 double relative_speed;
00056 double scaled_load;
00057 };
00058
00059 class Object_Data_T
00060 {
00061 public:
00062 bool migratable;
00063 int cluster;
00064 int from_pe;
00065 int to_pe;
00066 int num_lan_msgs;
00067 int num_wan_msgs;
00068 double load;
00069 int secondary_index;
00070 };
00071
00072 class Cluster_Data_T
00073 {
00074 public:
00075 int num_pes;
00076 double total_cpu_power;
00077 double scaled_cpu_power;
00078 };
00079
00080 class GridHybridSeedLB : public CBase_GridHybridSeedLB
00081 {
00082 public:
00083 GridHybridSeedLB (const CkLBOptions &opt);
00084 GridHybridSeedLB (CkMigrateMessage *msg);
00085
00086 bool QueryBalanceNow (int step);
00087 void work (LDStats *stats);
00088 void pup (PUP::er &p) { }
00089
00090 private:
00091 int Get_Cluster (int pe);
00092 void Initialize_PE_Data (CentralLB::LDStats *stats);
00093 int Available_PE_Count ();
00094 int Compute_Number_Of_Clusters ();
00095 void Initialize_Object_Data (CentralLB::LDStats *stats);
00096 int Compute_Migratable_Object_Count ();
00097 void Initialize_Cluster_Data ();
00098 void Initialize_Communication_Matrix (CentralLB::LDStats *stats);
00099 void Partition_Objects_Into_Clusters (CentralLB::LDStats *stats);
00100 void Examine_InterObject_Messages (CentralLB::LDStats *stats);
00101 void Map_NonMigratable_Objects_To_PEs ();
00102 int Find_Maximum_Object (int cluster);
00103 int Find_Maximum_Border_Object (int cluster);
00104 int Find_Maximum_Object_From_Seeds (int pe);
00105 int Find_Maximum_Border_Object_From_Seeds (int pe);
00106 int Compute_Communication_Events (int obj1, int obj2);
00107 int Find_Minimum_PE (int cluster);
00108 void Assign_Object_To_PE (int target_object, int target_pe);
00109
00110 int CK_LDB_GridHybridSeedLB_Mode;
00111 int CK_LDB_GridHybridSeedLB_Background_Load;
00112 double CK_LDB_GridHybridSeedLB_Load_Tolerance;
00113
00114 int Num_PEs;
00115 int Num_Objects;
00116 int Num_Migratable_Objects;
00117 int Num_Clusters;
00118 PE_Data_T *PE_Data;
00119 Object_Data_T *Object_Data;
00120 Cluster_Data_T *Cluster_Data;
00121 int *Migratable_Objects;
00122 int **Communication_Matrix;
00123 };
00124
00125 #endif