00001 00005 00006 #ifndef _NEIGHBORCOMMLB_H_ 00007 #define _NEIGHBORCOMMLB_H_ 00008 00009 #include <math.h> 00010 00011 #include "NborBaseLB.h" 00012 #include "NeighborCommLB.decl.h" 00013 00014 void CreateNeighborCommLB(); 00015 00016 class NeighborCommLB : public CBase_NeighborCommLB { 00017 public: 00018 NeighborCommLB(const CkLBOptions &); 00019 NeighborCommLB(CkMigrateMessage *m):CBase_NeighborCommLB(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 /* _NeighborCommLB_H_ */ 00049