本文整理汇总了C++中PatchMap::numPatches方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchMap::numPatches方法的具体用法?C++ PatchMap::numPatches怎么用?C++ PatchMap::numPatches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchMap
的用法示例。
在下文中一共展示了PatchMap::numPatches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recvResults
void ComputeGlobal::recvResults(ComputeGlobalResultsMsg *msg) {
DebugM(3,"Receiving results (" << msg->aid.size() << " forces, "
<< msg->newgdef.size() << " new group atoms) on client\n");
// set the forces only if we aren't going to resend the data
int setForces = !msg->resendCoordinates;
if(setForces) { // we are requested to
// Store forces to patches
PatchMap *patchMap = PatchMap::Object();
int numPatches = patchMap->numPatches();
AtomMap *atomMap = AtomMap::Object();
const Lattice & lattice = patchList[0].p->lattice;
ResizeArrayIter<PatchElem> ap(patchList);
Force **f = new Force*[numPatches];
FullAtom **t = new FullAtom*[numPatches];
for ( int i = 0; i < numPatches; ++i ) { f[i] = 0; t[i] = 0; }
Force extForce = 0.;
Tensor extVirial;
for (ap = ap.begin(); ap != ap.end(); ap++) {
(*ap).r = (*ap).forceBox->open();
f[(*ap).patchID] = (*ap).r->f[Results::normal];
t[(*ap).patchID] = (*ap).p->getAtomList().begin();
}
AtomIDList::iterator a = msg->aid.begin();
AtomIDList::iterator a_e = msg->aid.end();
ForceList::iterator f2 = msg->f.begin();
for ( ; a != a_e; ++a, ++f2 ) {
DebugM(1,"processing atom "<<(*a)<<", F="<<(*f2)<<"...\n");
/* XXX if (*a) is out of bounds here we get a segfault */
LocalID localID = atomMap->localID(*a);
if ( localID.pid == notUsed || ! f[localID.pid] ) continue;
Force f_atom = (*f2);
f[localID.pid][localID.index] += f_atom;
Position x_orig = t[localID.pid][localID.index].position;
Transform trans = t[localID.pid][localID.index].transform;
Position x_atom = lattice.reverse_transform(x_orig,trans);
extForce += f_atom;
extVirial += outer(f_atom,x_atom);
}
DebugM(1,"done with the loop\n");
// calculate forces for atoms in groups
Molecule *mol = Node::Object()->molecule;
AtomIDList::iterator g_i, g_e;
g_i = gdef.begin(); g_e = gdef.end();
ResizeArray<BigReal>::iterator gm_i = gmass.begin();
ForceList::iterator gf_i = msg->gforce.begin();
//iout << iDEBUG << "recvResults\n" << endi;
for ( ; g_i != g_e; ++g_i, ++gm_i, ++gf_i ) {
//iout << iDEBUG << *gf_i << '\n' << endi;
Vector accel = (*gf_i) / (*gm_i);
for ( ; *g_i != -1; ++g_i ) {
//iout << iDEBUG << *g_i << '\n' << endi;
LocalID localID = atomMap->localID(*g_i);
if ( localID.pid == notUsed || ! f[localID.pid] ) continue;
Force f_atom = accel * mol->atommass(*g_i);
f[localID.pid][localID.index] += f_atom;
Position x_orig = t[localID.pid][localID.index].position;
Transform trans = t[localID.pid][localID.index].transform;
Position x_atom = lattice.reverse_transform(x_orig,trans);
extForce += f_atom;
extVirial += outer(f_atom,x_atom);
}
}
DebugM(1,"done with the groups\n");
for (ap = ap.begin(); ap != ap.end(); ap++) {
(*ap).forceBox->close(&((*ap).r));
}
delete [] f;
delete [] t;
ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce);
ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial);
reduction->submit();
}
// done setting the forces
// Get reconfiguration if present
if ( msg->reconfig ) configure(msg->newaid, msg->newgdef);
// send another round of data if requested
if(msg->resendCoordinates) {
DebugM(3,"Sending requested data right away\n");
sendData();
}
delete msg;
DebugM(3,"Done processing results\n");
}
示例2: buildData
/**
* @brief Builds the data structures required for the load balancing strategies in NAMD.
*/
int NamdHybridLB::buildData(LDStats* stats) {
int n_pes = stats->nprocs();
PatchMap* patchMap = PatchMap::Object();
ComputeMap* computeMap = ComputeMap::Object();
const SimParameters* simParams = Node::Object()->simParameters;
BigReal bgfactor = simParams->ldbBackgroundScaling;
BigReal pmebgfactor = simParams->ldbPMEBackgroundScaling;
BigReal homebgfactor = simParams->ldbHomeBackgroundScaling;
int pmeOn = simParams->PMEOn;
int unLoadPme = simParams->ldbUnloadPME;
int pmeBarrier = simParams->PMEBarrier;
int unLoadZero = simParams->ldbUnloadZero;
int unLoadOne = simParams->ldbUnloadOne;
int unLoadIO= simParams->ldbUnloadOutputPEs;
// traversing the list of processors and getting their load information
int i, pe_no;
for (i=0; i<n_pes; ++i) {
pe_no = stats->procs[i].pe;
// BACKUP processorArray[i].Id = i;
processorArray[i].Id = pe_no; // absolute pe number
processorArray[i].available = true;
// BACKUP if ( pmeOn && isPmeProcessor(i) )
if ( pmeOn && isPmeProcessor(pe_no) ) {
processorArray[i].backgroundLoad = pmebgfactor * stats->procs[i].bg_walltime;
// BACKUP } else if (patchMap->numPatchesOnNode(i) > 0) {
} else if (patchMap->numPatchesOnNode(pe_no) > 0) {
processorArray[i].backgroundLoad = homebgfactor * stats->procs[i].bg_walltime;
} else {
processorArray[i].backgroundLoad = bgfactor * stats->procs[i].bg_walltime;
}
processorArray[i].idleTime = stats->procs[i].idletime;
processorArray[i].load = processorArray[i].computeLoad = 0.0;
}
// If I am group zero, then offload processor 0 and 1 in my group
if(stats->procs[0].pe == 0) {
if(unLoadZero) processorArray[0].available = false;
if(unLoadOne) processorArray[1].available = false;
}
// if all pes are Pme, disable this flag
if (pmeOn && unLoadPme) {
for (i=0; i<n_pes; i++) {
if(!isPmeProcessor(stats->procs[i].pe)) break;
}
if (i == n_pes) {
iout << iINFO << "Turned off unLoadPme flag!\n" << endi;
unLoadPme = 0;
}
}
if (pmeOn && unLoadPme) {
for (i=0; i<n_pes; i++) {
if ((pmeBarrier && i==0) || isPmeProcessor(stats->procs[i].pe))
processorArray[i].available = false;
}
}
// if all pes are output, disable this flag
#ifdef MEM_OPT_VERSION
if (unLoadIO) {
if (simParams->numoutputprocs == n_pes) {
iout << iINFO << "Turned off unLoadIO flag!\n" << endi;
unLoadIO = 0;
}
}
if (unLoadIO){
for (i=0; i<n_pes; i++) {
if (isOutputProcessor(stats->procs[i].pe))
processorArray[i].available = false;
}
}
#endif
// need to go over all patches to get all required proxies
int numPatches = patchMap->numPatches();
int totalLocalProxies = 0;
int totalProxies = 0;
for ( int pid=0; pid<numPatches; ++pid ) {
int neighborNodes[PatchMap::MaxOneAway + PatchMap::MaxTwoAway];
patchArray[pid].Id = pid;
patchArray[pid].numAtoms = 0;
patchArray[pid].processor = patchMap->node(pid);
const int numProxies =
#if 0 // USE_TOPOMAP - this function needs to be there for the hybrid case
requiredProxiesOnProcGrid(pid,neighborNodes);
#else
requiredProxies(pid, neighborNodes);
#endif
int numLocalProxies = 0;
for (int k=0; k<numProxies; k++) {
//.........这里部分代码省略.........
示例3: sendData
void ComputeGlobal::sendData()
{
DebugM(2,"sendData\n");
// Get positions from patches
PatchMap *patchMap = PatchMap::Object();
int numPatches = patchMap->numPatches();
AtomMap *atomMap = AtomMap::Object();
const Lattice & lattice = patchList[0].p->lattice;
ResizeArrayIter<PatchElem> ap(patchList);
CompAtom **x = new CompAtom*[numPatches];
FullAtom **t = new FullAtom*[numPatches];
for ( int i = 0; i < numPatches; ++i ) { x[i] = 0; t[i] = 0; }
int step = -1;
for (ap = ap.begin(); ap != ap.end(); ap++) {
x[(*ap).patchID] = (*ap).positionBox->open();
t[(*ap).patchID] = (*ap).p->getAtomList().begin();
step = (*ap).p->flags.step;
}
ComputeGlobalDataMsg *msg = new ComputeGlobalDataMsg;
msg->step = step;
AtomIDList::iterator a = aid.begin();
AtomIDList::iterator a_e = aid.end();
for ( ; a != a_e; ++a ) {
LocalID localID = atomMap->localID(*a);
if ( localID.pid == notUsed || ! x[localID.pid] ) continue;
msg->aid.add(*a);
Position x_orig = x[localID.pid][localID.index].position;
Transform trans = t[localID.pid][localID.index].transform;
msg->p.add(lattice.reverse_transform(x_orig,trans));
}
// calculate group centers of mass
Molecule *mol = Node::Object()->molecule;
AtomIDList::iterator g_i, g_e;
g_i = gdef.begin(); g_e = gdef.end();
ResizeArray<BigReal>::iterator gm_i = gmass.begin();
for ( ; g_i != g_e; ++g_i, ++gm_i ) {
Vector com(0,0,0);
for ( ; *g_i != -1; ++g_i ) {
LocalID localID = atomMap->localID(*g_i);
if ( localID.pid == notUsed || ! x[localID.pid] ) continue;
Position x_orig = x[localID.pid][localID.index].position;
Transform trans = t[localID.pid][localID.index].transform;
com += lattice.reverse_transform(x_orig,trans) * mol->atommass(*g_i);
}
com /= *gm_i;
DebugM(1,"Adding center of mass "<<com<<"\n");
msg->gcom.add(com);
}
for (ap = ap.begin(); ap != ap.end(); ap++) {
(*ap).positionBox->close(&(x[(*ap).patchID]));
}
msg->fid.swap(fid);
msg->tf.swap(totalForce);
fid.resize(0);
totalForce.resize(0);
delete [] x;
delete [] t;
DebugM(3,"Sending data (" << msg->aid.size() << " positions) on client\n");
comm->sendComputeGlobalData(msg);
}