00001 #ifndef _GRIDCOMMLB_H_ 00002 #define _GRIDCOMMLB_H_ 00003 00004 #include <limits.h> 00005 #include <math.h> 00006 #include "CentralLB.h" 00007 00008 #define CK_LDB_GRIDCOMMLB_MODE 0 00009 #define CK_LDB_GRIDCOMMLB_BACKGROUND_LOAD 1 00010 #define CK_LDB_GRIDCOMMLB_LOAD_TOLERANCE 0.10 00011 00012 #ifndef MAXINT 00013 #define MAXINT 2147483647 00014 #endif 00015 00016 #ifndef MAXDOUBLE 00017 #define MAXDOUBLE 1e10 00018 #endif 00019 00020 void CreateGridCommLB (); 00021 00022 class PE_Data_T 00023 { 00024 public: 00025 bool available; 00026 int cluster; 00027 int num_objs; 00028 int num_lan_objs; 00029 int num_lan_msgs; 00030 int num_wan_objs; 00031 int num_wan_msgs; 00032 double relative_speed; 00033 double scaled_load; 00034 }; 00035 00036 class Object_Data_T 00037 { 00038 public: 00039 bool migratable; 00040 int cluster; 00041 int from_pe; 00042 int to_pe; 00043 int num_lan_msgs; 00044 int num_wan_msgs; 00045 double load; 00046 }; 00047 00048 class GridCommLB : public CBase_GridCommLB 00049 { 00050 public: 00051 GridCommLB (const CkLBOptions &); 00052 GridCommLB (CkMigrateMessage *msg); 00053 00054 bool QueryBalanceNow (int step); 00055 void work (LDStats *stats); 00056 void pup (PUP::er &p) { } 00057 00058 private: 00059 int Get_Cluster (int pe); 00060 void Initialize_PE_Data (CentralLB::LDStats *stats); 00061 int Available_PE_Count (); 00062 int Compute_Number_Of_Clusters (); 00063 void Initialize_Object_Data (CentralLB::LDStats *stats); 00064 void Examine_InterObject_Messages (CentralLB::LDStats *stats); 00065 void Map_NonMigratable_Objects_To_PEs (); 00066 void Map_Migratable_Objects_To_PEs (int cluster); 00067 int Find_Maximum_Object (int cluster); 00068 int Find_Minimum_PE (int cluster); 00069 void Assign_Object_To_PE (int target_object, int target_pe); 00070 00071 int CK_LDB_GridCommLB_Mode; 00072 int CK_LDB_GridCommLB_Background_Load; 00073 double CK_LDB_GridCommLB_Load_Tolerance; 00074 00075 int Num_PEs; 00076 int Num_Objects; 00077 int Num_Clusters; 00078 PE_Data_T *PE_Data; 00079 Object_Data_T *Object_Data; 00080 }; 00081 00082 #endif