17 #define SHRINK_INNER_BRICK 1
20 int npas,
int npes) :
RefineTorusLB(cs, pas, pes, ncs, npas, npes, 0)
35 void TorusLB::strategy() {
43 const int endGroup = beginGroup +
P;
44 #define INGROUP(PROC) ((PROC) >= beginGroup && (PROC) < endGroup)
57 if(!c) CkAbort(
"TorusLB: Compute Heap empty!\n");
59 for(
int j=0; j<6; j++) {
68 #define SELECT_REALPE(X) if INGROUP((X)) { \
69 selectPes(&processors[(X) - beginGroup], c); \
75 const
int realPe2 =
patches[c->patch2].processor;
76 if ( realPe2 != realPe1 ) {
89 if INGROUP(p->Id) selectPes(p, c);
125 if ( CmiNumNodes() > 1 ) {
128 int realNode1 = CmiNodeOf(realPe1);
129 int nodeSize = CmiNodeSize(realNode1);
130 if ( nodeSize > 1 ) {
131 int firstpe = CmiNodeFirst(realNode1);
132 for (
int rpe = firstpe; rpe < firstpe+nodeSize; ++rpe ) {
135 if ( p->available && ( p->load + c->load < minLoad ) ) {
136 minLoad = p->
load + c->load;
142 if ( realPe2 != realPe1 ) {
143 int realNode2 = CmiNodeOf(realPe2);
144 if ( realNode2 != realNode1 ) {
145 nodeSize = CmiNodeSize(realNode2);
146 if ( nodeSize > 1 ) {
147 int firstpe = CmiNodeFirst(realNode2);
148 for (
int rpe = firstpe; rpe < firstpe+nodeSize; ++rpe ) {
151 if ( p->available && ( p->load + c->load < minLoad ) ) {
152 minLoad = p->
load + c->load;
167 if ( ( CmiNumPhysicalNodes() > 1 ) &&
168 ( CmiNumPhysicalNodes() < CmiNumNodes() ) ) {
171 int realNode1 = CmiPhysicalNodeID(realPe1);
174 CmiGetPesOnPhysicalNode(realNode1, &rpelist, &nodeSize);
175 if ( nodeSize > 1 ) {
176 for (
int ipe = 0; ipe < nodeSize; ++ipe ) {
177 int rpe = rpelist[ipe];
180 if ( p->available && ( p->load + c->load < minLoad ) ) {
181 minLoad = p->
load + c->load;
187 if ( realPe2 != realPe1 ) {
188 int realNode2 = CmiPhysicalNodeID(realPe2);
189 if ( realNode2 != realNode1 ) {
190 CmiGetPesOnPhysicalNode(realNode2, &rpelist, &nodeSize);
191 if ( nodeSize > 1 ) {
192 for (
int ipe = 0; ipe < nodeSize; ++ipe ) {
193 int rpe = rpelist[ipe];
196 if ( p->available && ( p->load + c->load < minLoad ) ) {
197 minLoad = p->
load + c->load;
216 int p1, p2, pe, x1, x2, xm, xM, y1, y2, ym, yM, z1, z2, zm, zM, t1, t2;
217 int dimNX, dimNY, dimNZ, dimNT;
222 tmgr.rankToCoordinates(p1, x1, y1, z1, t1);
223 tmgr.rankToCoordinates(p2, x2, y2, z2, t2);
224 dimNX = tmgr.getDimNX();
225 dimNY = tmgr.getDimNY();
226 dimNZ = tmgr.getDimNZ();
227 dimNT = tmgr.getDimNT();
248 for(
int i=xm; i<=xM; i++)
249 for(
int j=ym; j<=yM; j++)
250 for(
int k=zm; k<=zM; k++)
251 for(
int l=0; l<dimNT; l++)
253 pe = tmgr.coordinatesToRank(i%dimNX, j%dimNY, k%dimNZ, l);
256 if(c->load + p->load < minLoad) {
257 minLoad = c->
load + p->load;
268 for(
int i=xM+1; i<xm+dimNX; i++)
269 for(
int j=0; j<dimNY; j++)
270 for(
int k=0; k<dimNZ; k++)
271 for(
int l=0; l<dimNT; l++)
273 pe = tmgr.coordinatesToRank(i%dimNX, j%dimNY, k%dimNZ, l);
276 if(c->load + p->load < minLoad) {
284 for(
int j=yM+1; j<ym+dimNY; j++)
285 for(
int i=xm; i<=xM; i++)
286 for(
int k=0; k<dimNZ; k++)
287 for(
int l=0; l<dimNT; l++)
289 pe = tmgr.coordinatesToRank(i%dimNX, j%dimNY, k%dimNZ, l);
292 if(c->load + p->load < minLoad) {
300 for(
int k=zM+1; k<zm+dimNZ; k++)
301 for(
int i=xm; i<=xM; i++)
302 for(
int j=ym; j<=yM; j++)
303 for(
int l=0; l<dimNT; l++)
305 pe = tmgr.coordinatesToRank(i%dimNX, j%dimNY, k%dimNZ, l);
308 if(c->load + p->load < minLoad) {
377 CkPrintf(
"TorusLB: No receiver found average %f overload %f\n", averageLoad,
overLoad);
378 CkAbort(
"TorusLB: No receiver found\n");
397 index = (numEither*(numEither+1))/2 +
numProxies;
401 int p1, p2, pe, x1, x2, xm, xM, y1, y2, ym, yM, z1, z2, zm, zM, t1, t2;
402 int dimNX, dimNY, dimNZ, dimNT;
407 tmgr.rankToCoordinates(p1, x1, y1, z1, t1);
408 tmgr.rankToCoordinates(p2, x2, y2, z2, t2);
409 dimNX = tmgr.getDimNX();
410 dimNY = tmgr.getDimNY();
411 dimNZ = tmgr.getDimNZ();
412 dimNT = tmgr.getDimNT();
422 tmgr.rankToCoordinates(p->
Id, x, y, z, t);
423 int wB =
withinBrick(x, y, z, xm, xM, dimNX, ym, yM, dimNY, zm, zM, dimNZ);
429 if (!(oldp) || p->
load < oldp->
load )
435 double loadDiff = 0.0;
444 if ((loadDiff > 0.4) || (loadDiff > 0.0 && (tmgr.getHopsBetweenRanks(p->
Id, p1) +
445 tmgr.getHopsBetweenRanks(p->
Id, p2) < tmgr.getHopsBetweenRanks(oldp->
Id, p1) +
446 tmgr.getHopsBetweenRanks(oldp->
Id, p2)))) {
457 if (!(oldp) || p->
load < oldp->
load )
void assign(computeInfo *c, processorInfo *pRec)
if(ComputeNonbondedUtil::goMethod==2)
TorusLB(computeInfo *cs, patchInfo *pas, processorInfo *pes, int ncs, int npas, int npes)
processorInfo * processors
void printLoads(int phase=0)
void numAvailable(computeInfo *c, processorInfo *p, int *nPatches, int *nProxies, int *isBadForCommunication)
static Units next(Units u)
InfoRecord * next(heapIterator *)
maxHeap * computeSelfHeap
maxHeap * computePairHeap
int withinBrick(int x, int y, int z, int xm, int xM, int dimX, int ym, int yM, int dimY, int zm, int zM, int dimZ)
void brickDim(int a, int b, int dim, int &min, int &max)
InfoRecord * iterator(heapIterator *)
#define SHRINK_INNER_BRICK
InfoRecord * iterator(Iterator *)
const char * strategyName