16 #include "TopoManager.h"
17 extern TopoManager *topoMgr;
24 PeList::PeList(
int boxX,
int boxY,
int boxZ,
int order,
int maxX,
int maxY,
int maxZ,
int maxT)
26 if(config.torusMap==1)
28 CkAssert(topoMgr!=NULL);
34 size=config.numPesPerInstance;
36 CkPrintf(
"Ordering processors along long axis %d in %d X %d X %d\n",order, maxX, maxY, maxZ);
37 TheList=
new int[size];
38 sortIdx=
new int[size];
42 for(
int x=0; x<maxX; x+=boxX)
43 for(
int y=0; y<maxY; y+=boxY)
44 for(
int z=0; z<maxZ; z+=boxZ)
49 for(
int bx=0;bx<boxX;bx++)
50 for(
int by=0;by<boxY;by++)
51 for(
int bz=0;bz<boxZ;bz++)
52 for(
int bt=0;bt<maxT;bt++)
56 TheList[i++]=topoMgr->coordinatesToRank(bx+x, by+y, bz+z, bt);
62 for(
int y=0; y<maxY; y+=boxY)
63 for(
int x=0; x<maxX; x+=boxX)
64 for(
int z=0; z<maxZ; z+=boxZ)
70 for(
int by=0;by<boxY;by++)
71 for(
int bz=0;bz<boxZ;bz++)
72 for(
int bx=0;bx<boxX;bx++)
73 for(
int bt=0;bt<maxT;bt++)
76 TheList[i++]=topoMgr->coordinatesToRank(bx+x, by+y, bz+z, bt);
83 for(
int z=0; z<maxZ; z+=boxZ)
84 for(
int x=0; x<maxX; x+=boxX)
85 for(
int y=0; y<maxY; y+=boxY)
89 for(
int bz=0;bz<boxZ;bz++)
90 for(
int by=0;by<boxY;by++)
91 for(
int bx=0;bx<boxX;bx++)
92 for(
int bt=0;bt<maxT;bt++)
95 TheList[i++]=topoMgr->coordinatesToRank(bx+x, by+y, bz+z, bt);
102 CkAbort(
"unknown order");
106 int end=numBoxes*boxX*boxY*boxZ;
108 if(i<config.numPesPerInstance)
110 PeList remainder(config.numPesPerInstance);
111 for(
int i=0; i< size;i++)
115 if(remainder.TheList[j]==TheList[i])
117 CkPrintf(
"IF %d %d %d %d %d\n", i, j, size, TheList[j], TheList[i]);
122 CkPrintf(
"ELSE %d %d %d %d %d\n", i, j, size, TheList[j], TheList[i]);
129 for(; i< remainder.size ; i++)
131 TheList[i+end]=remainder.TheList[i];
132 sortIdx[i+end]=i+end;
137 CkAbort(
"You shouldn't be calling this function\n");
145 size=config.numPesPerInstance;
146 TheList=
new int[size+1];
147 sortIdx=
new int[size+1];
148 for(
int i=0;i<size;i++)
156 void PeList::rebuild()
160 size=config.numPesPerInstance;
161 for(
int i=0;i<size;i++)
170 int *PeList::pelower_bound(
int pe)
172 return(std::lower_bound(&TheList[0],&TheList[size],pe));
174 bool PeList::binsearch(
int pe)
176 return(std::binary_search(&TheList[0],&TheList[size],pe));
179 void PeList::sortSource(
int srcPe)
181 if(config.torusMap==1)
186 CkAssert(srcPe<config.numPes);
187 topoMgr->sortRanksByHops(srcPe, TheList, sortIdx, size);
194 CkVec <int> sortme(size);
195 CmiMemcpy(sortme.getVec(), TheList,size*
sizeof(int));
197 CmiMemcpy(TheList, sortme.getVec(), size*
sizeof(int));
203 if(config.torusMap==1)
204 return(TheList[topoMgr->pickClosestRank(srcPe, TheList, size)]);
210 int PeList::findNext()
213 if(config.torusMap==1) {
219 CkAssert(current<size);
220 CkAssert(sortIdx[current]<size);
221 value=TheList[sortIdx[current]];
226 value=TheList[current];
int minDist(int source)
return a processor at minumum distance from source
Author: Eric J Bohm Date Created: May 31, 2006.