Exemple #1
0
  Main(CkArgMsg* m): numArrays(2), numElements(5), sectionSize(numElements), maxIter(3), numIter(0)
  {
    //Process command-line arguments
    if (m->argc > 1) numElements = atoi(m->argv[1]);
    if (m->argc > 2) numArrays   = atoi(m->argv[2]);
    if (m->argc > 3) sectionSize = atoi(m->argv[3]); else sectionSize = numElements;
    if (m->argc > 4) maxIter     = atoi(m->argv[4]);
    if (m->argc > 5)
    { CkPrintf("Syntax: %s [numElements numArrays sectionSize maxIter]",m->argv[0]); CkAbort("Wrong Usage\n"); }
    delete m;

    CkPrintf("Running a cross-array section demo.\n");
    CkPrintf("\tnum PEs = %d\n\tnum arrays = %d\n\tnum elements = %d\n\tsection size = %d\n\tnum iterations = %d\n",
             CkNumPes(), numArrays, numElements, sectionSize, maxIter);

    // Create a multicast manager group
    CkGroupID mcastMgrGID = CProxy_CkMulticastMgr::ckNew();
    CkMulticastMgr *mcastMgr = CProxy_CkMulticastMgr(mcastMgrGID).ckLocalBranch();

    // Setup section member index bounds
    int afloor = 0, aceiling = sectionSize-1;

    // Allocate space
    CProxy_Hello *arrayOfArrays = new CProxy_Hello[numArrays];
    CkArrayID *arrID            = new CkArrayID[numArrays];
    int *nelems                 = new int[numArrays];
    CkArrayIndex **elems     = new CkArrayIndex*[numArrays];

    // Create a list of array section members
    for(int k=0; k < numArrays; k++)
    {
        // Create the array
        arrayOfArrays[k] = CProxy_Hello::ckNew(k, mcastMgrGID, numElements);
        // Store the AID
        arrID[k]  = arrayOfArrays[k].ckGetArrayID();
        // Create a list of section member indices in this array
        nelems[k] = sectionSize;
        elems[k]  = new CkArrayIndex[sectionSize];
        for(int i=afloor,j=0; i <= aceiling; i++,j++)
            elems[k][j] = CkArrayIndex1D(i);
    }
    // Create the x-array-section
    sectionProxy = CProxySection_Hello(numArrays, arrID, elems, nelems);

    // Delegate the section comm to the CkMulticast library
    sectionProxy.ckSectionDelegate(mcastMgr);
    // Configure the client of the section reduction
    CkCallback *rednCB = new CkCallback(CkIndex_Main::rednPong(NULL), thisProxy); 
    mcastMgr->setReductionClient(sectionProxy, rednCB);

    // Start the test by pinging the section
    pingMsg *msg = new pingMsg(numIter);
    sectionProxy.mcastPing(msg);
  }
Exemple #2
0
  void pup(PUP::er &p) {
    p|sid;
    p(init);
    p|cnt;
    p|mcp;
#if 1
    if (p.isUnpacking() && thisIndex == 0) {
      CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();
      mg->resetSection(mcp);
      CkCallback *cb = new CkCallback(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy);
      mg->setReductionClient(mcp, cb);
    }
#endif
  }
Exemple #3
0
void Patch::localCreateSection() {
#ifdef USE_SECTION_MULTICAST
  CkVec<CkArrayIndex6D> elems;
  for (int num=0; num<numNbrs; num++)
    elems.push_back(CkArrayIndex6D(computesList[num][0], computesList[num][1], computesList[num][2], computesList[num][3], computesList[num][4], computesList[num][5]));

  CkArrayID computeArrayID = computeArray.ckGetArrayID();
  mCastSecProxy = CProxySection_Compute::ckNew(computeArrayID, elems.getVec(), elems.size()); 

  CkMulticastMgr *mCastGrp = CProxy_CkMulticastMgr(mCastGrpID).ckLocalBranch();
  mCastSecProxy.ckSectionDelegate(mCastGrp);
  mCastGrp->setReductionClient(mCastSecProxy, new CkCallback(CkIndex_Patch::reduceForces(NULL), thisProxy(thisIndex.x, thisIndex.y, thisIndex.z)));

#endif
}
Exemple #4
0
    // only on index 0
  void start()
  {
    CkAssert(thisIndex == 0);
CmiPrintf("start %d elements\n", nElements);
    CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();

    // create section proxy
//    CkVec<CkArrayIndex1D> al;
//    for (int i=0; i<sectionSize; i++)
//      al.push_back(CkArrayIndex1D(i));
//    mcp = CProxySection_Hello::ckNew(thisArrayID, al.getVec(), al.size());
#if 0
    mcast = new CProxySection_Hello(thisArrayID, al, sectionSize, mCastGrpId);
#endif
    mcp = CProxySection_Hello::ckNew(thisArrayID, 0, sectionSize-1, 1);
    mcp.ckSectionDelegate(mg);

#if 0
    mcp.ckDelegate(mg);
    mg->setSection(mcp);
#endif

#if 0
    mg->setSection(sid, thisArrayID, al, sectionSize);
    sid.create(thisArrayID);
    for (int i=0; i<sectionSize; i++) 
      sid.addMember(CkArrayIndex1D(i));
    mg->setSection(sid);
#endif

    cnt.reductionsRemaining=REDUCE_TIME;
    cnt.reductionNo=0;
//    mg->setReductionClient(mcp, client, cnt);
    CkCallback *cb = new CkCallback(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy);
    mg->setReductionClient(mcp, cb);

    HiMsg *hiMsg = new (2, 0) HiMsg;
    hiMsg->data[0] = 22;
    hiMsg->data[1] = 28;
    mcp.SayHi(hiMsg);
  }
Exemple #5
0
  void start()
  {
    CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();

    sectionSize = SectionSize;
    if (sectionSize > NumElements) sectionSize = NumElements;
    CkArrayIndex *al = new CkArrayIndex[sectionSize];
    for (int i=0; i<sectionSize; i++) {
      al[i] = CkArrayIndex1D(i);
    }
    mcp = CProxySection_Hello::ckNew(thisArrayID, al, sectionSize);
    mcp.ckSectionDelegate(mg);
    delete [] al;
    cnt.reductionsRemaining=NumReductions;
    cnt.reductionNo=0;
    CkCallback *cb = new CkCallback(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy);
    mg->setReductionClient(mcp, cb);

    HiMsg *hiMsg = new (2, 0) HiMsg;
    hiMsg->data[0] = 22;
    hiMsg->data[1] = 28;
    startTime = CkWallTimer ();
    mcp.SayHi(hiMsg);
  }