本文整理汇总了C++中CkVec类的典型用法代码示例。如果您正苦于以下问题:C++ CkVec类的具体用法?C++ CkVec怎么用?C++ CkVec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CkVec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
// generate migrate message from stats->from_proc and to_proc
LBMigrateMsg * CentralLB::createMigrateMsg(LDStats* stats)
{
int i;
CkVec<MigrateInfo*> migrateInfo;
for (i=0; i<stats->n_objs; i++) {
LDObjData &objData = stats->objData[i];
int frompe = stats->from_proc[i];
int tope = stats->to_proc[i];
if (frompe != tope) {
// CkPrintf("[%d] Obj %d migrating from %d to %d\n",
// CkMyPe(),obj,pe,dest);
MigrateInfo *migrateMe = new MigrateInfo;
migrateMe->obj = objData.handle;
migrateMe->from_pe = frompe;
migrateMe->to_pe = tope;
migrateMe->async_arrival = objData.asyncArrival;
migrateInfo.insertAtEnd(migrateMe);
}
}
int migrate_count=migrateInfo.length();
LBMigrateMsg* msg = new(migrate_count,CkNumPes(),CkNumPes(),0) LBMigrateMsg;
msg->n_moves = migrate_count;
for(i=0; i < migrate_count; i++) {
MigrateInfo* item = (MigrateInfo*) migrateInfo[i];
msg->moves[i] = *item;
delete item;
migrateInfo[i] = 0;
}
return msg;
}
示例2: MapObjsToPe
/*
* Map objects to PE for load balance. It takes in a min heap of objects which
* can be transferred and finds suitable receiver PEs. The mapping is stored in
* obj_no and the corresponding entry in obj_pe_no indicates the receiver PE.
*/
void DistributedLB::MapObjsToPe(minHeap &objs, CkVec<int> &obj_no,
CkVec<int> &obj_pe_no) {
int p_id;
double p_load;
int rand_pe;
// While my load is more than the threshold, try to transfer objs
while (my_load > (thr_avg)) {
// If there is only one object, then nothing can be done to balance it.
if (objs_count < 2) break;
// Flag to indicate whether successful in finding a transfer
bool success = false;
// Get the smallest object
InfoRecord* obj = objs.deleteMin();
// No more objects to retrieve
if (obj == 0) break;
// If transferring this object makes this PE underloaded, then don't
// transfer
if ((my_load - obj->load) < (thr_avg)) {
break;
}
// Pick random PE based on the probability and the find is successful only
// if on transferring the object, that PE does not become overloaded
do {
rand_pe = PickRandReceiverPeIdx();
if (rand_pe == -1) break;
p_id = pe_no[rand_pe];
p_load = loads[rand_pe];
if ((p_load + obj->load) < avg_load) {
success = true;
}
kMaxTrials--;
} while (!success && (kMaxTrials > 0));
// No successful in finding a suitable PE to transfer the object
if (!success) {
break;
}
// Found an object and a suitable PE to transfer it to. Decrement the obj
// count and update the loads.
obj_no.insertAtEnd(obj->Id);
obj_pe_no.insertAtEnd(p_id);
objs_count--;
loads[rand_pe] += obj->load;
my_load -= obj->load;
// Send information to the receiver PE about this obj. This is necessary for
// ack as well as finding out how many objs are migrating in
thisProxy[p_id].InformMigration(obj->Id, CkMyPe(),
my_stats->objData[obj->Id].wallTime, false);
// This object is assigned, so we delete it from the heap
delete obj;
}
}
示例3: getEdgeAdaptAdj
void BulkAdapt::get_elemsToLock(adaptAdj startElem, adaptAdj **elemsToLock, int edgeID, int *count)
{
CkVec<adaptAdj>* nbrElems;
// find the elements adjacent to startElem along the edge edgeID
//BULK_DEBUG(CkPrintf("[%d] BulkAdapt::get_elemsToLock: calling getEdgeAdaptAdj on elem %d\n",partitionID,startElem.localID));
nbrElems = getEdgeAdaptAdj(meshID, startElem.localID, startElem.elemType,
edgeID);
// extract adjacencies from CkVec into array needed by the locking code
(*count) = nbrElems->size();
(*elemsToLock) = (adaptAdj *)malloc((*count + 1) * sizeof(adaptAdj));
for (int i=0; i<*count; i++) {
(*elemsToLock)[i] = (*nbrElems)[i];
}
// add the start element
(*elemsToLock)[*count] = startElem;
(*count)++;
/*
printf("Elems to lock: ");
for (int i=0; i<*count; i++) {
printf("(%d, %d, %d) ", (*elemsToLock)[i].partID, (*elemsToLock)[i].localID,
(*elemsToLock)[i].elemType);
}
printf("\n");
*/
}
示例4: readClause
static void readClause(StreamBuffer& in, par_SolverState& S, CkVec<par_Lit>& lits) {
int parsed_lit, var;
lits.removeAll();
for (;;){
parsed_lit = parseInt(in);
if (parsed_lit == 0) break;
var = abs(parsed_lit)-1;
S.occurrence[var]++;
if(parsed_lit>0)
S.positive_occurrence[var]++;
lits.push_back( par_Lit(parsed_lit));
}
}
示例5: 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]);
}
}
示例6: getRoccomPconn
/** Extract an IDXL_Side_t into Roccom format. */
static void getRoccomPconn(IDXL_Side_t is,int bias,CkVec<int> &pconn,const int *paneFmChunk)
{
int p,np=IDXL_Get_partners(is);
pconn.push_back(np);
for (p=0;p<np;p++) {
int chunk=IDXL_Get_partner(is,p);
int pane=1+chunk;
if(paneFmChunk) pane=paneFmChunk[chunk];
pconn.push_back(pane);
int n,nn=IDXL_Get_count(is,p);
pconn.push_back(nn); /* number of shared nodes */
for (n=0;n<nn;n++)
pconn.push_back(IDXL_Get_index(is,p,n)+1+bias); /* nodes are 1-based */
}
}
示例7: localCreateSection
void Patch::localCreateSection() {
#ifdef USE_SECTION_MULTICAST
CkVec<CkArrayIndex6D> elems;
for (int num=0; num<numNbrs; num++)
elems.push_back(CkArrayIndex6D(computesList[num][0], computesList[num][1], computesList[num][2], computesList[num][3], computesList[num][4], computesList[num][5]));
CkArrayID computeArrayID = computeArray.ckGetArrayID();
mCastSecProxy = CProxySection_Compute::ckNew(computeArrayID, elems.getVec(), elems.size());
CkMulticastMgr *mCastGrp = CProxy_CkMulticastMgr(mCastGrpID).ckLocalBranch();
mCastSecProxy.ckSectionDelegate(mCastGrp);
mCastGrp->setReductionClient(mCastSecProxy, new CkCallback(CkIndex_Patch::reduceForces(NULL), thisProxy(thisIndex.x, thisIndex.y, thisIndex.z)));
#endif
}
示例8: ImportFluidData_request
void System::ImportFluidData_request(const CkVec< pair<int,int> > &reqData, const int recvIndex)
{
assert(thisIndex != recvIndex);
const int nrecv = reqData.size();
assert(nrecv > 0);
MeshFluidGrad_msg *msg = new (nrecv, nrecv, nrecv, nrecv) MeshFluidGrad_msg;
msg->n = nrecv;
for (int i = 0; i < nrecv; i++)
{
const int local_id = reqData[i].first;
const int remote_id = reqData[i].second;
assert(local_id >= 0);
assert(local_id < local_n);
msg-> id_list[i] = remote_id;
msg->mesh_pnts[i] = mesh_pnts[local_id];
msg->Wrec_list[i] = Wrec_list[local_id];
#if 1
if (!ptcl_list[local_id].is_active())
{
Fluid Wi = Wrec_list[local_id].w;
const real dt = t_global - mesh_pnts[local_id].tbeg;
for (int k = 0; k < Fluid::NFLUID; k++)
Wi[k] += Wrec_list[local_id].t[k]*dt;
msg->Wrec_list[i].w = Wi;
}
#endif
msg->Wrec_minmax[i] = Wrec_minmax_list[local_id];
}
systemProxy[recvIndex].ImportFluidData_recv(msg);
}
示例9: assert
void System::ImportFluidPrimitives_request(const CkVec< pair<int,int> > &reqData, const int recvIndex)
{
assert(thisIndex != recvIndex);
const int nrecv = reqData.size();
assert(nrecv > 0);
CkVec< pair<int, pair<Fluid, MeshPoint> > > data2send(nrecv);
for (int i = 0; i < nrecv; i++)
{
const int local_id = reqData[i].first;
const int remote_id = reqData[i].second;
assert(local_id >= 0);
assert(local_id < local_n);
data2send[i].first = remote_id;
Fluid Wi = Wrec_list[local_id].w;
#if 1
if (!ptcl_list[local_id].is_active())
{
Fluid Wi = Wrec_list[local_id].w;
const real dt = t_global - mesh_pnts[local_id].tbeg;
for (int k = 0; k < Fluid::NFLUID; k++)
Wi[k] += Wrec_list[local_id].t[k]*dt;
}
#endif
data2send[i].second = std::make_pair(Wi, mesh_pnts[local_id]);
}
systemProxy[recvIndex].ImportFluidPrimitives_recv(data2send);
}
示例10: assignclause
void par_SolverState::assignclause(CkVec<par_Clause>& cls )
{
clauses.removeAll();
for(int i=0; i<cls.size(); i++)
{
clauses.push_back( cls[i]);
}
}
示例11: addToLists
//function to add a node to the list for a particular node
void addToLists(int *listIndex,CkVec<CkVec<int> > &lists,int chunk,int node){
if(listIndex[chunk] == -1){
CkVec<int> tmpVec;
int index = lists.push_back_v(tmpVec);
listIndex[chunk] = index;
}
CkVec<int> &vec = lists[listIndex[chunk]];
vec.push_back(node);
}
示例12: userBracketEvent
void TraceBluegene::userBracketEvent(const char* name, double bt, double et, void** parentLogPtr, CkVec<void*> bgLogList){
if (!genTimeLog) return;
BgTimeLog* newLog = new BgTimeLog(_threadEP,name,bt,et);
newLog->addBackwardDeps(bgLogList);
CmiAssert(bgLogList.size()>0);
newLog->objId = ((BgTimeLog*)bgLogList[0])->objId; // for sdag
*parentLogPtr = newLog;
tTIMELINEREC.logEntryInsert(newLog);
}
示例13: collectCommData
// find sender comms
void HybridBaseLB::collectCommData(int objIdx, CkVec<LDCommData> &comms, int atlevel)
{
LevelData *lData = levelData[atlevel];
LDStats *statsData = lData->statsData;
LDObjData &objData = statsData->objData[objIdx];
for (int com=0; com<statsData->n_comm; com++) {
LDCommData &cdata = statsData->commData[com];
if (cdata.from_proc()) continue;
if (cdata.sender.objID() == objData.objID() && cdata.sender.omID() == objData.omID())
comms.push_back(cdata);
}
}
示例14: nextUnoccupied
//Find next un-occupied global number:
int nextUnoccupied(void) {
while (occupiedBefore<occupied.size()) {
if (occupied[occupiedBefore]==0)
return occupiedBefore;
else occupiedBefore++;
}
/* occupiedBefore==occupied.size(), so add to end of list */
occupied.push_back(1);
return occupiedBefore;
}
示例15: mark
/// Mark this entity's global numbers as used:
void mark(FEM_Entity &src) {
int l,len=src.size();
for (l=0;l<len;l++) {
int g=src.getGlobalno(l);
if (g!=-1) {
while (occupied.size()<=g) { //Make room for this marker
occupied.push_back(0);
}
//FIXME: make sure element global numbers aren't repeated
// (tough because *node* global numbers may be repeated)
occupied[g]=1;
}
}
}