コード例 #1
0
ファイル: Node.cpp プロジェクト: sdasgup3/parallel-sudoku
void Node::getPriorityInfo(UShort & newParentPrioBits, UInt* &newParentPrioPtr, UInt &newParentPrioPtrSize, 
    UShort &parentPrioBits, UInt* &parentPrioPtr, UShort &childPrioBits, UInt &childnum)
{
  if(NULL == parentPrioPtr) {
    CkAssert(childPrioBits <= CkIntbits);
    newParentPrioBits  = childPrioBits + parentPrioBits;
    newParentPrioPtr  = (UInt *)malloc(sizeof(int));
    *newParentPrioPtr = childnum << (8*sizeof(unsigned int) - newParentPrioBits);
    newParentPrioPtrSize = 1;
    return;
  }

  newParentPrioBits           = parentPrioBits + childPrioBits;
  UShort parentPrioWords      = CkPriobitsToInts(parentPrioBits);
  UShort newParentPrioWords   = CkPriobitsToInts(parentPrioBits + childPrioBits);
  int shiftbits = 0;

  if(newParentPrioWords == parentPrioWords) {
    newParentPrioPtr  = (UInt *)malloc(parentPrioWords*sizeof(int));
    for(int i=0; i<parentPrioWords; i++) {
      newParentPrioPtr[i] = parentPrioPtr[i];
    }
    newParentPrioPtrSize  = parentPrioWords;

    if((newParentPrioBits) % (8*sizeof(unsigned int)) != 0) {
      shiftbits = 8*sizeof(unsigned int) - (newParentPrioBits)%(8*sizeof(unsigned int));
    }
    newParentPrioPtr[parentPrioWords-1] = parentPrioPtr[parentPrioWords-1] | (childnum << shiftbits);

  } else if(newParentPrioWords > parentPrioWords) {
    /* have to append a new integer */
    newParentPrioPtr  = (UInt *)malloc(newParentPrioWords*sizeof(int));
    for(int i=0; i<parentPrioWords; i++) {
      newParentPrioPtr[i] = parentPrioPtr[i];
    }
    newParentPrioPtrSize  = newParentPrioWords;

    if(parentPrioBits % (8*sizeof(unsigned int)) == 0) {
      shiftbits = sizeof(unsigned int)*8 - childPrioBits;
      newParentPrioPtr[parentPrioWords] = (childnum << shiftbits);
    } else { /*higher bits are appended to the last integer and then use anothe new integer */
      int inusebits = 8*sizeof(unsigned int) - (parentPrioBits % ( 8*sizeof(unsigned int)));
      unsigned int higherbits =  childnum >> (childPrioBits - inusebits);
      newParentPrioPtr[parentPrioWords-1] = parentPrioPtr[parentPrioWords-1] | higherbits;
      /* lower bits are stored in new integer */
      newParentPrioPtr[parentPrioWords] = childnum << (8*sizeof(unsigned int) - childPrioBits + inusebits);
    }
  }
コード例 #2
0
ファイル: debug-charm.C プロジェクト: gitter-badger/quinoa
// Interpret data in a message in a user-friendly way.
//  Ignores most of the envelope fields used by CkPupMessage,
//  and instead concentrates on user data
void CpdPupMessage(PUP::er &p, void *msg)
{
  envelope *env=UsrToEnv(msg);
  //int wasPacked=env->isPacked();
  int size=env->getTotalsize();
  int prioBits=env->getPriobits();
  int from=env->getSrcPe();
  PUPn(from);
  //PUPn(wasPacked);
  PUPn(prioBits);
  int userSize=size-sizeof(envelope)-sizeof(int)*CkPriobitsToInts(prioBits);
  PUPn(userSize);
  int msgType = env->getMsgIdx();
  PUPn(msgType);
  int envType = env->getMsgtype();
  PUPn(envType);

  //p.synchronize(PUP::sync_last_system);

  int ep=CkMessageToEpIdx(msg);
  PUPn(ep);

  // Pup the information specific to this envelope type
  if (envType == ForArrayEltMsg || envType == ArrayEltInitMsg) {
    int arrID = env->getArrayMgr().idx;
    PUPn(arrID);
    CkArrayIndex &idx = env->getsetArrayIndex();
    int nInts = idx.nInts;
    int dimension = idx.dimension;
    PUPn(nInts);
    PUPn(dimension);
    p.comment("index");
    if (dimension >=4 && dimension <=6) {
      p((short int *)idx.index, dimension);
    } else {
      p(idx.index, nInts);
    }
  } else if (envType == ForNodeBocMsg || envType == ForBocMsg) {
    int groupID = env->getGroupNum().idx;
    PUPn(groupID);
  } else if (envType == BocInitMsg || envType == NodeBocInitMsg) {
    int groupID = env->getGroupNum().idx;
    PUPn(groupID);
  } else if (envType == NewVChareMsg || envType == ForVidMsg || envType == FillVidMsg) {
    p.comment("ptr");
    void *ptr = env->getVidPtr();
    pup_pointer(&p, &ptr);
  } else if (envType == ForChareMsg) {
    p.comment("ptr");
    void *ptr = env->getObjPtr();
    pup_pointer(&p, &ptr);
  }
  
  /* user data */
  p.comment("data");
  p.synchronize(PUP::sync_begin_object);
  if (_entryTable[ep]->messagePup!=NULL)
    _entryTable[ep]->messagePup(p,msg);
  else
    CkMessage::ckDebugPup(p,msg);
  p.synchronize(PUP::sync_end_object);
}