void cb_client(CkReductionMsg *msg) { endTime = CkWallTimer (); int dataSize = msg->getSize(); void *data = msg->getData(); CmiPrintf("%e\n", endTime-startTime); // check correctness int result; int redno = msg->getRedNo(); result = 0; for (int i=0; i<sectionSize; i++) result+=i; if (*(int *)data != result) { CmiPrintf("Expected: %d acual:%d\n", result, *(int *)data); CmiAbort("reduction result is wrong!"); } cnt.reductionsRemaining--; if (cnt.reductionsRemaining<=0) { CProxy_main mproxy(mid); mproxy.maindone(); cnt.reductionNo++; } else { HiMsg *hiMsg = new (2, 0) HiMsg; hiMsg->data[0] = 22; hiMsg->data[1] = 28; startTime = CkWallTimer (); mcp.SayHi(hiMsg); cnt.reductionNo++; } delete msg; }
// void cb_client(CkSectionInfo sid, void *param, int dataSize, void *data) void cb_client(CkReductionMsg *msg) { int dataSize = msg->getSize(); void *data = msg->getData(); CmiPrintf("RESULT [%d]: %d\n", cnt.reductionNo, *(int *)data); // check correctness int result; int redno = msg->getRedNo(); if (redno%3 == 0) { result = 0; for (int i=0; i<sectionSize; i++) result+=i; } else if (redno%3 == 2) { result = 1; for (int i=1; i<sectionSize+1; i++) result*=i; } else { result = sectionSize+1; } if (*(int *)data != result) { CmiPrintf("Expected: %d acual:%d\n", result, *(int *)data); CmiAbort("reduction result is wrong!"); } cnt.reductionsRemaining--; if (cnt.reductionsRemaining<=0) { CProxy_main mproxy(mid); mproxy.maindone(); cnt.reductionNo++; } else { #if 0 CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch(); if (cnt->reductionNo % 32 == 0) mg->rebuild(mcp.ckGetSectionInfo()); #endif if (cnt.reductionNo%3 == 0) { HiMsg *hiMsg = new (2, 0) HiMsg; //hiMsg->data[0] = 18+cnt.reductionNo; hiMsg->data[0] = 22; hiMsg->data[1] = 28; mcp.SayHi(hiMsg); } cnt.reductionNo++; } delete msg; }
void client(CkSectionInfo sid, void *param, int dataSize, void *data) { myReductionCounter *c=(myReductionCounter *)param; CmiPrintf("RESULT [%d]: %d\n", c->reductionNo, *(int *)data); // check correctness int result; if (c->reductionNo%3 == 0) { result = 0; for (int i=0; i<sectionSize; i++) result+=i; } else if (c->reductionNo%3 == 2) { result = 1; for (int i=1; i<sectionSize+1; i++) result*=i; } else { result = sectionSize+1; } if (*(int *)data != result) { CmiAbort("wrong!"); } c->reductionsRemaining--; if (c->reductionsRemaining<=0) { CProxy_main mproxy(mid); mproxy.maindone(); c->reductionNo++; } else { CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch(); if (c->reductionNo % 32 == 0) mg->rebuild(mcp.ckGetSectionInfo()); if (c->reductionNo%3 == 0) { HiMsg *hiMsg = new (1, 0) HiMsg; hiMsg->data[0] = 18+c->reductionNo; mcp.SayHi(hiMsg); } c->reductionNo++; } }