00001 #ifndef _GRIDHYBRIDLB_H_ 00002 #define _GRIDHYBRIDLB_H_ 00003 00004 #include "CentralLB.h" 00005 00006 #define CK_LDB_GRIDHYBRIDLB_MODE 0 00007 #define CK_LDB_GRIDHYBRIDLB_BACKGROUND_LOAD 1 00008 #define CK_LDB_GRIDHYBRIDLB_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 CreateGridHybridLB (); 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 GridHybridLB : public CBase_GridHybridLB 00081 { 00082 public: 00083 GridHybridLB (const CkLBOptions &); 00084 GridHybridLB (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 void Initialize_Cluster_Data (); 00097 void Partition_Objects_Into_Clusters (CentralLB::LDStats *stats); 00098 void Examine_InterObject_Messages (CentralLB::LDStats *stats); 00099 void Map_NonMigratable_Objects_To_PEs (); 00100 void Map_Migratable_Objects_To_PEs (int cluster); 00101 int Find_Maximum_Object (int cluster); 00102 int Find_Minimum_PE (int cluster); 00103 void Assign_Object_To_PE (int target_object, int target_pe); 00104 00105 int CK_LDB_GridHybridLB_Mode; 00106 int CK_LDB_GridHybridLB_Background_Load; 00107 double CK_LDB_GridHybridLB_Load_Tolerance; 00108 00109 int Num_PEs; 00110 int Num_Objects; 00111 int Num_Clusters; 00112 PE_Data_T *PE_Data; 00113 Object_Data_T *Object_Data; 00114 Cluster_Data_T *Cluster_Data; 00115 }; 00116 00117 #endif