Example #1
0
AddrType LSQVPC::replayCheck(DInst *dinst)//return non-zero if replay needed
  /* dinst got executed (out-of-order) {{{1 */
{
  AddrType tag = calcWord(dinst);
  std::multimap<AddrType, DInst*>::iterator instIt; 
  //instIt = instMap.begin();
  instIt = instMap.find(tag);
  //AddrType storefound = 0;
  //while(instIt != instMap.end()){
  while(instIt->first==tag){
    if(instIt->first != tag){
      instIt++;
      continue;
    }
    if(instIt->second->getID() < dinst->getID()){
      if(instIt->second->getAddr()==dinst->getAddr()){
        LSQVPC_replays.inc(dinst->getStatsFlag());
        return 1; 
      }
    }
    //storefound = instIt->second->getPC();
    //if(instIt->second->getData()==dinst->getData()){
    //  return 0; //no replay needed
    //}
    instIt++;
  }
  return 0;
  //return storefound;
}
Example #2
0
void LDSTQ::insert(DInst *dinst)
{
  I(inflightInsts.find(dinst) == inflightInsts.end());
  instMap[calcWord(dinst)].push_back(dinst);
  
  inflightInsts.insert(dinst);
}
Example #3
0
void LDSTBuffer::getStoreEntry(DInst *dinst) 
{
  I( dinst->getInst()->isStore() );

#ifdef LDSTBUFFER_IGNORE_DEPS
  return;
#endif

  EntryType::iterator sit = stores.find(calcWord(dinst));
  if (sit != stores.end()) {
    DInst *pdinst = sit->second;
    I(pdinst->getInst()->isStore());
    if (!pdinst->hasPending() && dinst->getContextId() == pdinst->getContextId())
      pdinst->setDeadStore();
  }

  stores[calcWord(dinst)] = dinst;
}
Example #4
0
bool LDSTQ::executed(DInst *dinst)
{
    if(dinst->isDeadInst())
        return false;

    bool doReplay = false;
    I(inflightInsts.find(dinst) != inflightInsts.end());

    const Instruction *inst = dinst->getInst();
    AddrDInstQMap::iterator addrIt = instMap.find(calcWord(dinst));

    I(addrIt != instMap.end());

    dinst->markResolved();

    bool beforeInst = true;

    DInstQueue::iterator instIt = addrIt->second.end();
    instIt--;
    while(instIt != addrIt->second.begin()) {
        DInst *qdinst = *instIt;
        if(qdinst == dinst)
            beforeInst = false;

        const Instruction *qinst = qdinst->getInst();

        if(beforeInst && qdinst->isResolved()) {
            if(inst->isLoad() && qinst->isLoad()) {
                ldldViolations.inc();
                doReplay = true;
                if(!dinst->isDeadInst())
                    gproc->replay(qdinst);
            } else if(inst->isStore() && qinst->isStore()) {
                ststViolations.inc();
            } else if(inst->isStore() && qinst->isLoad()) {
                stldViolations.inc();
                doReplay = true;
                if(!dinst->isDeadInst())
                    gproc->replay(qdinst);
            }
        }


        if(!beforeInst && inst->isLoad()
                && qinst->isStore() && qdinst->isResolved()) {
#ifdef LDSTQ_FWD
            dinst->setLoadForwarded();
#endif
            stldForwarding.inc();
            break; // found if forwarded no need to check the rest of the entries
        }

        instIt--;
    }

    return doReplay;
}
Example #5
0
// Для всех слов длинна которых больше MIN_LENGTH но меньше MAX_LENGTH
void calcAllWords(std::vector<Word> &dict){
	const size_t size = dict.size();

	for(size_t wordId = 0; wordId < size; ++wordId){
		if((dict[wordId].length() >= MIN_LENGTH) && (dict[wordId].length() <= MAX_LENGTH)){
			calcWord(dict[wordId], dict);
			std::cout<<"calculated ["<<wordId+1<<" / "<<size<<"] ("<<(int)((((double)(wordId+1))/size)*100)<<"%)\r";
		}
	}
	std::cout<<"\n";
}
Example #6
0
void LDSTBuffer::storeLocallyPerformed(DInst *dinst) 
{
  I(dinst->getInst()->isStore());

#ifdef LDSTBUFFER_IGNORE_DEPS
  return;
#endif

  EntryType::iterator sit = stores.find(calcWord(dinst));
  if (sit == stores.end()) 
    return; // accross processors stores can be removed out-of-order
 
  if (sit->second == dinst)
    stores.erase(sit);
}
Example #7
0
void LDSTBuffer::getLoadEntry(DInst *dinst) 
{
  I(dinst->getInst()->isLoad());

#ifdef LDSTBUFFER_IGNORE_DEPS
  return;
#endif
    
  // LOAD
  EntryType::iterator sit = stores.find(calcWord(dinst));
  if (sit == stores.end())
    return;

  DInst *pdinst = sit->second;
  I(pdinst->getInst()->isStore());

#if defined(TASKSCALAR) && !defined(TS_CAVA)
  if (dinst->getVersionRef() != pdinst->getVersionRef())
    return;
#else
  if (dinst->getContextId() != pdinst->getContextId()) {
    // FIXME2: In a context switch the same processor may have two different
    // PIDs

    // Different processor or window. Queue the instruction even if executed
    dinst->setDepsAtRetire();
    I(pdinst->getInst()->getAddr() != dinst->getInst()->getAddr());
    pdinst->addFakeSrc(dinst);

    GLOG(DEBUG2, "FORWARD pc=0x%x [addr=0x%x] (%p)-> pc=0x%x [addr=0x%x] (%p)"
	,(int)pdinst->getInst()->getAddr() , (int)pdinst->getVaddr(), pdinst
	,(int)dinst->getInst()->getAddr()  , (int)dinst->getVaddr(), dinst);
    return;
  }
#endif

#ifndef LDSTQ_FWD
  dinst->setLoadForwarded();
#endif
  if (!pdinst->isExecuted()) {
    I(pdinst->getInst()->getAddr() != dinst->getInst()->getAddr());
    pdinst->addFakeSrc(dinst);
  }
}
Example #8
0
void LSQVPC::remove(DInst *dinst)
  /* Remove from the LSQ {{{1 (in-order) */
{
  I(dinst->getAddr());
  std::multimap<AddrType, DInst*>::iterator instIt; 
  //instIt = instMap.begin();
  AddrType tag = calcWord(dinst);
  instIt = instMap.find(tag);
  //while(instIt != instMap.end()){
  while(instIt->first==tag){
    if(instIt->second == dinst) {
      instMap.erase(instIt);
      return;
    }
    instIt++;
    if (instIt == instMap.end())
      return;
  }
}
Example #9
0
int main(void) {
    int cases = getInt();
    for (int cc=0;cc<cases;cc++) {
        root.words = 0;
        FOR(i, MAX_LETTER) if (root.children[i] != NULL) {
            delete root.children[i];
            root.children[i] = NULL;
        }

        int n = getInt();
        int total = 0;
        FOR(i, n) {
            scanf("%s", word);
            addWord(word);
            total += calcWord(word);
        }

        printf("Case #%d: %d\n", cc + 1, total);
    }
Example #10
0
void LDSTQ::remove(DInst *dinst)
{
  I(inflightInsts.find(dinst) != inflightInsts.end());
  AddrDInstQMap::iterator addrIt = instMap.find(calcWord(dinst));
  
  I(addrIt != instMap.end());

  DInstQueue::iterator instIt = addrIt->second.begin();
  while(instIt != addrIt->second.end()) {
    if(*instIt == dinst)
      break;
    instIt++;
  }

  I(instIt != addrIt->second.end());
  addrIt->second.erase(instIt);

  if(addrIt->second.size() == 0)
    instMap.erase(addrIt);
  
  inflightInsts.erase(dinst);
}
Example #11
0
DInst *LSQFull::executing(DInst *dinst)
  /* dinst got executed (out-of-order) {{{1 */
{
  I(dinst->getAddr());

  AddrType tag = calcWord(dinst);

  const Instruction *inst = dinst->getInst();
  DInst *faulty = 0;

#if 0
  AddrDInstQMap::const_iterator instIt = instMap.begin();
  I(instIt != instMap.end());

  I(!dinst->isExecuted());

  while(instIt != instMap.end()) {
    if (instIt->first != tag){
      instIt++;
      continue; 
    }
#endif
  std::pair<AddrDInstQMap::iterator, AddrDInstQMap::iterator> ret;
  ret = instMap.equal_range(tag);
  for (AddrDInstQMap::iterator instIt=ret.first; instIt!=ret.second; ++instIt) {
    I(instIt->first == tag);

    //inst->dump("Executed");
    DInst *qdinst = instIt->second;
    if(qdinst == dinst) {
      continue;
    }

    const Instruction *qinst  = qdinst->getInst();

    //bool beforeInst = qdinst->getID() < dinst->getID();
    bool oooExecuted = qdinst->getID() > dinst->getID();
    if(oooExecuted){

      if(qdinst->isExecuted() && qdinst->getPC() != dinst->getPC()) { 

        if(inst->isStore() && qinst->isLoad()) { 
          if (faulty == 0)
            faulty = qdinst; 
          else if (faulty->getID() < qdinst->getID())
            faulty = qdinst;
        }
      }
    }else{
      if (!dinst->isLoadForwarded() && inst->isLoad() && qinst->isStore() && qdinst->isExecuted()) {
        dinst->setLoadForwarded();
        stldForwarding.inc(dinst->getStatsFlag());
      }
    }
  }

  I(!dinst->isExecuted()); // first clear, then mark executed
  return faulty;
}
/* }}} */

void LSQFull::remove(DInst *dinst)
  /* Remove from the LSQ {{{1 (in-order) */
{
  I(dinst->getAddr());

 //const Instruction *inst = dinst->getInst();

  std::pair<AddrDInstQMap::iterator,AddrDInstQMap::iterator> rangeIt;
  //rangeIt = instMap.equal_range(calcWord(dinst));  
  AddrDInstQMap::iterator instIt = instMap.begin();

  //for(AddrDInstQMap::iterator it = rangeIt.first; it != rangeIt.second ; it++) {
  while(instIt != instMap.end()){
    if(instIt->second == dinst) {
      instMap.erase(instIt);
      return;
    }
    instIt++;
  }
}
Example #12
0
void LSQFull::insert(DInst *dinst)
  /* Insert dinst in LSQ (in-order) {{{1 */
{
  I(dinst->getAddr());
  instMap.insert(std::pair<AddrType, DInst *>(calcWord(dinst),dinst));
}