Commit 55566879 authored by Robert Ricci's avatar Robert Ricci

Change around some data structures to make certain functions faster -

turns out that getting iterators to the STL hash_* data structures is
really slow, so for some that won't be very big, use the non-hash
version.

Buys something like a 30% speedup for large topologies.
parent f7fc7ff3
......@@ -49,8 +49,8 @@ static float delta = 2;
static float FD_VIOLATION_WEIGHT = 1.0;
// Number of runs to spend melting
static int melt_trans = 500;
static int min_neighborhood_size = 500;
static int melt_trans = 1000;
static int min_neighborhood_size = 1000;
static float temp_rate = 0.9;
......
......@@ -7,6 +7,8 @@
#ifndef __PCLASS_H
#define __PCLASS_H
#include<map>
// Declared in assign.cc - indicated whether or not we should use pclasses
extern bool use_pclasses;
......@@ -64,7 +66,7 @@ class tb_pclass {
public:
tb_pclass() : name(), size(0), used(0), refcount(0) {;}
typedef hash_map<crope,tb_pnodelist*> pclass_members_map;
typedef map<crope,tb_pnodelist*> pclass_members_map;
typedef hash_set<tb_pnode*,hashptr<tb_pnode*> > tb_pnodeset;
typedef hash_map<crope,tb_pnodeset*> pclass_members_set;
......
......@@ -8,6 +8,7 @@
#define __PHYSICAL_H
#include "common.h"
#include <set>
// Icky, but I can't include virtual.h here
class tb_vnode;
......@@ -50,7 +51,7 @@ typedef graph_traits<tb_sgraph>::vertex_iterator svertex_iterator;
typedef graph_traits<tb_sgraph>::edge_iterator sedge_iterator;
typedef graph_traits<tb_sgraph>::out_edge_iterator soedge_iterator;
typedef hash_set<pvertex,hashptr<void*> > pvertex_set;
typedef set<pvertex> pvertex_set;
typedef hash_map<tb_pnode*,pvertex,hashptr<tb_pnode*> > pnode_pvertex_map;
typedef hash_map<crope,pvertex> name_pvertex_map;
typedef vector<svertex> switch_pred_map;
......
......@@ -1242,36 +1242,44 @@ double fd_score(tb_vnode *vnode,tb_pnode *pnode,int &fd_violated)
double value;
tb_vnode::desires_map::iterator desire_it;
tb_pnode::features_map::iterator feature_it;
for (desire_it = vnode->desires.begin();
desire_it != vnode->desires.end();
desire_it++) {
feature_it = pnode->features.find((*desire_it).first);
SDEBUG(cerr << " desire = " << (*desire_it).first << " " <<
(*desire_it).second << endl);
if (feature_it == pnode->features.end()) {
// Unmatched desire. Add cost.
SDEBUG(cerr << " unmatched" << endl);
value = (*desire_it).second;
fd_score += SCORE_DESIRE*value;
if (value >= FD_VIOLATION_WEIGHT) {
fd_violated++;
// Optimize the case where the vnode has no desires
if (!vnode->desires.empty()) {
for (desire_it = vnode->desires.begin();
desire_it != vnode->desires.end();
desire_it++) {
feature_it = pnode->features.find((*desire_it).first);
SDEBUG(cerr << " desire = " << (*desire_it).first << " " <<
(*desire_it).second << endl);
if (feature_it == pnode->features.end()) {
// Unmatched desire. Add cost.
SDEBUG(cerr << " unmatched" << endl);
value = (*desire_it).second;
fd_score += SCORE_DESIRE*value;
if (value >= FD_VIOLATION_WEIGHT) {
fd_violated++;
}
}
}
}
for (feature_it = pnode->features.begin();
feature_it != pnode->features.end();++feature_it) {
desire_it = vnode->desires.find((*feature_it).first);
SDEBUG(cerr << " feature = " << (*feature_it).first
<< " " << (*feature_it).second << endl);
if (desire_it == vnode->desires.end()) {
// Unused feature. Add weight
SDEBUG(cerr << " unused" << endl);
value = (*feature_it).second;
fd_score+=SCORE_FEATURE*value;
if (value >= FD_VIOLATION_WEIGHT) {
fd_violated++;
// Optimize the case where the pnode has no features
if (!pnode->features.empty()) {
for (feature_it = pnode->features.begin();
feature_it != pnode->features.end();++feature_it) {
desire_it = vnode->desires.find((*feature_it).first);
SDEBUG(cerr << " feature = " << (*feature_it).first
<< " " << (*feature_it).second << endl);
if (desire_it == vnode->desires.end()) {
// Unused feature. Add weight
SDEBUG(cerr << " unused" << endl);
value = (*feature_it).second;
fd_score+=SCORE_FEATURE*value;
if (value >= FD_VIOLATION_WEIGHT) {
fd_violated++;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment