diff options
| author | Dongdong Li <[email protected]> | 2013-11-22 11:32:14 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:50:59 -0700 |
| commit | bdc0e550448f04c7c8f030b7421209bae37e651d (patch) | |
| tree | d59135ebbc05d7ddcd77c3b647e647e159073359 /src/intersim2/.svn/pristine/1f | |
| parent | 3f74773ce1ffe8ed5044a103d84459b56d4e9c20 (diff) | |
Add .svn file so other people can keep update with changes from Stanford
Code Review: Issue 103001
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 17411]
Diffstat (limited to 'src/intersim2/.svn/pristine/1f')
| -rw-r--r-- | src/intersim2/.svn/pristine/1f/1f35cbdd9ebe1ee0a41e949e03d51d268ac55bad.svn-base | 97 | ||||
| -rw-r--r-- | src/intersim2/.svn/pristine/1f/1f6b483285599def0e7fea5379c0af7a176d2736.svn-base | 223 |
2 files changed, 320 insertions, 0 deletions
diff --git a/src/intersim2/.svn/pristine/1f/1f35cbdd9ebe1ee0a41e949e03d51d268ac55bad.svn-base b/src/intersim2/.svn/pristine/1f/1f35cbdd9ebe1ee0a41e949e03d51d268ac55bad.svn-base new file mode 100644 index 0000000..9ac579a --- /dev/null +++ b/src/intersim2/.svn/pristine/1f/1f35cbdd9ebe1ee0a41e949e03d51d268ac55bad.svn-base @@ -0,0 +1,97 @@ +// $Id$ + +/* + Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _PIPEFIFO_HPP_ +#define _PIPEFIFO_HPP_ + +#include <vector> + +#include "module.hpp" + +template<class T> class PipelineFIFO : public Module { + int _lanes; + int _depth; + + int _pipe_len; + int _pipe_ptr; + + vector<vector<T*> > _data; + +public: + PipelineFIFO( Module *parent, const string& name, int lanes, int depth ); + ~PipelineFIFO( ); + + void Write( T* val, int lane = 0 ); + void WriteAll( T* val ); + + T* Read( int lane = 0 ); + + void Advance( ); +}; + +template<class T> PipelineFIFO<T>::PipelineFIFO( Module *parent, + const string& name, + int lanes, int depth ) : + Module( parent, name ), + _lanes( lanes ), _depth( depth ) +{ + _pipe_len = depth + 1; + _pipe_ptr = 0; + + _data.resize(_lanes); + for ( int l = 0; l < _lanes; ++l ) { + _data[l].resize(_pipe_len, 0); + } +} + +template<class T> PipelineFIFO<T>::~PipelineFIFO( ) +{ +} + +template<class T> void PipelineFIFO<T>::Write( T* val, int lane ) +{ + _data[lane][_pipe_ptr] = val; +} + +template<class T> void PipelineFIFO<T>::WriteAll( T* val ) +{ + for ( int l = 0; l < _lanes; ++l ) { + _data[l][_pipe_ptr] = val; + } +} + +template<class T> T* PipelineFIFO<T>::Read( int lane ) +{ + return _data[lane][_pipe_ptr]; +} + +template<class T> void PipelineFIFO<T>::Advance( ) +{ + _pipe_ptr = ( _pipe_ptr + 1 ) % _pipe_len; +} + +#endif diff --git a/src/intersim2/.svn/pristine/1f/1f6b483285599def0e7fea5379c0af7a176d2736.svn-base b/src/intersim2/.svn/pristine/1f/1f6b483285599def0e7fea5379c0af7a176d2736.svn-base new file mode 100644 index 0000000..baded43 --- /dev/null +++ b/src/intersim2/.svn/pristine/1f/1f6b483285599def0e7fea5379c0af7a176d2736.svn-base @@ -0,0 +1,223 @@ +// $Id$ + +/* + Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/*vc.cpp + * + *this class describes a virtual channel in a router + *it includes buffers and virtual channel state and controls + * + *This class calls the routing functions + */ + +#include <limits> +#include <sstream> + +#include "globals.hpp" +#include "booksim.hpp" +#include "vc.hpp" + +const char * const VC::VCSTATE[] = {"idle", + "routing", + "vc_alloc", + "active"}; + +VC::VC( const Configuration& config, int outputs, + Module *parent, const string& name ) + : Module( parent, name ), + _state(idle), _out_port(-1), _out_vc(-1), _pri(0), _watched(false), + _expected_pid(-1), _last_id(-1), _last_pid(-1) +{ + _lookahead_routing = !config.GetInt("routing_delay"); + _route_set = _lookahead_routing ? NULL : new OutputSet( ); + + string priority = config.GetStr( "priority" ); + if ( priority == "local_age" ) { + _pri_type = local_age_based; + } else if ( priority == "queue_length" ) { + _pri_type = queue_length_based; + } else if ( priority == "hop_count" ) { + _pri_type = hop_count_based; + } else if ( priority == "none" ) { + _pri_type = none; + } else { + _pri_type = other; + } + + _priority_donation = config.GetInt("vc_priority_donation"); +} + +VC::~VC() +{ + if(!_lookahead_routing) { + delete _route_set; + } +} + +void VC::AddFlit( Flit *f ) +{ + assert(f); + + if(_expected_pid >= 0) { + if(f->pid != _expected_pid) { + ostringstream err; + err << "Received flit " << f->id << " with unexpected packet ID: " << f->pid + << " (expected: " << _expected_pid << ")"; + Error(err.str()); + } else if(f->tail) { + _expected_pid = -1; + } + } else if(!f->tail) { + _expected_pid = f->pid; + } + + // update flit priority before adding to VC buffer + if(_pri_type == local_age_based) { + f->pri = numeric_limits<int>::max() - GetSimTime(); + assert(f->pri >= 0); + } else if(_pri_type == hop_count_based) { + f->pri = f->hops; + assert(f->pri >= 0); + } + + _buffer.push_back(f); + UpdatePriority(); +} + +Flit *VC::RemoveFlit( ) +{ + Flit *f = NULL; + if ( !_buffer.empty( ) ) { + f = _buffer.front( ); + _buffer.pop_front( ); + _last_id = f->id; + _last_pid = f->pid; + UpdatePriority(); + } else { + Error("Trying to remove flit from empty buffer."); + } + return f; +} + + + +void VC::SetState( eVCState s ) +{ + Flit * f = FrontFlit(); + + if(f && f->watch) + *gWatchOut << GetSimTime() << " | " << FullName() << " | " + << "Changing state from " << VC::VCSTATE[_state] + << " to " << VC::VCSTATE[s] << "." << endl; + + _state = s; +} + +const OutputSet *VC::GetRouteSet( ) const +{ + return _route_set; +} + +void VC::SetRouteSet( OutputSet * output_set ) +{ + _route_set = output_set; + _out_port = -1; + _out_vc = -1; +} + +void VC::SetOutput( int port, int vc ) +{ + _out_port = port; + _out_vc = vc; +} + +void VC::UpdatePriority() +{ + if(_buffer.empty()) return; + if(_pri_type == queue_length_based) { + _pri = _buffer.size(); + } else if(_pri_type != none) { + Flit * f = _buffer.front(); + if((_pri_type != local_age_based) && _priority_donation) { + Flit * df = f; + for(size_t i = 1; i < _buffer.size(); ++i) { + Flit * bf = _buffer[i]; + if(bf->pri > df->pri) df = bf; + } + if((df != f) && (df->watch || f->watch)) { + *gWatchOut << GetSimTime() << " | " << FullName() << " | " + << "Flit " << df->id + << " donates priority to flit " << f->id + << "." << endl; + } + f = df; + } + if(f->watch) + *gWatchOut << GetSimTime() << " | " << FullName() << " | " + << "Flit " << f->id + << " sets priority to " << f->pri + << "." << endl; + _pri = f->pri; + } +} + + +void VC::Route( tRoutingFunction rf, const Router* router, const Flit* f, int in_channel ) +{ + rf( router, f, in_channel, _route_set, false ); + _out_port = -1; + _out_vc = -1; +} + +// ==== Debug functions ==== + +void VC::SetWatch( bool watch ) +{ + _watched = watch; +} + +bool VC::IsWatched( ) const +{ + return _watched; +} + +void VC::Display( ostream & os ) const +{ + if ( _state != VC::idle ) { + os << FullName() << ": " + << " state: " << VCSTATE[_state]; + if(_state == VC::active) { + os << " out_port: " << _out_port + << " out_vc: " << _out_vc; + } + os << " fill: " << _buffer.size(); + if(!_buffer.empty()) { + os << " front: " << _buffer.front()->id; + } + os << " pri: " << _pri; + os << endl; + } +} |
