Exemplo n.º 1
0
 /** Push back the vertices of cell i_w to the gain manager. */
 void pushBack(unsigned int whichPart, unsigned int i_w, const short* gain)
 {
   for (unsigned int k=0; k<getNumPartitions(); k++) {
     if (whichPart == k) continue;
     _gainBucket[k].pushBack(_vertexArray[k][i_w], gain[k]);
   }
 }
Exemplo n.º 2
0
int GModel::writeMSH(const std::string &name, double version, bool binary,
                     bool saveAll, bool saveParametric, double scalingFactor,
                     int elementStartNum, int saveSinglePartition,
                     bool append)
{
  if(version < 4.0 && getNumPartitions() > 0) {
    Msg::Warning("Saving a partitioned mesh in a format older than 4.0 may "
                 "cause information loss");
  }

  if(version < 3.0) {
    return _writeMSH2(name, version, binary, saveAll, saveParametric,
                      scalingFactor, elementStartNum, saveSinglePartition,
                      append, true);
  }
  else if(version < 4.0) {
    return _writeMSH3(name, version, binary, saveAll, saveParametric,
                      scalingFactor, elementStartNum, saveSinglePartition,
                      append);
  }
  else if(version < 5.0) {
    return _writeMSH4(name, version, binary, saveAll, saveParametric,
                      scalingFactor, append);
  }

  Msg::Error("Unknown MSH file version %g", version);
  return 0;
}
Exemplo n.º 3
0
int GModel::writePartitionedMSH(const std::string &baseName, double version,
                                bool binary, bool saveAll, bool saveParametric,
                                double scalingFactor)
{
  if(version < 4.0 && getNumPartitions() > 0) {
    Msg::Warning("Saving a partitioned mesh in a format older than 4.0 may "
                 "cause information loss");
  }

  if(version < 3.0) {
    return _writePartitionedMSH2(baseName, binary, saveAll, saveParametric,
                                 scalingFactor);
  }
  else if(version < 4.0) {
    return _writePartitionedMSH3(baseName, version, binary, saveAll,
                                 saveParametric, scalingFactor);
  }
  else if(version < 5.0) {
    return _writePartitionedMSH4(baseName, version, binary, saveAll,
                                 saveParametric, scalingFactor);
  }

  Msg::Error("Unknown MSH file version %g", version);
  return 0;
}
Exemplo n.º 4
0
 /** Update the gain changes of the neighbor vertex in whichPart */
 void updateNeighbor(unsigned int whichPart,  ///< in which partition
                     unsigned int i_w,    ///< the affected neighbor vertex
                     const short* deltaGain)  ///< the gain changes
 {
   if (_cellList[i_w].isLocked()) return;
   for (unsigned int k=0; k<getNumPartitions(); k++) {
     if (k == whichPart) continue;
     _gainBucket[k].modifyKeyLIFOBy(_vertexArray[k][i_w], deltaGain[k]);
   }
 }
Exemplo n.º 5
0
 /** Update the changes according to the move of vertex v from
     fromPart to toPart */  
 void updateMove(const FMMoveInfo& moveInfo,
                 const short* = 0)      ///< the gain changes (not used here)
 {
   const unsigned int fromPart = moveInfo._fromPart;
   const unsigned int i_v = moveInfo._i_v;
   for (unsigned int k=0; k<getNumPartitions(); k++) {
     if (fromPart == k) continue;
     _gainBucket[k].detach(_vertexArray[k][i_v]);
   }
 }
Exemplo n.º 6
0
inline void FMPWPartTmpl<GainTmpl>::
initGrouping2()
{
  vector<unsigned int> randVector(getNumPartitions());
  for (unsigned int k=0; k<getNumPartitions(); ++k) {
    _moveTo[k] = k;
    _groupMap[k] = 255;
    randVector[k] = k;
  }
  std::random_shuffle(randVector.begin(), randVector.end());
  for (unsigned int j=0; j<_numGroups; ++j) {
    const unsigned int i = _numGroups + j;
    _moveTo[randVector[j]] = randVector[i];
    _moveTo[randVector[i]] = randVector[j];
    _groupMap[randVector[j]] = j;
    _groupMap[randVector[i]] = j;
    _groupInvMap[j] = randVector[j];
  }
}
Exemplo n.º 7
0
unsigned int FMPWPartTmpl<GainTmpl>::
doPartitionOne(vector<unsigned char>& part) 
{
  if (isNoInit()) initDiff(part);
  else {
    initPart(part);
    _initCost = getNetlist().cutCost(part, getNumPartitions());
    //xxx std::cout << "InitCost: " << _initCost << '\n';
  }
  return doPartitionInternal(part);
}
Exemplo n.º 8
0
inline unsigned int FMPWPartTmpl<GainTmpl>::
doPartitionInternal(vector<unsigned char>& part) 
{
  typedef FMPartTmpl<FMBiPartCore, GainTmpl> PWPartMgrType; 
  typedef FMPartTmpl4<FMKWayPartCore4, FMKWayGainMgr2> RefineType; 

  unsigned int cost1 = _initCost;
  unsigned int cost = _initCost;

  RefineType rfMgr(getParam());
  rfMgr.setBalanceTol(getBalanceTol());
  rfMgr.setPValue(1);
  rfMgr.setQValue(10);
  rfMgr.setVerbosity(getVerbosity());
  rfMgr.setBoundType(getBoundType());
  rfMgr.noNeedSetHighFanoutNets();

  while (1) {
    initGrouping2();
    getNetlist().pairWisePhase1(part, _groupMap, _sGVec);
    //xxx int cost3 = cost;
    cost = cost1;

    for (unsigned int j=0; j<_numGroups; ++j) {
      const FMParam param(*_sGVec[j]);
      PWPartMgrType PWMgr(param);
      //xxx PWMgr.setBalanceTol(getBalanceTol());
      PWMgr.setUpperBound(getUpperBound());
      PWMgr.setLowerBound(getLowerBound());
      // PWMgr.setPValue(_pvalue);
      // PWMgr.setQValue(_qvalue);
      PWMgr.setVerbosity(getVerbosity());
      //xxx PWMgr.setBoundType(getBoundType());
      PWMgr.noNeedSetHighFanoutNets();
      PWMgr.setNoInit(cost);
      vector<unsigned char> pw_part;
      projectUp(part, pw_part, j);
      // cost = PWMgr.doPartitionOne(pw_part);
      boost::array<int, 64>& diff = getDiff();
      const unsigned int part0 = _groupInvMap[j];
      const unsigned int part1 = _moveTo[part0];
      int diff2[2];
      diff2[0] = diff[part0];
      diff2[1] = diff[part1];
      PWMgr.setDiff(diff2);
      cost = PWMgr.doPartitionOne4(pw_part);
      // PWMgr.doPartition(pw_part, 1);
      // cost = PWMgr.getBestCost();
      projectDown(part, pw_part, j);
      int* diff3 = PWMgr.getDiff();
      diff[part0] = diff3[0];
      diff[part1] = diff3[1];
      delete _sGVec[j];
    }
    // printDiff();
    // std::cout << "cost = " << cost << std::endl;

    assert(cost == getNetlist().cutCost(part, getNumPartitions()));
    //xxx initDiff(part);  

    rfMgr.setNoInit(cost); // only refine the solution
    rfMgr.setDiff(getDiff());
    cost1 = rfMgr.doPartitionOne4(part);
    // rfMgr.doPartition(part, 1);
    // cost1 = rfMgr.getBestCost();
    assert(cost1 == getNetlist().cutCost(part, getNumPartitions()));
    setDiff(rfMgr.getDiff());
    // printDiff();
    // std::cout << "cost1 = " << cost1 << std::endl;

    if (cost1 >= cost) break;
  }


  return cost1;
}