void* CkCopyMsg(void **pMsg) {// cannot simply memcpy, because srcMsg could be varsize msg register void *srcMsg = *pMsg; register envelope *env = UsrToEnv(srcMsg); register unsigned char msgidx = env->getMsgIdx(); if(!env->isPacked() && _msgTable[msgidx]->pack) { srcMsg = _msgTable[msgidx]->pack(srcMsg); UsrToEnv(srcMsg)->setPacked(1); } register int size = UsrToEnv(srcMsg)->getTotalsize(); register envelope *newenv = (envelope *) CmiAlloc(size); CmiMemcpy(newenv, UsrToEnv(srcMsg), size); //memcpy(newenv, UsrToEnv(srcMsg), size); if(UsrToEnv(srcMsg)->isPacked() && _msgTable[msgidx]->unpack) { srcMsg = _msgTable[msgidx]->unpack(srcMsg); UsrToEnv(srcMsg)->setPacked(0); } *pMsg = srcMsg; if(newenv->isPacked() && _msgTable[msgidx]->unpack) { srcMsg = _msgTable[msgidx]->unpack(EnvToUsr(newenv)); UsrToEnv(srcMsg)->setPacked(0); } else srcMsg = EnvToUsr(newenv); setMemoryTypeMessage(newenv); return srcMsg; }
void* CkAllocBuffer(void *msg, int bufsize) { bufsize = CkMsgAlignLength(bufsize); register envelope *env = UsrToEnv(msg); register envelope *packbuf; packbuf = _allocEnv(env->getMsgtype(), bufsize, env->getPriobits()); register int size = packbuf->getTotalsize(); CmiMemcpy(packbuf, env, sizeof(envelope)); packbuf->setTotalsize(size); packbuf->setPacked(!env->isPacked()); CmiMemcpy(packbuf->getPrioPtr(), env->getPrioPtr(), packbuf->getPrioBytes()); return EnvToUsr(packbuf);; }
CkMarshallMsg *CkAllocateMarshallMsgNoninline(int size,const CkEntryOptions *opts) { //Allocate the message CkMarshallMsg *m=new (size,opts->getPriorityBits())CkMarshallMsg; //Copy the user's priority data into the message envelope *env=UsrToEnv(m); setMemoryTypeMessage(env); if (opts->getPriorityPtr() != NULL) CmiMemcpy(env->getPrioPtr(),opts->getPriorityPtr(),env->getPrioBytes()); //Set the message's queueing type env->setQueueing((unsigned char)opts->getQueueing()); env->setGroupDep(opts->getGroupDepID()); return m; }
// needs to figure out what is local/remote void CmiDirect_get(CmiDirectUserHandle *userHandle) { gni_post_descriptor_t *pd; #if USE_LRTS_MEMPOOL if (userHandle->remoteNode== CmiMyNode()) { CmiMemcpy(userHandle->remoteBuf,userHandle->localBuf,userHandle->transSize); (*(userHandle->callbackFnPtr))(userHandle->callbackData); } else { gni_return_t status; RDMA_REQUEST *rdma_request_msg; MallocPostDesc(pd); if(userHandle->transSize <= LRTS_GNI_RDMA_THRESHOLD) pd->type = GNI_POST_FMA_GET; else pd->type = GNI_POST_RDMA_GET; pd->cq_mode = GNI_CQMODE_GLOBAL_EVENT; pd->dlvr_mode = GNI_DLVMODE_PERFORMANCE; pd->length = userHandle->transSize; pd->local_addr = (uint64_t) (userHandle->localBuf); pd->local_mem_hndl = userHandle->localMdh; pd->remote_addr = (uint64_t)(userHandle->remoteBuf); pd->remote_mem_hndl = userHandle->remoteMdh; pd->src_cq_hndl = 0; pd->rdma_mode = 0; pd->first_operand = (uint64_t) (userHandle->callbackFnPtr); pd->second_operand = (uint64_t) (userHandle->callbackData); pd->amo_cmd = 2; pd->cqwrite_value = DIRECT_SEQ; #if REMOTE_EVENT bufferRdmaMsg(sendRdmaBuf, CmiGetNodeGlobal(userHandle->remoteNode,CmiMyPartition()), pd, userHandle->ack_index); #else bufferRdmaMsg(sendRdmaBuf, CmiGetNodeGlobal(userHandle->remoteNode,CmiMyPartition()), pd, -1); #endif #if CMI_DIRECT_DEBUG CmiPrintf("[%d] RDMA get %d,%d bytes addr %p to remoteNode %d:%p \n\n",CmiMyPe(), userHandle->transSize, pd->length, (void*)(pd->local_addr), userHandle->remoteNode, (void*) (pd->remote_addr)); #endif } #else CmiPrintf("Normal Send in CmiDirect Get\n"); CmiAbort(""); #endif }
//============================================================================ // This function when the density FFT from Rho_R is complete //============================================================================ //cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc //============================================================================ void CP_Rho_GSpacePlane::acceptRhoData() { #ifdef _CP_DEBUG_RHOG_VERBOSE_ CkPrintf("{%d} Rho GS [%d] acceptRhoData\n", thisInstance.proxyOffset, thisIndex); #endif #ifdef _CP_DEBUG_RHOG_RHOG_ char myFileName[100]; sprintf(myFileName, "Rho_Gspace_%d.out", thisIndex); std::vector< gridPoint > & dpoints = (*myPoints); FILE *fp = fopen(myFileName,"w"); for (int i = 0; i < numPoints; i++){ fprintf(fp," %d %d %d : %g %g\n", dpoints[i].d3, dpoints[i].d2, dpoints[i].d1, divRhoX[dpoints[i].offset].re, divRhoX[dpoints[i].offset].im); }//endfor fclose(fp); #endif //============================================================================ // I) Communicate rho(g) to RHoGHartExt to compute eext and hart part of vks // or print out that you are taking the day off //------------------------------------------------ // Hartree is on, send rhoG to the harteext-G chare #ifndef _CP_DEBUG_HARTEEXT_OFF_ // hartree is cooking //create first message to be able to copy RhoGHartMsg *msg, *base_msg = new (numPoints) RhoGHartMsg; complex *dest = base_msg->data; std::vector< gridPoint > & points = (*myPoints); for(int p = 0; p < numPoints; p++) { int off = points[p].offset; dest[p] = divRhoX[off]; } int nchareHartAtmT = config.nchareHartAtmT; for(int j = 0; j < nchareHartAtmT; j++) { if(j != (nchareHartAtmT - 1)) { msg = new (numPoints) RhoGHartMsg; CmiMemcpy(msg->data, base_msg->data, numPoints * sizeof(complex)); } else { msg = base_msg; } msg->size = numPoints; //------------------------------------------------ //RAZ: This is important: // This is spin modified logic to send to up // instance GHartExt Calc. // No way spin down should go there. // We are sending Grho from data_out //------------------------------------------------ if (mySpinIndex==0){ UrhoGHartExtProxy[thisInstance.proxyOffset](thisIndex,j).acceptData(msg); }else if(mySpinIndex==1){ UberCollection upinstance=thisInstance; // flip the spin upinstance.idxU.s= !upinstance.idxU.s; // get new offset int Offset2RhoUp=upinstance.setPO(); UrhoGHartExtProxy[Offset2RhoUp](thisIndex,j).acceptData(msg); }//endif spin logic }//endfor : atmType parallelization #else // Hartree is off, chill if(thisIndex == 0) { CkPrintf("EHART = OFF FOR DEBUGGING\n"); CkPrintf("EExt = OFF FOR DEBUGGING\n"); CkPrintf("EWALD_recip = OFF FOR DEBUGGING\n"); }//endif #endif //============================================================================ // III) Start grad corr computations if necessary #if CMK_TRACE_ENABLED double StartTime=CmiWallTimer(); #endif if(simReadOnly.cp_grad_corr_on != 0) { divRhoVksGspace(); } #if CMK_TRACE_ENABLED traceUserBracketEvent(divRhoVksGspace_, StartTime, CmiWallTimer()); #endif //============================================================================ //kick off NL if its our job launchNlG(); //--------------------------------------------------------------------------- }//end routine