Example #1
0
TrafficManager::TrafficManager( const Configuration &config, Network *net , int u_id)
    : Module( 0, "traffic_manager" )
{
    int s;
    ostringstream tmp_name;
    string sim_type, priority;

    uid = u_id;
    _net    = net;
    _cur_id = 0;

    _sources = _net->NumSources( );
    _dests   = _net->NumDests( );

    // ============ Message priorities ============

    config.GetStr( "priority", priority );

    _classes = 1;

    if ( priority == "class" ) {
        _classes  = 2;
        _pri_type = class_based;
    } else if ( priority == "age" ) {
        _pri_type = age_based;
    } else if ( priority == "none" ) {
        _pri_type = none;
    } else {
        Error( "Unknown priority " + priority );
    }

    // ============ Injection VC states  ============

    _buf_states = new BufferState * [_sources];

    for ( s = 0; s < _sources; ++s ) {
        tmp_name << "buf_state_" << s;
        _buf_states[s] = new BufferState( config, this, tmp_name.str( ) );
        tmp_name.seekp( 0, ios::beg );
    }

    // ============ Injection queues ============

    _voqing = config.GetInt( "voq" );

    if ( _voqing ) {
        _use_lagging = false;
    } else {
        _use_lagging = true;
    }

    _time               = 0;
    _warmup_time        = -1;
    _drain_time         = -1;
    _empty_network      = false;

    _measured_in_flight = 0;
    _total_in_flight    = 0;

    if ( _use_lagging ) {
        _qtime    = new int * [_sources];
        _qdrained = new bool * [_sources];
    }

    if ( _voqing ) {
        _voq         = new list<Flit *> * [_sources];
        _active_list = new list<int> [_sources];
        _active_vc   = new bool * [_sources];
    }

    _partial_packets = new list<Flit *> * [_sources];

    for ( s = 0; s < _sources; ++s ) {
        if ( _use_lagging ) {
            _qtime[s]    = new int [_classes];
            _qdrained[s] = new bool [_classes];
        }

        if ( _voqing ) {
            _voq[s]       = new list<Flit *> [_dests];
            _active_vc[s] = new bool [_dests];
        }

        _partial_packets[s] = new list<Flit *> [_classes];
    }

    _split_packets = config.GetInt( "split_packets" );

    credit_return_queue = new queue<Flit *> [_sources];

    // ============ Reorder queues ============

    _reorder = config.GetInt( "reorder" ) ? true : false;

    if ( _reorder ) {
        _inject_sqn = new int * [_sources];
        _rob_sqn    = new int * [_sources];
        _rob_sqn_max = new int * [_sources];
        _rob        = new priority_queue<Flit *, vector<Flit *>, flitp_compare> * [_sources];

        for ( int i = 0; i < _sources; ++i ) {
            _inject_sqn[i] = new int [_dests];
            _rob_sqn[i]    = new int [_dests];
            _rob_sqn_max[i] = new int [_dests];
            _rob[i]        = new priority_queue<Flit *, vector<Flit *>, flitp_compare> [_dests];

            for ( int j = 0; j < _dests; ++j ) {
                _inject_sqn[i][j] = 0;
                _rob_sqn[i][j]    = 0;
                _rob_sqn_max[i][j] = 0;
            }
        }

        _rob_pri = new int [_dests];

        for ( int i = 0; i < _dests; ++i ) {
            _rob_pri[i] = 0;
        }
    }

    // ============ Statistics ============

    _latency_stats   = new Stats * [_classes];
    _overall_latency = new Stats * [_classes];

    for ( int c = 0; c < _classes; ++c ) {
        tmp_name << "latency_stat_" << c;
        _latency_stats[c] = new Stats( this, tmp_name.str( ), 1.0, 1000 );
        tmp_name.seekp( 0, ios::beg );

        tmp_name << "overall_latency_stat_" << c;
        _overall_latency[c] = new Stats( this, tmp_name.str( ), 1.0, 1000 );
        tmp_name.seekp( 0, ios::beg );
    }

    _pair_latency     = new Stats * [_dests];
    _accepted_packets = new Stats * [_dests];

    for ( int i = 0; i < _dests; ++i ) {
        tmp_name << "pair_stat_" << i;
        _pair_latency[i] = new Stats( this, tmp_name.str( ), 1.0, 250 );
        tmp_name.seekp( 0, ios::beg );

        tmp_name << "accepted_stat_" << i;
        _accepted_packets[i] = new Stats( this, tmp_name.str( ) );
        tmp_name.seekp( 0, ios::beg );
    }

    _hop_stats            = new Stats( this, "hop_stats", 1.0, 20 );;
    _overall_accepted     = new Stats( this, "overall_acceptance" );
    _overall_accepted_min = new Stats( this, "overall_min_acceptance" );

    if ( _reorder ) {
        _rob_latency = new Stats( this, "rob_latency", 1.0, 1000 );
        _rob_size    = new Stats( this, "rob_size", 1.0, 250 );
    }

    _flit_timing = config.GetInt( "flit_timing" );

    // ============ Simulation parameters ============

    _load = config.GetFloat( "injection_rate" );
    _packet_size = config.GetInt( "const_flits_per_packet" );

    _total_sims = config.GetInt( "sim_count" );

    _internal_speedup = config.GetFloat( "internal_speedup" );
    _partial_internal_cycles = 0.0;

    _traffic_function  = NULL; // GetTrafficFunction( config ); // Not used by gpgpusim
    _routing_function  = GetRoutingFunction( config );
    _injection_process = NULL; // GetInjectionProcess( config ); // Not used by gpgpusim

    config.GetStr( "sim_type", sim_type );

    if ( sim_type == "latency" ) {
        _sim_mode = latency;
    } else if ( sim_type == "throughput" ) {
        _sim_mode = throughput;
    } else {
        Error( "Unknown sim_type " + sim_type );
    }

    _sample_period   = config.GetInt( "sample_period" );
    _max_samples     = config.GetInt( "max_samples" );
    _warmup_periods  = config.GetInt( "warmup_periods" );
    _latency_thres   = config.GetFloat( "latency_thres" );
    _include_queuing = config.GetInt( "include_queuing" );
}
Example #2
0
IQRouterBase::IQRouterBase( const Configuration& config,
		Module *parent, const string & name, int id,
		int inputs, int outputs )
: Router( config, parent, name, id, inputs, outputs ),
  bufferMonitor(inputs),
  switchMonitor(inputs, outputs)
{
	ostringstream vc_name;

	_vcs         = config.GetInt( "num_vcs" );
	_vc_size     = config.GetInt( "vc_buf_size" );

	_routing_delay    = config.GetInt( "routing_delay" );
	_vc_alloc_delay   = config.GetInt( "vc_alloc_delay" );
	_sw_alloc_delay   = config.GetInt( "sw_alloc_delay" );

	// Routing
	_rf = GetRoutingFunction( config );

	// Alloc VC's
	_vc.resize(_inputs);
	for ( int i = 0; i < _inputs; ++i ) {
		_vc[i].resize(_vcs);
		for (int j = 0; j < _vcs; ++j ) {
			_vc[i][j] = new VC(config, _outputs);
			vc_name << "vc_i" << i << "_v" << j;
			_vc[i][j]->SetName( this, vc_name.str( ) );
			vc_name.str("");
		}
	}

	// Alloc next VCs' buffer state
	_next_vcs.resize(_outputs);
	for (int j = 0; j < _outputs; ++j) {
		_next_vcs[j] = new BufferState( config );
		vc_name << "next_vc_o" << j;
		_next_vcs[j]->SetName( this, vc_name.str( ) );
		vc_name.str("");
	}
	/*_next_vcs[_outputs]=new BufferState(config);
	vc_name<<"drain_"<<_outputs;
	_next_vcs[_outputs]->SetName(this, vc_name.str());*/
	vc_name.str("");
	// Alloc pipelines (to simulate processing/transmission delays)
	_crossbar_pipe =
			new PipelineFIFO<Flit>( this, "crossbar_pipeline", _outputs*_output_speedup,
					_st_prepare_delay + _st_final_delay );

	_credit_pipe =
			new PipelineFIFO<Credit>( this, "credit_pipeline", _inputs,
					_credit_delay );

	// Input and output queues
	//_input_buffer.resize(_inputs);
	_output_buffer.resize(_outputs);

	_in_cred_buffer.resize(_inputs);
	//_out_cred_buffer.resize(_outputs);

	// Switch configuration (when held for multiple cycles)
	_hold_switch_for_packet = config.GetInt( "hold_switch_for_packet" );
	_switch_hold_in.resize(_inputs*_input_speedup, -1);
	_switch_hold_out.resize(_outputs*_output_speedup, -1);
	_switch_hold_vc.resize(_inputs*_input_speedup, -1);

	_received_flits.resize(_inputs);
	_sent_flits.resize(_outputs);
	ResetFlitStats();
}
Example #3
0
IQRouter::IQRouter(const Configuration& config, Module *parent, string name,
		int id, int inputs, int outputs) :
	Router(config, parent, name, id, inputs, outputs)
{
	string alloc_type;
	ostringstream vc_name;

	_vcs = config.GetInt("num_vcs");
	_vc_size = config.GetInt("vc_buf_size");

	// Routing

	_rf = GetRoutingFunction(config);

	// Alloc VC's

	_vc = new VC *[_inputs];

	for (int i = 0; i < _inputs; ++i)
	{
		//_vc[i] = new VC[_vcs](config, _outputs);
		_vc[i] = new VC[_vcs];

		for (int v = 0; v < _vcs; ++v)
		{
			_vc[i][v].Init(config, _outputs);

			// Name the vc modules
			vc_name << "vc_i" << i << "_v" << v;
			_vc[i][v].SetName(this, vc_name.str());
			vc_name.seekp(0, ios::beg);
		}
	}

	// Alloc next VCs' buffer state

	//_next_vcs = new BufferState[_outputs](config);
	_next_vcs = new BufferState[_outputs];

	for (int o = 0; o < _outputs; ++o)
	{
		_next_vcs[o].Init(config);

		vc_name << "next_vc_o" << o;
		_next_vcs[o].SetName(this, vc_name.str());
		vc_name.seekp(0, ios::beg);
	}

	// Alloc allocators

	config.GetStr("vc_allocator", alloc_type);
	_vc_allocator = Allocator::NewAllocator(config, this, "vc_allocator",
			alloc_type, _vcs * _inputs, 1, _vcs * _outputs, 1);

	if (!_vc_allocator)
	{
		cout << "ERROR: Unknown vc_allocator type " << alloc_type << endl;
		exit(-1);
	}

	config.GetStr("sw_allocator", alloc_type);
	_sw_allocator = Allocator::NewAllocator(config, this, "sw_allocator",
			alloc_type, _inputs * _input_speedup, _input_speedup, _outputs
					* _output_speedup, _output_speedup);

	if (!_sw_allocator)
	{
		cout << "ERROR: Unknown sw_allocator type " << alloc_type << endl;
		exit(-1);
	}

	_sw_rr_offset = new int[_inputs * _input_speedup];
	for (int i = 0; i < _inputs * _input_speedup; ++i)
	{
		_sw_rr_offset[i] = 0;
	}

	// Alloc pipelines (to simulate processing/transmission delays)

	_crossbar_pipe = new PipelineFIFO<Flit> (this, "crossbar_pipeline",
			_outputs * _output_speedup, _st_prepare_delay + _st_final_delay);

	_credit_pipe = new PipelineFIFO<Credit> (this, "credit_pipeline", _inputs,
			_credit_delay);

	// Input and output queues

	_input_buffer = new queue<Flit *> [_inputs];
	_output_buffer = new queue<Flit *> [_outputs];

	_in_cred_buffer = new queue<Credit *> [_inputs];
	_out_cred_buffer = new queue<Credit *> [_outputs];

	// Switch configuration (when held for multiple cycles)

	_hold_switch_for_packet = config.GetInt("hold_switch_for_packet");
	_switch_hold_in = new int[_inputs * _input_speedup];
	_switch_hold_out = new int[_outputs * _output_speedup];
	_switch_hold_vc = new int[_inputs * _input_speedup];

	for (int i = 0; i < _inputs * _input_speedup; ++i)
	{
		_switch_hold_in[i] = -1;
		_switch_hold_vc[i] = -1;
	}

	for (int i = 0; i < _outputs * _output_speedup; ++i)
	{
		_switch_hold_out[i] = -1;
	}
}
Example #4
0
ChaosRouter::ChaosRouter( const Configuration& config,
                          Module *parent, const string & name, int id,
                          int inputs, int outputs )
    : Router( config,
              parent, name,
              id,
              inputs, outputs )
{
    int i;

    if ( inputs != outputs ) {
        Error( "Chaos router must have equal number of input and output ports" );
    }

    _buffer_size      = config.GetInt( "const_flits_per_packet" );
    _multi_queue_size = config.GetInt( "multi_queue_size" );

    _cur_channel = 0;
    _read_stall  = 0;

    // Routing

    _rf = GetRoutingFunction( config );

    _input_route = new OutputSet * [_inputs];
    _mq_route    = new OutputSet * [_multi_queue_size];

    for ( i = 0; i < _inputs; ++i ) {
        _input_route[i] = new OutputSet( _outputs );
    }

    for ( i = 0; i < _multi_queue_size; ++i ) {
        _mq_route[i] = new OutputSet( _outputs );
    }

    // Alloc pipelines (to simulate processing/transmission delays)

    _crossbar_pipe =
        new PipelineFIFO<Flit>( this, "crossbar_pipeline", _outputs,
                                _st_prepare_delay + _st_final_delay );

    // Input and output queues

    _input_frame  = new queue<Flit *> [_inputs];
    _output_frame = new queue<Flit *> [_outputs];
    _multi_queue  = new queue<Flit *> [_multi_queue_size];

    _credit_queue  = new queue<Credit *> [_inputs];

    _input_state        = new eQState [_inputs];
    _input_output_match = new int [_inputs];
    _input_mq_match     = new int [_inputs];

    _output_matched     = new bool [_outputs];
    _next_queue_cnt     = new int [_outputs];

    for ( i = 0; i < _inputs; ++i ) {
        _input_state[i]        = empty;
        _input_output_match[i] = -1;
        _input_mq_match[i]     = -1;
    }

    for ( i = 0; i < _outputs; ++i ) {
        _output_matched[i] = false;
        _next_queue_cnt[i] = 0;
    }

    _multi_match = new int  [_multi_queue_size];
    _mq_age      = new int  [_multi_queue_size];
    _mq_matched  = new bool [_multi_queue_size];
    _multi_state = new eQState [_multi_queue_size];

    for ( i = 0; i < _multi_queue_size; ++i ) {
        _multi_state[i] = empty;
        _multi_match[i] = -1;
        _mq_matched[i] = false;
    }
}