예제 #1
0
byte * aes(byte *in, byte *skey)
{
	int i;

	for(i=0; i < 16; i++)
	{
		state[i] = in[i];
		key[i] = skey[i];
	}
	addRoundKey();

	for(i = 0; i < 9; i++)
	{
 		subBytes();
		shiftRows();
		mixColumns();
		computeKey(rcon[i]);
		addRoundKey();
	}

	subBytes();
	shiftRows();
	computeKey(rcon[i]);
	addRoundKey();

	return state;
}
예제 #2
0
파일: AES128.cpp 프로젝트: 12019/libraries
/* Compute a round of the key
 * 0 4  8 12
 * 1 5  9 13
 * 2 6 10 14
 * 3 7 11 15
 */
void AES128::computeKeyRound(int round) {
	int i;
	initKey();
	for (i=0; i < round; i++ ) {
		computeKey(pgm_read_byte(rcon+i));
	}
}
예제 #3
0
파일: lowpbe.c 프로젝트: bhargavz/pac4mac
// Optimized for FireMaster....
int nsspkcs5_CipherData(struct NSSPKCS5PBEParameter * pbe_param, const unsigned char *pwhash, const unsigned char *encString, SECItem *pkcs5_pfxpbe, SECItem *secPreHash)
{

	unsigned char *hashKey = computeKey(pbe_param, pwhash, pkcs5_pfxpbe, secPreHash);

	struct DESContext dctx;
	DES_CreateContext(&dctx, hashKey, hashKey + 32);
	return DES_EDE3CBCDe(&dctx, encString);
}
예제 #4
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
Status PlanCache::add(const CanonicalQuery& query,
                      const std::vector<QuerySolution*>& solns,
                      PlanRankingDecision* why,
                      Date_t now) {
    invariant(why);

    if (solns.empty()) {
        return Status(ErrorCodes::BadValue, "no solutions provided");
    }

    if (why->stats.size() != solns.size()) {
        return Status(ErrorCodes::BadValue, "number of stats in decision must match solutions");
    }

    if (why->scores.size() != solns.size()) {
        return Status(ErrorCodes::BadValue, "number of scores in decision must match solutions");
    }

    if (why->candidateOrder.size() != solns.size()) {
        return Status(ErrorCodes::BadValue,
                      "candidate ordering entries in decision must match solutions");
    }

    PlanCacheEntry* entry = new PlanCacheEntry(solns, why);
    const QueryRequest& qr = query.getQueryRequest();
    entry->query = qr.getFilter().getOwned();
    entry->sort = qr.getSort().getOwned();
    if (query.getCollator()) {
        entry->collation = query.getCollator()->getSpec().toBSON();
    }
    entry->timeOfCreation = now;


    // Strip projections on $-prefixed fields, as these are added by internal callers of the query
    // system and are not considered part of the user projection.
    BSONObjBuilder projBuilder;
    for (auto elem : qr.getProj()) {
        if (elem.fieldName()[0] == '$') {
            continue;
        }
        projBuilder.append(elem);
    }
    entry->projection = projBuilder.obj();

    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    std::unique_ptr<PlanCacheEntry> evictedEntry = _cache.add(computeKey(query), entry);

    if (NULL != evictedEntry.get()) {
        LOG(1) << _ns << ": plan cache maximum size exceeded - "
               << "removed least recently used entry " << redact(evictedEntry->toString());
    }

    return Status::OK();
}
예제 #5
0
파일: AES128.cpp 프로젝트: 12019/libraries
byte * AES128::encrypt(byte *message) {
	int i;

	memcpy((void*)state, (const void*)message,16);
	
	initKey();
	addRoundKey();

	for(i = 0; i < 9; i++) {
 		subBytes();
		shiftRows();
		mixColumns();
		computeKey(pgm_read_byte(rcon + i));
		addRoundKey();
	}

	subBytes();
	shiftRows();
	computeKey(pgm_read_byte(rcon + i));
	addRoundKey();

	memcpy((void*)message,(const void*)state, 16);	
	return message;
}
예제 #6
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
Status PlanCache::get(const CanonicalQuery& query, CachedSolution** crOut) const {
    PlanCacheKey key = computeKey(query);
    verify(crOut);

    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    PlanCacheEntry* entry;
    Status cacheStatus = _cache.get(key, &entry);
    if (!cacheStatus.isOK()) {
        return cacheStatus;
    }
    invariant(entry);

    *crOut = new CachedSolution(key, *entry);

    return Status::OK();
}
예제 #7
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
Status PlanCache::getEntry(const CanonicalQuery& query, PlanCacheEntry** entryOut) const {
    PlanCacheKey key = computeKey(query);
    verify(entryOut);

    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    PlanCacheEntry* entry;
    Status cacheStatus = _cache.get(key, &entry);
    if (!cacheStatus.isOK()) {
        return cacheStatus;
    }
    invariant(entry);

    *entryOut = entry->clone();

    return Status::OK();
}
void LcsHash::restore(uint numVals, uint16_t lastValOff)
{
    uint            i;
    uint            key;
    PBuffer         dataWithLen;
    LcsHashValueNode      *newNode;
    LcsHashValOrd   dummy;
    LcsHashValOrd   valOrd;
    TupleStorageByteLength storageLength;

    /*
     * Compression mode could change dynamically so we have to check everytime.
     * If this batch will not be compressed, then there is no reason to
     * generate a real hash code.  Hash code generation is expensive, so
     * try to avoid it.
     */
    bool noCompress = clusterBlockWriter->noCompressMode(columnId);

    for (i = 0; i < numVals && !(hash.isFull()); i++) {
        dataWithLen = clusterBlockWriter->getOffsetPtr(columnId, lastValOff);
        key = noCompress ? 0 : computeKey(dataWithLen);

        /*
         * If value is not in hash, or if we are not in compress mode (in which
         * case we allow duplicates in the hash table), then adds value to the
         * hash.
         */
        if (noCompress || !search(key, dataWithLen, &dummy)) {
            newNode = hash.getNewValueNode();

            valOrd = valCnt++;
            newNode->valueOrd = valOrd;
            newNode->valueOffset = (uint16_t) lastValOff;

            hash.insertNewValueNode(key,  newNode);

            storageLength = attrAccessor.getStoredByteCount(dataWithLen);
            if (storageLength > maxValueSize) {
                maxValueSize = storageLength;
            }
        }

        lastValOff = clusterBlockWriter->getNextVal(
            columnId,
            (uint16_t)lastValOff);
    }
}
예제 #9
0
//-------------------------------------------------------------------------------
GribV1Record::GribV1Record(ZUFILE* file) : GribRecord()
{
    seekStart = zu_tell(file);
    data    = NULL;
    BMSbits = NULL;
    eof     = false;
    isFull = false;
    knownData = true;

    ok = readGribSection0_IS(file);

    if (ok) {
        ok = readGribSection1_PDS(file);
        zu_seek(file, fileOffset1+sectionSize1, SEEK_SET);
    }
    if (ok) {
        ok = readGribSection2_GDS(file);
        zu_seek(file, fileOffset2+sectionSize2, SEEK_SET);
    }
    if (ok) {
        ok = readGribSection3_BMS(file);
        zu_seek(file, fileOffset3+sectionSize3, SEEK_SET);
    }
    if (ok) {
        ok = readGribSection4_BDS(file);
        zu_seek(file, fileOffset4+sectionSize4, SEEK_SET);
    }
    if (ok) {
        ok = readGribSection5_ES(file);
    }
    if (ok) {
        zu_seek(file, seekStart+totalSize, SEEK_SET);
    }

    if (ok) {
        if(dataType!=DATA_NOTDEF && levelType!=DATA_LV_NOTDEF) {
            knownData = true;
            unitConversion();
        }
        else {
            knownData = false;
            qWarning() << "Unknown data: dataType=" << dataType << ", levelType=" << levelType << ", levelValue=" << levelValue;
        }

        computeKey();
    }
}
예제 #10
0
    Status PlanCache::add(const CanonicalQuery& query,
                          const std::vector<QuerySolution*>& solns,
                          PlanRankingDecision* why) {
        invariant(why);

        if (solns.empty()) {
            return Status(ErrorCodes::BadValue, "no solutions provided");
        }

        if (why->stats.size() != solns.size()) {
            return Status(ErrorCodes::BadValue,
                          "number of stats in decision must match solutions");
        }

        if (why->scores.size() != solns.size()) {
            return Status(ErrorCodes::BadValue,
                          "number of scores in decision must match solutions");
        }

        if (why->candidateOrder.size() != solns.size()) {
            return Status(ErrorCodes::BadValue,
                          "candidate ordering entries in decision must match solutions");
        }

        PlanCacheEntry* entry = new PlanCacheEntry(solns, why);
        const LiteParsedQuery& pq = query.getParsed();
        entry->query = pq.getFilter().getOwned();
        entry->sort = pq.getSort().getOwned();
        entry->projection = pq.getProj().getOwned();

        boost::lock_guard<boost::mutex> cacheLock(_cacheMutex);
        std::auto_ptr<PlanCacheEntry> evictedEntry = _cache.add(computeKey(query), entry);

        if (NULL != evictedEntry.get()) {
            LOG(1) << _ns << ": plan cache maximum size exceeded - "
                   << "removed least recently used entry "
                   << evictedEntry->toString();
        }

        return Status::OK();
    }
예제 #11
0
//Calls default multicast scheme to send the messages. It could 
//also call a converse lower level strategy to do the muiticast.
//For example pipelined multicast
void RectMulticastStrategy::remoteMulticast(envelope *env, 
					    ComlibRectSectionHashObject *obj) {

    ComlibPrintf("[%d] remoteMulticast \n", CkMyPe());       
    int npes = obj->npes;
    int *pelist = obj->pelist;
    
    //    if(npes == 0) {
    //        CmiFree(env);
    //        return;    
    //    }
    
    //CmiSetHandler(env, handlerId);
    CmiSetHandler(env, CkpvAccess(strategy_handlerid));

    ((CmiMsgHeaderExt *) env)->stratid = getInstance();

    //Collect Multicast Statistics
    RECORD_SENDM_STATS(getInstance(), env->getTotalsize(), pelist, npes);
    int srcpe=env->getSrcPe();    
    CkPackMessage(&env);


    //    int destid=env->getGroupNum().idx;    
    
    //Sending a remote multicast
    ComlibMulticastMsg *cbmsg = (ComlibMulticastMsg *)EnvToUsr(env);
    int sectionID=cbmsg->_cookie.sInfo.cInfo.id;
    CkArrayID destid=obj->aid;
    // bgl_machineRectBcast should only be called once globally
    // per multicast
    int comm=computeKey(sectionID, srcpe, destid);
    ComlibPrintf("[%d] rectbcast using comm %d section %d srcpe %d request %p\n",CkMyPe(), comm, sectionID, srcpe, CkpvAccess(com_rect_ptr)->get(comm));
#ifdef COMLIB_RECT_DEBUG
    isSane(CkpvAccess(com_rect_ptr)->get(comm),comm);
#endif
    bgl_machine_RectBcast(comm  , (char*)env, env->getTotalsize());
    //CmiSyncListSendAndFree(npes, pelist, env->getTotalsize(), (char*)env);
    //CmiSyncBroadcastAndFree(env->getTotalsize(), (char*)env);
}
예제 #12
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
Status PlanCache::feedback(const CanonicalQuery& cq, PlanCacheEntryFeedback* feedback) {
    if (NULL == feedback) {
        return Status(ErrorCodes::BadValue, "feedback is NULL");
    }
    std::unique_ptr<PlanCacheEntryFeedback> autoFeedback(feedback);
    PlanCacheKey ck = computeKey(cq);

    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    PlanCacheEntry* entry;
    Status cacheStatus = _cache.get(ck, &entry);
    if (!cacheStatus.isOK()) {
        return cacheStatus;
    }
    invariant(entry);

    // We store up to a constant number of feedback entries.
    if (entry->feedback.size() < static_cast<size_t>(internalQueryCacheFeedbacksStored.load())) {
        entry->feedback.push_back(autoFeedback.release());
    }

    return Status::OK();
}
예제 #13
0
void ProgramCache::useProgram(const Description& description) {

    // generate the key for the shader based on the description
    Key needs(computeKey(description));

     // look-up the program in the cache
    Program* program = mCache.valueFor(needs);
    if (program == NULL) {
        // we didn't find our program, so generate one...
        nsecs_t time = -systemTime();
        program = generateProgram(needs);
        mCache.add(needs, program);
        time += systemTime();

        //ALOGD(">>> generated new program: needs=%08X, time=%u ms (%d programs)",
        //        needs.mNeeds, uint32_t(ns2ms(time)), mCache.size());
    }

    // here we have a suitable program for this description
    if (program->isValid()) {
        program->use();
        program->setUniforms(description);
    }
}
예제 #14
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
Status PlanCache::remove(const CanonicalQuery& canonicalQuery) {
    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    return _cache.remove(computeKey(canonicalQuery));
}
void LcsHash::insert(
    PBuffer     dataWithLen,
    LcsHashValOrd   *valOrd,
    bool       *undoInsert)
{
    uint        key;
    uint16_t    newValueOffset;
    LcsHashValueNode *vPtr = 0;
    TupleStorageByteLength storageLength;

    /*
     * Compression mode could change dynamically so we have to check everytime.
     * If this batch will not be compressed, then there is no reason to
     * generate a real hash code.  Hash code generation is expensive, so
     * try to avoid it.
     */
    bool noCompress = clusterBlockWriter->noCompressMode(columnId);
    key = noCompress ? 0 : computeKey(dataWithLen);

    *undoInsert     = false;

    /*
     * If value is not in hash, or
     * if we are not in compress mode
     * (in which case we allow duplicates in the hash table),
     * then adds value to the hash.
     */
    if (noCompress || !search(key, dataWithLen, valOrd, &vPtr)) {
        LcsHashValueNode       *newNode;

        /*
         * If hash table is full,  or
         * if the cluster page is full
         * then returns and indicates the need to undo the insert.
         */
        *undoInsert =
            hash.isFull()
            || !clusterBlockWriter->addValue(
                columnId, dataWithLen, &newValueOffset);

        if (*undoInsert) {
            /*
             * Prepares undo action.
             */
            undo.set(NOTHING, key, maxValueSize, 0);
            return;
        }

        /*
         * Inserts a new node only when the above call does not return
         * undoInsert.  If a new node is inserted but the undoInsert above is
         * true, the subsequent undoInsert() call will not roll back the new
         * node correctly if undo.what is not set to NEWENTRY(the default value
         * is NOTHING).
         */
        newNode = hash.getNewValueNode();
        newNode->valueOffset = newValueOffset;
        *valOrd = valCnt ++;
        valOrd->setValueInBatch();
        newNode->valueOrd = *valOrd;

        hash.insertNewValueNode(key, newNode);

        /*
         * Prepares undo action.
         */
        undo.set(NEWENTRY, key, maxValueSize, 0);

        storageLength = attrAccessor.getStoredByteCount(dataWithLen);

        if (storageLength > maxValueSize) {
            maxValueSize = storageLength;
        }
    } else {
        /*
         * We found the value in the hash (from the Search() call above),
         * so it is already in the block,
         * but it still may not be part of the current batch.
         * Whether it is or not, call addValue(), so that we can adjust
         * space left in the block.
         */
        bool bFirstTimeInBatch = !valOrd->isValueInBatch();

        *undoInsert =
            !clusterBlockWriter->addValue(columnId, bFirstTimeInBatch);

        if (*undoInsert) {
            /*
             * Prepares undo action.
             */
            undo.set(NOTHING, key, maxValueSize, 0);
            return;
        }

        (vPtr->valueOrd).setValueInBatch();
        *valOrd = vPtr->valueOrd;

        /*
         * Prepares undo action.
         */
        if (bFirstTimeInBatch) {
            undo.set(NEWBATCHVALUE, key, maxValueSize, vPtr);
        } else {
            undo.set(NOTHING, key, maxValueSize, 0);
        }
    }
    /*
     * Otherwise the value is already in the hash, and the current batch
     * already has a pointer to that value, so don't do anything.
     */
}
예제 #16
0
void EDPSimplePUBListener::onNewCacheChangeAdded(RTPSReader* /*reader*/, const CacheChange_t* const change_in)
{
	const char* const CLASS_NAME = "EDPSimplePUBListener";
	const char* const METHOD_NAME = "onNewCacheChangeAdded";
	CacheChange_t* change = (CacheChange_t*)change_in;
	//boost::lock_guard<boost::recursive_mutex> guard(*this->mp_SEDP->mp_PubReader.first->getMutex());
	logInfo(RTPS_EDP,"");
	if(!computeKey(change))
	{
		logWarning(RTPS_EDP,"Received change with no Key");
	}
	if(change->kind == ALIVE)
	{
		//LOAD INFORMATION IN TEMPORAL WRITER PROXY DATA
		WriterProxyData writerProxyData;
		CDRMessage_t tempMsg;
		tempMsg.msg_endian = change->serializedPayload.encapsulation == PL_CDR_BE ? BIGEND:LITTLEEND;
		tempMsg.length = change->serializedPayload.length;
		memcpy(tempMsg.buffer,change->serializedPayload.data,tempMsg.length);
		if(writerProxyData.readFromCDRMessage(&tempMsg))
		{
			change->instanceHandle = writerProxyData.m_key;
			if(writerProxyData.m_guid.guidPrefix == mp_SEDP->mp_RTPSParticipant->getGuid().guidPrefix)
			{
				logInfo(RTPS_EDP,"Message from own RTPSParticipant, ignoring",C_CYAN);
				mp_SEDP->mp_PubReader.second->remove_change(change);
				return;
			}
			//LOOK IF IS AN UPDATED INFORMATION
			WriterProxyData* wdata = nullptr;
			ParticipantProxyData* pdata = nullptr;
			if(this->mp_SEDP->mp_PDP->addWriterProxyData(&writerProxyData,true,&wdata,&pdata)) //ADDED NEW DATA
			{
				//CHECK the locators:
				if(wdata->m_unicastLocatorList.empty() && wdata->m_multicastLocatorList.empty())
				{
					wdata->m_unicastLocatorList = pdata->m_defaultUnicastLocatorList;
					wdata->m_multicastLocatorList = pdata->m_defaultMulticastLocatorList;
				}
				wdata->m_isAlive = true;
				mp_SEDP->pairingWriterProxy(wdata);
			}
			else if(pdata == nullptr) //RTPSParticipant NOT FOUND
			{
				logWarning(RTPS_EDP,"Received message from UNKNOWN RTPSParticipant, removing");
				this->mp_SEDP->mp_PubReader.second->remove_change(change);
				return;
			}
			else //NOT ADDED BECAUSE IT WAS ALREADY THERE
			{
				boost::lock_guard<boost::recursive_mutex> guard(*mp_SEDP->mp_PubReader.second->getMutex());
				for(auto ch = mp_SEDP->mp_PubReader.second->changesBegin();
						ch!=mp_SEDP->mp_PubReader.second->changesEnd();++ch)
				{
					if((*ch)->instanceHandle == change->instanceHandle &&
							(*ch)->sequenceNumber < change->sequenceNumber)
						mp_SEDP->mp_PubReader.second->remove_change(*ch);
				}
				wdata->update(&writerProxyData);
				mp_SEDP->pairingWriterProxy(wdata);
			}
		}
	}
	else
	{
		//REMOVE WRITER FROM OUR READERS:
		logInfo(RTPS_EDP,"Disposed Remote Writer, removing...",C_CYAN);
		GUID_t auxGUID = iHandle2GUID(change->instanceHandle);
		mp_SEDP->mp_PubReader.second->remove_change(change);
		this->mp_SEDP->removeWriterProxy(auxGUID);
	}
	return;
}
예제 #17
0
ComlibRectSectionHashObject *
RectMulticastStrategy::createObjectOnIntermediatePe(int nindices,
						      CkArrayIndex *idxlist,
						      int npes,
						      ComlibMulticastIndexCount *counts,
						      int srcpe, int thisSectionID) {

    ComlibPrintf("[%d] createObjectOnIntermediatePe \n", CkMyPe());   
    ComlibRectSectionHashObject *obj = new ComlibRectSectionHashObject();
    CkAssert(npes>0);
    sinfo.getRemotePelist(nindices, idxlist, obj->npes, obj->pelist);
    sinfo.getLocalIndices(nindices, idxlist, obj->indices);
    obj->aid=sinfo.getDestArrayID();
    //obj->indices.resize(0);
    //for (int i=0; i<nindices; ++i) obj->indices.insertAtEnd(idxlist[i]);
    //sinfo.getLocalIndices(nindices, idxlist, obj->indices);
    BGLTorusManager *bgltm= BGLTorusManager::getObject();
    int x,y,z;
    bgltm->getCoordinatesByRank(srcpe,x, y, z);

    unsigned int comm = computeKey( thisSectionID, srcpe, sinfo.getDestArrayID());

    if(obj->npes<=0)
      {
	ComlibPrintf("[%d] nindices %d, npes %d, obj->npes %d\n", CkMyPe(), nindices, npes, obj->npes);
      }
    CkAssert(obj->npes>0);
    BGTsRC_Geometry_t *geometry=getRectGeometry(obj,srcpe);
    // handle the root not in rectangle case
    if( x >= geometry->x0 && x  < geometry->x0+ geometry->xs &&
	y >= geometry->y0 && y  < geometry->y0+ geometry->ys &&
	z >= geometry->z0 && z  < geometry->z0+ geometry->zs)
      { // ok
	ComlibPrintf("[%d] create intermediate %d %d %d %d in rectangle %d %d %d, %d %d %d comm = %d \n", CkMyPe(), srcpe, x, y, z, 
		     geometry->x0, geometry->y0, geometry->z0,
		     geometry->xs, geometry->ys, geometry->zs, comm
		     );   

	obj->sourceInRectangle=true;
	obj->cornerRoot=srcpe;
      }
    else
      {
	ComlibPrintf("[%d] root %d %d %d %d NOT in rectangle %d %d %d, %d %d %d  \n", CkMyPe(), srcpe, x, y, z, 
		     geometry->x0, geometry->y0, geometry->z0,
		     geometry->xs, geometry->ys, geometry->zs
		     );   


	obj->sourceInRectangle=false;
	// fix the root to a corner
	obj->cornerRoot=assignCornerRoot(geometry,srcpe);
      }

    void *request = CkpvAccess(com_rect_ptr)->get(comm);
    if(request==NULL)
      {
	request=bgl_machine_RectBcastInit(comm, geometry);
	ComlibPrintf("[%d] cinter init comm %d section %d srcpe %d\n",CkMyPe(), comm, thisSectionID, srcpe);	
      }
    else{
      ComlibPrintf("[%d] cinter already init comm %d section %d srcpe %d\n",CkMyPe(), comm, thisSectionID, srcpe);
    }
    // we don't actually need the request on a typical intermediate
    // only the forwarding case cares.
    CkpvAccess(com_rect_ptr)->put(comm)= request;
#ifdef COMLIB_RECT_DEBUG
    void *getrequest =     CkpvAccess(com_rect_ptr)->get(comm);
    CkAssert(*((char *) request)==*((char *)getrequest));
    isSane(getrequest,comm);
#endif
    //    delete geometry;
    return obj;
}
예제 #18
0
파일: plan_cache.cpp 프로젝트: i80and/mongo
bool PlanCache::contains(const CanonicalQuery& cq) const {
    stdx::lock_guard<stdx::mutex> cacheLock(_cacheMutex);
    return _cache.hasKey(computeKey(cq));
}
예제 #19
0
ComlibRectSectionHashObject *
RectMulticastStrategy::createObjectOnSrcPe(int nindices, CkArrayIndex *idxlist, unsigned int thisSectionID) {

    ComlibPrintf("[%d] createObjectOnSrcPe \n", CkMyPe());   
    ComlibPrintf("[%d] Rect createObjectOnSrcPe \n", CkMyPe());   
    ComlibRectSectionHashObject *obj = new ComlibRectSectionHashObject();
    
    sinfo.getRemotePelist(nindices, idxlist, obj->npes, obj->pelist);
    sinfo.getLocalIndices(nindices, idxlist, obj->indices);
    // TODO: how do we get the root pe here?
    // cheap hack, assume section built from root
    int rootpe=CkMyPe();
    BGLTorusManager *bgltm= BGLTorusManager::getObject();
    int x,y,z;
    bgltm->getCoordinatesByRank(rootpe,x, y, z);
    obj->aid=sinfo.getDestArrayID();
    unsigned int comm=computeKey( thisSectionID, rootpe, sinfo.getDestArrayID());
    CkAssert(obj->npes>0);
    BGTsRC_Geometry_t *geometry=getRectGeometry(obj ,rootpe);
    // handle the root not in rectangle case
    if( x >= geometry->x0 && x  < geometry->x0+ geometry->xs &&
	y >= geometry->y0 && y  < geometry->y0+ geometry->ys &&
	z >= geometry->z0 && z  < geometry->z0+ geometry->zs)
      { // ok
	ComlibPrintf("[%d] create root %d %d %d %d in rectangle %d %d %d, %d %d %d comm id = %d geom root %d %d %d geom t0 %d tr %d ts %d\n", CkMyPe(), rootpe, x, y, z, 
		     geometry->x0, geometry->y0, geometry->z0,
		     geometry->xs, geometry->ys, geometry->zs, comm,
		     geometry->xr, geometry->yr, geometry->zr,
		     geometry->t0, geometry->tr, geometry->ts
		     );   
	obj->sourceInRectangle=true;
	obj->cornerRoot=rootpe;
	void *request = CkpvAccess(com_rect_ptr)->get(comm);
	if(request==NULL)
	  {
	    request=bgl_machine_RectBcastInit(comm, geometry);
	    ComlibPrintf("[%d] csrc init comm %d section %d srcpe %d request %p\n",CkMyPe(), comm, thisSectionID, rootpe, request);
	    CkpvAccess(com_rect_ptr)->put(comm)= request;
#ifdef COMLIB_RECT_DEBUG
	    isSane(request,comm);
#endif
	  }
	else{
	  ComlibPrintf("[%d] csrc already init comm %d section %d srcpe %d\n",CkMyPe(), comm, thisSectionID, rootpe);
	}
#ifdef COMLIB_RECT_DEBUG
	void *getrequest =     CkpvAccess(com_rect_ptr)->get(comm);
	CkAssert(*((char *) request)==*((char *)getrequest));
	isSane(getrequest,comm);
#endif
      }
    else // sender not inside rectangle.
      {  // we cannot initialize or use the rectangle from here
	ComlibPrintf("[%d] root %d %d %d %d NOT in rectangle %d %d %d, %d %d %d  \n", CkMyPe(), rootpe, x, y, z, 
		     geometry->x0, geometry->y0, geometry->z0,
		     geometry->xs, geometry->ys, geometry->zs
		     );   

	obj->sourceInRectangle=false;
	obj->cornerRoot=assignCornerRoot(geometry, rootpe);
	/*  if we were to actually use the geom from here.
	  obj->sourceInRectangle=false;
	  geometry.xr=geometry.x0;
	  geometry.yr=geometry.y0;
	  geometry.zr=geometry.z0;
	*/

      }
    //    delete geometry;
    return obj;
}