00001
00009 #ifndef _GRIDROUTER_H
00010 #define _GRIDROUTER_H
00011
00012 #include <math.h>
00013
00014 #include "petable.h"
00015
00016 #define ROWLEN COLLEN
00017 #define RowLen(pe) ColLen(pe)
00018 #define PELISTSIZE ((ROWLEN-1)/sizeof(int)+1)
00019
00020 inline int ColLen(int npes)
00021 {
00022 int len= (int)sqrt((double)npes);
00023 if (npes > (len*len)) len++;
00024 return(len);
00025 }
00026
00027 inline int Expect(int pe, int npes)
00028 {
00029 int i, len=ColLen(npes);
00030 for (i=len-1;i>=0;i--) {
00031 int myrow=pe/len;
00032 int toprep=i*len;
00033 int offset=pe-myrow*len;
00034 if ((toprep+offset) <= (npes-1)) return(i+1);
00035 }
00036 return(len);
00037 }
00038
00039 #include "persistent.h"
00040
00041
00042 class GridRouter : public Router
00043 {
00044 private:
00045 PeTable *PeMesh, *PeMesh1, *PeMesh2;
00046 int *onerow, *gpes,
00047 *rowVector, *colVector,
00048 *growVector, *gcolVector;
00049
00050 int myrow, mycol;
00051 int rvecSize, cvecSize;
00052 int MyPe, NumPes, COLLEN;
00053 int LPMsgCount, LPMsgExpected;
00054 int recvExpected, recvCount;
00055 void InitVars();
00056 void LocalProcMsg(comID id);
00057 void sendRow(comID id);
00058
00059 public:
00060 GridRouter(int, int, Strategy*);
00061 ~GridRouter();
00062 void NumDeposits(comID, int);
00063
00064 void EachToAllMulticast(comID , int , void *, int);
00065 void EachToManyMulticast(comID , int , void *, int, int *, int);
00066 void EachToManyMulticastQ(comID id, CkQ<MessageHolder *> &msgq);
00067
00068 void RecvManyMsg(comID, char *);
00069 void ProcManyMsg(comID, char *);
00070 void DummyEP(comID id, int);
00071 void ProcMsg(int, msgstruct **) {;}
00072 void SetMap(int *);
00073 };
00074
00075 #endif
00076