本文整理汇总了C++中Link::addTrans方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::addTrans方法的具体用法?C++ Link::addTrans怎么用?C++ Link::addTrans使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::addTrans方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: randomScheduleRed
//random schedule red
bool randomScheduleRed(PM* pPM, Job* pJob, float t){
//transmission of shuffle data
float inc;
int dataSize;
std::vector<PM*> blockPMs;
RedTask* tempRed = pJob->getUnassignedRed();
std::vector<MapTask*> maps = pJob -> getMapTasks();
std::vector<MapTask*>::iterator itMap = maps.begin();
while(itMap != maps.end()){
blockPMs.push_back((*itMap)->getPM());
++itMap;
}
std::vector<PM*>::iterator itBlockPM = blockPMs.begin();
while (itBlockPM != blockPMs.end()){
dataSize = (*itBlockPM)->getData(pJob->getID());
Link* pLink = (*itBlockPM)->getLink();
//inc = static_cast<float>(dataSize) * base_tx_time/static_cast<float>((defaultBlockSize * pJob->getTotalRedNum()));
pLink->addTrans(dataSize/pJob->getTotalRedNum());
//pLink->incrBusyTime(inc);
++itBlockPM;
}
//float incTime = base_tx_time * static_cast<float>(pJob->getShuffleBytes())/static_cast<float>(pJob->getTotalRedNum()*defaultBlockSize);
pPM->getLink()->addTrans(dataSize/pJob->getTotalRedNum());
//pPM->getLink()->incrBusyTime(incTime);
//get the delay
float delay = 0;
float maxDelay = 0;
itBlockPM = blockPMs.begin();
while(itBlockPM != blockPMs.end()){
delay = getTxTime(*itBlockPM, pPM);
if ( delay > maxDelay){
maxDelay = delay;
}
++itBlockPM;
}
redVM* tempVM = pPM->assignRed(tempRed, t);
float tt = t + redMap[getUniqueID(pJob->getID(),(tempRed)->getID())];
tt += maxDelay;
redTimeMap[tt] = tempVM;
return true;
}
示例2: scheduleRed
//schedule a reduce job
//To do: Should make the sum of probability of assign of all reduce tasks to be 1;
bool scheduleRed(PM* pPM, Job* pJob, float t){
// if (pPM->getNumAvailRedSlot() >0 ){
vector<RedTask*> reds = pJob->getRedTasks();
vector<RedTask*>::iterator itRed = reds.begin();
float tempProb;
float maxProb = 0;
RedTask* tempRed = 0;
while(itRed != reds.end()){
if(!(*itRed)->ifAssigned()){
tempProb = getProbOfAssign(*itRed, pPM);
if (tempProb > maxProb){
tempRed = *itRed;
maxProb = tempProb;
}
}
++itRed;
}
float prob = static_cast<float>(rand())/static_cast<float>(RAND_MAX);
if (maxProb > prob) {
//if (getUniqueID(pJob->getID(), tempRed->getID()) == 65001){
// cout <<"1"<<endl;
//}
cout<<"Scheduling red task "<<tempRed->getID()<<" of Job: "<<pJob->getID()<<" on PM: "<<pPM->getID()<<endl;
//transmission of shuffle data
float inc;
int dataSize;
std::vector<PM*> blockPMs;
Job* pJob = tempRed->getParentJob();
std::vector<MapTask*> maps = pJob -> getMapTasks();
std::vector<MapTask*>::iterator itMap = maps.begin();
while(itMap != maps.end()){
blockPMs.push_back((*itMap)->getPM());
++itMap;
}
std::vector<PM*>::iterator itBlockPM = blockPMs.begin();
while (itBlockPM != blockPMs.end()){
dataSize = (*itBlockPM)->getData(pJob->getID());
Link* pLink = (*itBlockPM)->getLink();
//inc = static_cast<float>(dataSize) * base_tx_time/static_cast<float>((defaultBlockSize * pJob->getTotalRedNum()));
// inc = static_cast<float>(dataSize)/defaultBlockSize * base_tx_time/pJob->getNumRedTasks();
//pLink->incrBusyTime(inc);
pLink->addTrans(dataSize/pJob->getTotalRedNum());
++itBlockPM;
}
// float incTime = static_cast<float>(pJob->getShuffleBytes())/(pJob->getNumRedTasks()*defaultBlockSize) * base_tx_time;
//float incTime = base_tx_time * static_cast<float>(pJob->getShuffleBytes())/static_cast<float>(pJob->getTotalRedNum()*defaultBlockSize);
//pPM->getLink()->incrBusyTime(incTime);
pPM->getLink()->addTrans(dataSize/pJob->getTotalRedNum());
//get the delay
float delay = 0;
float maxDelay = 0;
itBlockPM = blockPMs.begin();
while(itBlockPM != blockPMs.end()){
delay = getTxTime(*itBlockPM, pPM);
if ( delay > maxDelay){
maxDelay = delay;
}
++itBlockPM;
}
redVM* tempVM = pPM->assignRed(tempRed, t);
float tt = t + redMap[getUniqueID(pJob->getID(),(tempRed)->getID())];
tt += maxDelay;
redTimeMap[tt] = tempVM;
return true;
}
// }
return false;
}