int main( int argc, char **argv ) { BookSimConfig config; if ( !ParseArgs( &config, argc, argv ) ) { cerr << "Usage: " << argv[0] << " configfile... [param=value...]" << endl; return 0; } /*initialize routing, traffic, injection functions */ InitializeRoutingMap( config ); gPrintActivity = (config.GetInt("print_activity") > 0); gTrace = (config.GetInt("viewer_trace") > 0); string watch_out_file = config.GetStr( "watch_out" ); if(watch_out_file == "") { gWatchOut = NULL; } else if(watch_out_file == "-") { gWatchOut = &cout; } else { gWatchOut = new ofstream(watch_out_file.c_str()); } /*configure and run the simulator */ bool result = Simulate( config ); return result ? -1 : 0; }
bool Simulate( BookSimConfig const & config ) { vector<Network *> net; int subnets = config.GetInt("subnets"); /*To include a new network, must register the network here *add an else if statement with the name of the network */ net.resize(subnets); for (int i = 0; i < subnets; ++i) { ostringstream name; name << "network_" << i; net[i] = Network::New( config, name.str() ); } /*tcc and characterize are legacy *not sure how to use them */ assert(trafficManager == NULL); trafficManager = TrafficManager::New( config, net ) ; /*Start the simulation run */ double total_time; /* Amount of time we've run */ struct timeval start_time, end_time; /* Time before/after user code */ total_time = 0.0; gettimeofday(&start_time, NULL); bool result = trafficManager->Run() ; gettimeofday(&end_time, NULL); total_time = ((double)(end_time.tv_sec) + (double)(end_time.tv_usec)/1000000.0) - ((double)(start_time.tv_sec) + (double)(start_time.tv_usec)/1000000.0); cout<<"Total run time "<<total_time<<endl; for (int i=0; i<subnets; ++i) { ///Power analysis if(config.GetInt("sim_power") > 0){ Power_Module pnet(net[i], config); pnet.run(); } delete net[i]; } delete trafficManager; trafficManager = NULL; return result; }
int fixed_latency(int input, int output) { int latency; if (perfect_icnt) { latency = 1; } else { int dim = icnt_config.GetInt( "k" ); int xhops = abs ( input%dim - output%dim); int yhops = abs ( input/dim - output/dim); latency = ( (xhops+yhops)*fixed_lat_icnt ); } return latency; }
int main( int argc, char **argv ) { BookSimConfig config; if ( !ParseArgs( &config, argc, argv ) ) { cout << "Usage: " << argv[0] << " configfile" << endl; return 0; } /*print the configuration file at the begining of the reprot */ ifstream in(argv[1]); char c; cout << "BEGIN Configuration File" << endl; cout << "Name: " << argv[1] << endl; while (!in.eof()) { in.get(c); cout << c ; } cout << "END Configuration File" << endl; _threads = config.GetInt("threads"); /*initialize routing, traffic, injection functions */ InitializeRoutingMap( ); InitializeTrafficMap( ); InitializeInjectionMap( ); _print_activity = (config.GetInt("print_activity")==1); _trace = (config.GetInt("viewer trace")==1); _use_read_write = (config.GetInt("use_read_write")==1); config.GetStr( "watch_file", watch_file ); _use_noc_latency = (config.GetInt("use_noc_latency")==1); /*configure and run the simulator */ bool result; // for(int i = 0; i<2; i++){ result = AllocatorSim( config ); //} return result ? -1 : 0; }
void interconnect_stats() { if (!fixed_lat_icnt) { for (unsigned i=0; i<net_c;i++) { cout <<"Traffic "<<i<< " Stat" << endl; traffic[i]->ShowStats(); if (icnt_config.GetInt("enable_link_stats")) { cout << "%=================================" << endl; cout <<"Traffic "<<i<< "Link utilizations:" << endl; traffic[i]->_net->Display(); } } } else { //show max queue sizes cout<<"Max Fixed Latency ICNT queue size for"<<endl; for (unsigned i=0;i<(_n_mem + _n_shader);i++) { cout<<" node[" << i <<"] is "<<max_fixedlat_buf_size[i]; } cout<<endl; } }
void init_interconnect (char* config_file, unsigned int n_shader, unsigned int n_mem ) { _n_shader = n_shader; _n_mem = n_mem; if (! config_file ) { cout << "Interconnect Requires a configfile" << endl; exit (-1); } icnt_config.Parse( config_file ); net_c = icnt_config.GetInt( "network_count" ); if (net_c==2) { doub_net = true; } else if (net_c<1 || net_c>2) { cout <<net_c<<" Network_count less than 1 or more than 2 not supported."<<endl; abort(); } g_num_vcs = icnt_config.GetInt( "num_vcs" ); InitializeRoutingMap( ); InitializeTrafficMap( ); InitializeInjectionMap( ); RandomSeed( icnt_config.GetInt("seed") ); Network_gpgpu **net; traffic = new TrafficManager *[net_c]; net = new Network_gpgpu *[net_c]; for (unsigned i=0;i<net_c;i++) { string topo; icnt_config.GetStr( "topology", topo ); if ( topo == "torus" ) { net[i] = new KNCube( icnt_config, true ); } else if ( topo =="mesh" ) { net[i] = new KNCube( icnt_config, false ); } else if ( topo == "fly" ) { net[i] = new KNFly( icnt_config ); } else if ( topo == "single" ) { net[i] = new SingleNet( icnt_config ); } else { cerr << "Unknown topology " << topo << endl; exit(-1); } if ( icnt_config.GetInt( "link_failures" ) ) { net[i]->InsertRandomFaults( icnt_config ); } traffic[i] = new TrafficManager ( icnt_config, net[i], i/*id*/ ); } fixed_lat_icnt = icnt_config.GetInt( "fixed_lat_per_hop" ); if (icnt_config.GetInt( "perfect_icnt" )) { perfect_icnt = true; fixed_lat_icnt = 1; } _flit_size = icnt_config.GetInt( "flit_size" ); if (icnt_config.GetInt("ejection_buf_size")) { ejection_buffer_capacity = icnt_config.GetInt( "ejection_buf_size" ) ; } else { ejection_buffer_capacity = icnt_config.GetInt( "vc_buf_size" ); } boundary_buf_capacity = icnt_config.GetInt( "boundary_buf_size" ) ; if (icnt_config.GetInt("input_buf_size")) { input_buffer_capacity = icnt_config.GetInt("input_buf_size"); } else { input_buffer_capacity = 9; } create_buf(traffic[0]->_dests,input_buffer_capacity,icnt_config.GetInt( "num_vcs" )); MATLAB_OUTPUT = icnt_config.GetInt("MATLAB_OUTPUT"); DISPLAY_LAT_DIST = icnt_config.GetInt("DISPLAY_LAT_DIST"); DISPLAY_HOP_DIST = icnt_config.GetInt("DISPLAY_HOP_DIST"); DISPLAY_PAIR_LATENCY = icnt_config.GetInt("DISPLAY_PAIR_LATENCY"); create_node_map(n_shader,n_mem,traffic[0]->_dests, icnt_config.GetInt("use_map")); for (unsigned i=0;i<net_c;i++) { traffic[i]->_FirstStep(); } }