void TraceBluegene::bgPrint(const char* str){ if (CmiMemoryIs(CMI_MEMORY_IS_ISOMALLOC)) CmiDisableIsomalloc(); double curT = BgGetTime(); if (genTimeLog) bgAddProjEvent(strdup(str), -1, curT, writeData, this, BG_EVENT_PRINT); CmiPrintf(str, curT); if (CmiMemoryIs(CMI_MEMORY_IS_ISOMALLOC)) CmiEnableIsomalloc(); }
/* Handler: reduce */ void reduce(char *info) { UserData* ud = (UserData*)BgGetNodeData(); EnergyMsg* energyMsg = (EnergyMsg*)info; ud->lmdData->systemKinEnergy += energyMsg->kinEnergy ; ud->lmdData->systemPotEnergy += energyMsg->potEnergy ; ud->lmdData->numberOfCellsDone++ ; // CmiPrintf("done: %d %d\n", ud->lmdData->numberOfCellsDone, ud->spData->total_cells); if(ud->lmdData->numberOfCellsDone == ud->spData->total_cells) { ud->lmdData->numberOfCellsDone = 0; ud->lmdData->systemStepsCompleted++ ; PrintStep(ud->lmdData->systemStepsCompleted, ud->lmdData->systemPotEnergy, ud->lmdData->systemKinEnergy); ud->lmdData->systemPotEnergy = ud->lmdData->systemKinEnergy = 0.0; if (ud->lmdData->systemStepsCompleted >= ud->spData->steps) { CmiPrintf("TIMING: %fs/step\n", (BgGetTime()-startTime)/ud->spData->steps); BgShutdown(); } /* start next step */ int sX, sY, sZ; BgGetSize(&sX, &sY, &sZ); // new StepMsg once and reuse it for (int i=0; i<sX; i++) for (int j=0; j<sY; j++) for (int k=0; k<sZ; k++) { StepMsg *msg = new StepMsg(ud->lmdData->systemStepsCompleted); BgSendPacket(i, j, k, ANYTHREAD, sendCoordID, LARGE_WORK, sizeof(StepMsg), (char*)msg); } } delete energyMsg; }
void sendHandler(char *info) { int x,y,z; BgGetMyXYZ(&x,&y,&z); int numBgX, numBgY, numBgZ; BgGetSize(&numBgX, &numBgY, &numBgZ); userData* ud = (userData*)BgGetNodeData(); Msg* msg = (Msg*)info; if(x==0 && y==0 && z==0) { //ckout <<"Iteration no "<<ud->iter<<endl; ud->iter++; if(ud->iter==0) ud->st = BgGetTime(); if(ud->iter==NUM_ITERATIONS) { ud->pingTime[ud->caseCount-1] = (BgGetTime() - ud->st)/NUM_ITERATIONS; if(ud->caseCount==MAX_NUM_CASES) { CmiPrintf("Pingpong time averaged over %d iterations\n",NUM_ITERATIONS); CmiPrintf("---------------------------------------------------------\n"); CmiPrintf("case Time(RRT)\n"); CmiPrintf("---------------------------------------------------------\n"); for(int i=0; i<MAX_NUM_CASES; i++) switch(i+1){ case 1: CmiPrintf("0,0,0 <--> 0,0,%d %f\n", numBgZ-1,ud->pingTime[0]); break; case 2: CmiPrintf("0,0,0 <--> %d,0,0 %f\n",numBgX-1, ud->pingTime[1]); break; case 3: CmiPrintf("0,0,0 <--> 0,%d,0 %f\n",numBgY-1, ud->pingTime[2]); break; case 4: CmiPrintf("0,0,0 <--> %d,%d,%d %f\n",numBgX-1,numBgY-1,numBgZ-1,ud->pingTime[3]); break; } CmiPrintf("---------------------------------------------------------\n"); BgShutdown(); return; } ud->caseCount++; ud->iter = 0; ud->st = BgGetTime(); } switch(ud->caseCount) { case 1: BgSendPacket(0,0,numBgZ-1, ANYTHREAD,sendID, SMALL_WORK, sizeof(Msg), (char *)msg); break; case 2: BgSendPacket(numBgX-1,0,0, ANYTHREAD,sendID, SMALL_WORK, sizeof(Msg), (char *)msg); break; case 3: BgSendPacket(0,numBgY-1,0, ANYTHREAD,sendID, SMALL_WORK, sizeof(Msg), (char *)msg); break; case 4: BgSendPacket(numBgX-1,numBgY-1,numBgZ-1, ANYTHREAD,sendID, SMALL_WORK, sizeof(Msg), (char *)msg); break; } } else BgSendPacket(0,0,0, ANYTHREAD,sendID, SMALL_WORK, sizeof(Msg), (char *)msg); }
void TraceBluegene::bgMark(char* str){ double curT = BgGetTime(); if (genTimeLog) bgAddProjEvent(strdup(str), -1, curT, writeData, this, BG_EVENT_MARK); }