void SayHi(HiMsg *m) { redNo ++; CmiAssert(m->data[0] == 22 && m->data[1] == 28); CkGetSectionInfo(sid, m); CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch(); int dataSize = (int)(CompleteMsgSize); int* data = new int [dataSize]; int fragSize = dataSize/NumFrags; CkAssert (0 != fragSize); for (int i=0; i<dataSize; i++) { data [i] = thisIndex; } CkCallback cb(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy); mg->contribute(dataSize*sizeof(int), data,CkReduction::sum_int, sid, cb, fragSize*sizeof(int)); // data[0] = thisIndex+2; // data[1] = thisIndex+2; // mg->contribute(2*sizeof(int), &data,CkReduction::max_int, sid, sizeof(int)); // data[0] = thisIndex+1; // data[1] = thisIndex+1; // mg->contribute(2*sizeof(int), &data,CkReduction::product_int, sid, sizeof(int)); delete m; if (1) ckMigrate((CkMyPe()+1)%CkNumPes()); }
void SayHi(HiMsg *m) { // CkPrintf("[%d] Hi[%d] from element %d\n",CmiMyPe(), m->data[0],thisIndex); CmiAssert(m->data[0] == 22 && m->data[1] == 28); CkGetSectionInfo(sid, m); //CmiPrintf("[%d] SayHi: sid on %d %p\n", CmiMyPe(), sid.pe, sid.val); CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch(); int data = thisIndex; CkCallback cb(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy); mg->contribute(sizeof(int), &data,CkReduction::sum_int, sid, cb); data = thisIndex+2; mg->contribute(sizeof(int), &data,CkReduction::max_int, sid); data = thisIndex+1; mg->contribute(sizeof(int), &data,CkReduction::product_int, sid); delete m; if (1) ckMigrate((CkMyPe()+1)%CkNumPes()); }
void Test3D::compute(DummyMsg *m) { /*char buf[2048]; //for debugging sprintf(buf, "Compute called :: thisIndex = { %d, %d }, m->section = %d", thisIndex.x, thisIndex.y, m->section); //debugging */ //cookie stuff. int section = m->section; int oldLength = cookies.length(); int newLength = section + 1; if(oldLength < newLength) { //only if the section proxy calling //this method is a new section proxy //(that hasn't already called this method //before, increase the size of the cookies array. cookies.resize(section+1); for (int i = oldLength; i < newLength; i++) { CkSectionInfo tempCookie; cookies[i] = tempCookie; } } CkGetSectionInfo(cookies[section], m); //the index of the cookie identifies, which section proxy we are refering to. /* DEBUG CkSectionInfo si = cookies[section]; sprintf(buf + strlen(buf), ", Cookie:" " type = %d" " pe = %d" " sCookie = { redNo:%d, val:%p }\n", (int)(si.type), si.pe, si.sInfo.sCookie.redNo, si.sInfo.sCookie.val ); CkPrintf(buf); */ CkVec<double> myVector(vectorSize); //creates elements with vectorSize elements for(int i = 0; i < vectorSize; i++) { myVector[i] = doubleVector[i]; } CkMulticastMgr *mCastGrp = CProxy_CkMulticastMgr(mCastGrpID).ckLocalBranch(); CkCallback cb(CkIndex_Main::reportSum(NULL), mainProxy); mCastGrp->contribute(sizeof(double)*vectorSize, myVector.getVec(), CkReduction::sum_double, cookies[section], cb); delete m; };