Beispiel #1
0
void KNCube::_BuildNet( const Configuration &config )
{
   int left_node;
   int right_node;

   int right_input;
   int left_input;

   int right_output;
   int left_output;

   ostringstream router_name;

   for ( int node = 0; node < _size; ++node ) {

      router_name << "router";

      for ( int dim_offset = _size / _k; dim_offset >= 1; dim_offset /= _k ) {
         router_name << "_" << ( node / dim_offset ) % _k;
      }

      _routers[node] = Router_gpgpu::NewRouter( config, this, router_name.str( ), 
                                          node, 2*_n + 1, 2*_n + 1 );

      router_name.seekp( 0, ios::beg );

      for ( int dim = 0; dim < _n; ++dim ) {

         left_node  = _LeftNode( node, dim );
         right_node = _RightNode( node, dim );

         //
         // Current (N)ode
         // (L)eft node
         // (R)ight node
         //
         //   L--->N<---R
         //   L<---N--->R
         //

         right_input = _LeftChannel( right_node, dim );
         left_input  = _RightChannel( left_node, dim );

         _routers[node]->AddInputChannel( &_chan[right_input], &_chan_cred[right_input] );
         _routers[node]->AddInputChannel( &_chan[left_input], &_chan_cred[left_input] );

         right_output = _RightChannel( node, dim );
         left_output  = _LeftChannel( node, dim );

         _routers[node]->AddOutputChannel( &_chan[right_output], &_chan_cred[right_output] );
         _routers[node]->AddOutputChannel( &_chan[left_output], &_chan_cred[left_output] );
      }

      _routers[node]->AddInputChannel( &_inject[node], &_inject_cred[node] );
      _routers[node]->AddOutputChannel( &_eject[node], &_eject_cred[node] );
   }
}
Beispiel #2
0
void KNCube::_BuildNet( const Configuration &config )
{
  int left_node;
  int right_node;

  int right_input;
  int left_input;

  int right_output;
  int left_output;

  ostringstream router_name;

  //latency type, noc or conventional network
  bool use_noc_latency;
  use_noc_latency = (config.GetInt("use_noc_latency")==1);
  
  for ( int node = 0; node < _size; ++node ) {

    router_name << "router";
    
    for ( int dim_offset = _size / _k; dim_offset >= 1; dim_offset /= _k ) {
      router_name << "_" << ( node / dim_offset ) % _k;
    }

    _routers[node] = Router::NewRouter( config, this, router_name.str( ), 
					node, 2*_n + 1, 2*_n + 1 );
    _timed_modules.push_back(_routers[node]);

    router_name.str("");

    for ( int dim = 0; dim < _n; ++dim ) {

      //find the neighbor 
      left_node  = _LeftNode( node, dim );
      right_node = _RightNode( node, dim );

      //
      // Current (N)ode
      // (L)eft node
      // (R)ight node
      //
      //   L--->N<---R
      //   L<---N--->R
      //

      // torus channel is longer due to wrap around
      int latency = _mesh ? 1 : 2 ;

      //get the input channel number
      right_input = _LeftChannel( right_node, dim );
      left_input  = _RightChannel( left_node, dim );

      //add the input channel
      _routers[node]->AddInputChannel( _chan[right_input], _chan_cred[right_input] );
      _routers[node]->AddInputChannel( _chan[left_input], _chan_cred[left_input] );

      //set input channel latency
      if(use_noc_latency){
	_chan[right_input]->SetLatency( latency );
	_chan[left_input]->SetLatency( latency );
	_chan_cred[right_input]->SetLatency( latency );
	_chan_cred[left_input]->SetLatency( latency );
      } else {
	_chan[left_input]->SetLatency( 1 );
	_chan_cred[right_input]->SetLatency( 1 );
	_chan_cred[left_input]->SetLatency( 1);
	_chan[right_input]->SetLatency( 1 );
      }
      //get the output channel number
      right_output = _RightChannel( node, dim );
      left_output  = _LeftChannel( node, dim );
      
      //add the output channel
      _routers[node]->AddOutputChannel( _chan[right_output], _chan_cred[right_output] );
      _routers[node]->AddOutputChannel( _chan[left_output], _chan_cred[left_output] );

      //set output channel latency
      if(use_noc_latency){
	_chan[right_output]->SetLatency( latency );
	_chan[left_output]->SetLatency( latency );
	_chan_cred[right_output]->SetLatency( latency );
	_chan_cred[left_output]->SetLatency( latency );
      } else {
	_chan[right_output]->SetLatency(1);
	_chan[left_output]->SetLatency(1 );
	_chan_cred[right_output]->SetLatency(1 );
	_chan_cred[left_output]->SetLatency( 1);

      }
    }
    //injection and ejection channel, always 1 latency
    _routers[node]->AddInputChannel( _inject[node], _inject_cred[node] );
    _routers[node]->AddOutputChannel( _eject[node], _eject_cred[node] );
    _inject[node]->SetLatency( 1 );
    _eject[node]->SetLatency( 1 );
  }
}
Beispiel #3
0
/*legacy, not sure how this fits into the own scheme of things*/
void KNCube::InsertRandomFaults( const Configuration &config )
{
  int num_fails;
  unsigned long prev_seed;

  int node, chan;
  int i, j, t, n, c;
  bool *fail_nodes;
  bool available;

  bool edge;

  num_fails = config.GetInt( "link_failures" );
  
  if ( num_fails ) {
    prev_seed = RandomIntLong( );
    RandomSeed( config.GetInt( "fail_seed" ) );

    fail_nodes = new bool [_size];

    for ( i = 0; i < _size; ++i ) {
      node = i;

      // edge test
      edge = false;
      for ( n = 0; n < _n; ++n ) {
	if ( ( ( node % _k ) == 0 ) ||
	     ( ( node % _k ) == _k - 1 ) ) {
	  edge = true;
	}
	node /= _k;
      }

      if ( edge ) {
	fail_nodes[i] = true;
      } else {
	fail_nodes[i] = false;
      }
    }

    for ( i = 0; i < num_fails; ++i ) {
      j = RandomInt( _size - 1 );
      available = false;

      for ( t = 0; ( t < _size ) && (!available); ++t ) {
	node = ( j + t ) % _size;
       
	if ( !fail_nodes[node] ) {
	  // check neighbors
	  c = RandomInt( 2*_n - 1 );

	  for ( n = 0; ( n < 2*_n ) && (!available); ++n ) {
	    chan = ( n + c ) % 2*_n;

	    if ( chan % 1 ) {
	      available = fail_nodes[_LeftNode( node, chan/2 )];
	    } else {
	      available = fail_nodes[_RightNode( node, chan/2 )];
	    }
	  }
	}
	
	if ( !available ) {
	  cout << "skipping " << node << endl;
	}
      }

      if ( t == _size ) {
	Error( "Could not find another possible fault channel" );
      }

      
      OutChannelFault( node, chan );
      fail_nodes[node] = true;

      for ( n = 0; ( n < _n ) && available ; ++n ) {
	fail_nodes[_LeftNode( node, n )]  = true;
	fail_nodes[_RightNode( node, n )] = true;
      }

      cout << "failure at node " << node << ", channel " 
	   << chan << endl;
    }

    delete [] fail_nodes;

    RandomSeed( prev_seed );
  }
}
Beispiel #4
0
/*legacy, not sure how this fits into the own scheme of things*/
void KNCube::InsertRandomFaults( const Configuration &config )
{
  int num_fails = config.GetInt( "link_failures" );
  
  if ( _size && num_fails ) {
    vector<long> save_x;
    vector<double> save_u;
    SaveRandomState( save_x, save_u );
    int fail_seed;
    if ( config.GetStr( "fail_seed" ) == "time" ) {
      fail_seed = int( time( NULL ) );
      cout << "SEED: fail_seed=" << fail_seed << endl;
    } else {
      fail_seed = config.GetInt( "fail_seed" );
    }
    RandomSeed( fail_seed );

    vector<bool> fail_nodes(_size);

    for ( int i = 0; i < _size; ++i ) {
      int node = i;

      // edge test
      bool edge = false;
      for ( int n = 0; n < _n; ++n ) {
	if ( ( ( node % _k ) == 0 ) ||
	     ( ( node % _k ) == _k - 1 ) ) {
	  edge = true;
	}
	node /= _k;
      }

      if ( edge ) {
	fail_nodes[i] = true;
      } else {
	fail_nodes[i] = false;
      }
    }

    for ( int i = 0; i < num_fails; ++i ) {
      int j = RandomInt( _size - 1 );
      bool available = false;
      int node, chan;
      int t;

      for ( t = 0; ( t < _size ) && (!available); ++t ) {
		node = ( j + t ) % _size;
	       
		if ( !fail_nodes[node] ) {
		  // check neighbors
		  int c = RandomInt( 2*_n - 1 );

		  for ( int n = 0; ( n < 2*_n ) && (!available); ++n ) {
		    chan = ( n + c ) % 2*_n;

		    if ( chan % 1 ) {
		      available = fail_nodes[_LeftNode( node, chan/2 )];
		    } else {
		      available = fail_nodes[_RightNode( node, chan/2 )];
		    }
		  }
		}
		
		if ( !available ) {
		  cout << "skipping " << node << endl;
		}
      }

      if ( t == _size ) {
		Error( "Could not find another possible fault channel" );
      }

      
      OutChannelFault( node, chan );
      fail_nodes[node] = true;

      for ( int n = 0; ( n < _n ) && available ; ++n ) {
		fail_nodes[_LeftNode( node, n )]  = true;
		fail_nodes[_RightNode( node, n )] = true;
      }

      cout << "failure at node " << node << ", channel " 
	   << chan << endl;
    }

    RestoreRandomState( save_x, save_u );
  }
}