00001 00005 00006 #ifndef _NEIGHBORLB_H_ 00007 #define _NEIGHBORLB_H_ 00008 00009 #include <math.h> 00010 00011 #include "NborBaseLB.h" 00012 #include "NeighborLB.decl.h" 00013 00014 void CreateNeighborLB(); 00015 00016 class NeighborLB : public CBase_NeighborLB { 00017 public: 00018 NeighborLB(const CkLBOptions &); 00019 NeighborLB(CkMigrateMessage *m):CBase_NeighborLB(m) {} 00020 private: 00021 bool QueryBalanceNow(int step) { return true; }; 00022 virtual int max_neighbors() { 00023 return (CkNumPes() > 5) ? 4 : (CkNumPes()-1); 00024 }; 00025 virtual int num_neighbors() { 00026 return (CkNumPes() > 5) ? 4 : (CkNumPes()-1); 00027 }; 00028 virtual void neighbors(int* _n) { 00029 const int me = CkMyPe(); 00030 const int npe = CkNumPes(); 00031 if (npe > 1) 00032 _n[0] = (me + npe - 1) % npe; 00033 if (npe > 2) 00034 _n[1] = (me + 1) % npe; 00035 00036 int bigstep = (npe - 1) / 3 + 1; 00037 if (bigstep == 1) bigstep++; 00038 00039 if (npe > 3) 00040 _n[2] = (me + bigstep) % npe; 00041 if (npe > 4) 00042 _n[3] = (me + npe - bigstep) % npe; 00043 }; 00044 00045 LBMigrateMsg* Strategy(NborBaseLB::LDStats* stats, int n_nbrs); 00046 }; 00047 00048 #endif /* _NeighborLB_H_ */ 00049