// Sends transpose messages to every other chare void sendAllToAll() { for(int j=0;j<msgCount; j++) { for(int i = thisIndex; i < thisIndex+numChares; i++) { int t = i % numChares; CkSetRefNum(msgs[j*numChares+t],iter); thisProxy[t].getAllToAll(msgs[j*numChares+t]); } } }
// Send ghost faces to the six neighbors void begin_iteration(void) { if (thisIndex.x == 0 && thisIndex.y == 0 && thisIndex.z == 0) { // CkPrintf("Start of iteration %d\n", iterations); if(iterations % PRINT_FREQ == 0) { average = timing; timing = CmiWallTimer(); average = (timing - average)/(double)PRINT_FREQ; CkPrintf("time=%.2f it=%d avg=%.4f\n",timing,iterations,average); } } iterations++; // Copy different faces into messages ghostMsg *leftMsg = new (blockDimY*blockDimZ) ghostMsg(RIGHT, blockDimY, blockDimZ); ghostMsg *rightMsg = new (blockDimY*blockDimZ) ghostMsg(LEFT, blockDimY, blockDimZ); ghostMsg *topMsg = new (blockDimX*blockDimZ) ghostMsg(BOTTOM, blockDimX, blockDimZ); ghostMsg *bottomMsg = new (blockDimX*blockDimZ) ghostMsg(TOP, blockDimX, blockDimZ); ghostMsg *frontMsg = new (blockDimX*blockDimY) ghostMsg(BACK, blockDimX, blockDimY); ghostMsg *backMsg = new (blockDimX*blockDimY) ghostMsg(FRONT, blockDimX, blockDimY); CkSetRefNum(leftMsg, iterations); CkSetRefNum(rightMsg, iterations); CkSetRefNum(topMsg, iterations); CkSetRefNum(bottomMsg, iterations); CkSetRefNum(frontMsg, iterations); CkSetRefNum(backMsg, iterations); for(int j=0; j<blockDimY; ++j) for(int k=0; k<blockDimZ; ++k) { leftMsg->gh[k*blockDimY+j] = temperature[index(1, j+1, k+1)]; rightMsg->gh[k*blockDimY+j] = temperature[index(blockDimX, j+1, k+1)]; } for(int i=0; i<blockDimX; ++i) for(int k=0; k<blockDimZ; ++k) { topMsg->gh[k*blockDimX+i] = temperature[index(i+1, 1, k+1)]; bottomMsg->gh[k*blockDimX+i] = temperature[index(i+1, blockDimY, k+1)]; } for(int i=0; i<blockDimX; ++i) for(int j=0; j<blockDimY; ++j) { frontMsg->gh[j*blockDimX+i] = temperature[index(i+1, j+1, 1)]; backMsg->gh[j*blockDimX+i] = temperature[index(i+1, j+1, blockDimZ)]; } // Send my left face thisProxy(wrap_x(thisIndex.x-1), thisIndex.y, thisIndex.z).receiveGhosts(leftMsg); // Send my right face thisProxy(wrap_x(thisIndex.x+1), thisIndex.y, thisIndex.z).receiveGhosts(rightMsg); // Send my top face thisProxy(thisIndex.x, wrap_y(thisIndex.y-1), thisIndex.z).receiveGhosts(topMsg); // Send my bottom face thisProxy(thisIndex.x, wrap_y(thisIndex.y+1), thisIndex.z).receiveGhosts(bottomMsg); // Send my front face thisProxy(thisIndex.x, thisIndex.y, wrap_z(thisIndex.z-1)).receiveGhosts(frontMsg); // Send my back face thisProxy(thisIndex.x, thisIndex.y, wrap_z(thisIndex.z+1)).receiveGhosts(backMsg); }