本文整理汇总了C++中CkVec::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ CkVec::resize方法的具体用法?C++ CkVec::resize怎么用?C++ CkVec::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CkVec
的用法示例。
在下文中一共展示了CkVec::resize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNodeLocalIndices
void ComlibSectionInfo::getNodeLocalIndices(int nindices,
CkArrayIndex *idxlist,
CkArrayID &destArrayID,
CkVec<CkArrayIndex> &idx_vec){
int acount = 0;
idx_vec.resize(0);
CkArray *a = (CkArray *)_localBranch(destArrayID);
for(acount = 0; acount < nindices; acount++){
//int p = ComlibGetLastKnown(destArrayID, idxlist[acount]);
int p = a->lastKnown(idxlist[acount]);
if(p == CkMyPe())
idx_vec.insertAtEnd(idxlist[acount]);
}
}
示例2: removeNonMigratable
// rebuild LDStats and remove all non-migratble objects and related things
void CentralLB::removeNonMigratable(LDStats* stats, int count)
{
int i;
// check if we have non-migratable objects
int have = 0;
for (i=0; i<stats->n_objs; i++)
{
LDObjData &odata = stats->objData[i];
if (!odata.migratable) {
have = 1; break;
}
}
if (have == 0) return;
CkVec<LDObjData> nonmig;
CkVec<int> new_from_proc, new_to_proc;
nonmig.resize(stats->n_migrateobjs);
new_from_proc.resize(stats->n_migrateobjs);
new_to_proc.resize(stats->n_migrateobjs);
int n_objs = 0;
for (i=0; i<stats->n_objs; i++)
{
LDObjData &odata = stats->objData[i];
if (odata.migratable) {
nonmig[n_objs] = odata;
new_from_proc[n_objs] = stats->from_proc[i];
new_to_proc[n_objs] = stats->to_proc[i];
n_objs ++;
}
else {
stats->procs[stats->from_proc[i]].bg_walltime += odata.wallTime;
#if CMK_LB_CPUTIMER
stats->procs[stats->from_proc[i]].bg_cputime += odata.cpuTime;
#endif
}
}
CmiAssert(stats->n_migrateobjs == n_objs);
stats->makeCommHash();
CkVec<LDCommData> newCommData;
newCommData.resize(stats->n_comm);
int n_comm = 0;
for (i=0; i<stats->n_comm; i++)
{
LDCommData& cdata = stats->commData[i];
if (!cdata.from_proc())
{
int idx = stats->getSendHash(cdata);
CmiAssert(idx != -1);
if (!stats->objData[idx].migratable) continue;
}
switch (cdata.receiver.get_type()) {
case LD_PROC_MSG:
break;
case LD_OBJ_MSG: {
int idx = stats->getRecvHash(cdata);
if (stats->complete_flag)
CmiAssert(idx != -1);
else if (idx == -1) continue; // receiver not in this group
if (!stats->objData[idx].migratable) continue;
break;
}
case LD_OBJLIST_MSG: // object message FIXME add multicast
break;
}
newCommData[n_comm] = cdata;
n_comm ++;
}
if (n_objs != stats->n_objs) CmiPrintf("Removed %d nonmigratable %d comms - n_objs:%d migratable:%d\n", stats->n_objs-n_objs, stats->n_objs, stats->n_migrateobjs, stats->n_comm-n_comm);
// swap to new data
stats->objData = nonmig;
stats->from_proc = new_from_proc;
stats->to_proc = new_to_proc;
stats->n_objs = n_objs;
stats->commData = newCommData;
stats->n_comm = n_comm;
stats->deleteCommHash();
stats->makeCommHash();
}