void torus_mapping(void) { tw_lpid kpid; tw_pe * pe; int nkp_per_pe=16; for(kpid = 0; kpid < nkp_per_pe; kpid++) tw_kp_onpe(kpid, g_tw_pe[0]); int i; for(i = 0; i < nlp_nodes_per_pe; i++) { kpid = i % g_tw_nkp; pe = tw_getpe(kpid % g_tw_npe); tw_lp_onpe(i, pe, g_tw_mynode * nlp_nodes_per_pe + i + getRem() ); tw_lp_onkp(g_tw_lp[i], g_tw_kp[kpid]); tw_lp_settype(i, &nodes_lps[0]); } for(i = 0; i < nlp_mpi_procs_per_pe; i++) { kpid = i % g_tw_nkp; pe = tw_getpe(kpid % g_tw_npe); tw_lp_onpe(nlp_nodes_per_pe+i, pe, N_nodes + g_tw_mynode * nlp_mpi_procs_per_pe + i + getRem() ); tw_lp_onkp(g_tw_lp[nlp_nodes_per_pe + i], g_tw_kp[kpid]); tw_lp_settype(nlp_nodes_per_pe + i, &nodes_lps[1]); } }
int main(int argc, char **argv, char **env) { int i; lookahead = 1.0; tw_opt_add(app_opt); tw_init(&argc, &argv); g_tw_memory_nqueues = 16; offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_events_per_pe = (mult * nlp_per_pe * g_wifi_start_events)+ optimistic_memory; g_tw_lookahead = lookahead; tw_define_lps(nlp_per_pe, sizeof(wifi_message)); tw_lp_settype(0, &mylps[0]); for(i = 1; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); tw_run(); tw_end(); return 0; }
int main( int argc, char** argv ) { int i; tw_opt_add(app_opt); tw_init(&argc, &argv); printf("First version BGP model! \n"); //////////// N_controller_per_DDN = NumControllerPerDDN; N_FS_per_DDN = N_controller_per_DDN * NumFSPerController; N_ION_per_DDN = N_FS_per_DDN * N_ION_per_FS; N_CN_per_DDN = N_ION_per_DDN * N_CN_per_ION; int N_lp_per_DDN = N_controller_per_DDN + N_FS_per_DDN + N_ION_per_DDN + N_CN_per_DDN + 1; int N_lp_t = N_lp_per_DDN * NumDDN; nlp_per_pe = N_lp_t/tw_nnodes()/g_tw_npe; N_DDN_per_PE = NumDDN/tw_nnodes()/g_tw_npe; g_tw_events_per_pe = nlp_per_pe * 32 + opt_mem; tw_define_lps(nlp_per_pe, sizeof(MsgData), 0); // mapping initialization int LPaccumulate = 0; for( i=0; i<N_CN_per_DDN*N_DDN_per_PE; i++ ) tw_lp_settype(i, &mylps[0]); LPaccumulate += N_CN_per_DDN*N_DDN_per_PE; for( i=0; i<N_ION_per_DDN*N_DDN_per_PE; i++ ) tw_lp_settype(i + LPaccumulate, &mylps[1]); LPaccumulate += N_ION_per_DDN*N_DDN_per_PE; for( i=0; i<N_FS_per_DDN*N_DDN_per_PE; i++ ) tw_lp_settype(i + LPaccumulate, &mylps[2]); LPaccumulate += N_FS_per_DDN*N_DDN_per_PE; for( i=0; i<N_controller_per_DDN*N_DDN_per_PE; i++ ) tw_lp_settype(i + LPaccumulate, &mylps[3]); LPaccumulate += N_controller_per_DDN*N_DDN_per_PE; for( i=0; i<N_DDN_per_PE; i++ ) tw_lp_settype(i + LPaccumulate, &mylps[4]); tw_run(); tw_end(); return 0; }
int main(int argc, char **argv, char **env) { int i; tw_opt_add(app_opt); tw_init(&argc, &argv); offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_memory_nqueues = 1; g_tw_events_per_pe = (mult * nlp_per_pe * g_mem_start_events) + optimistic_memory; tw_define_lps(nlp_per_pe, sizeof(mem_message)); for(i = 0; i < nlp_per_pe; i++) tw_lp_settype(i, &mylps[0]); //((g_tw_nlp/g_tw_nkp) * g_mem_start_events), // init the memory interface my_fd = tw_memory_init(g_tw_events_per_pe * nbufs, sizeof(mem_packet), 0.5); tw_run(); mem_stats_print(); tw_end(); return 0; }
int main(int argc, char **argv, char **env) { int i; lookahead = 1.0; tw_opt_add(app_opt); tw_init(&argc, &argv); if( lookahead > 1.0 ) tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n"); g_tw_events_per_pe = (nlp_per_pe * g_start_events) + optimistic_memory; g_tw_lookahead = lookahead; tw_define_lps(nlp_per_pe, sizeof(ping_pong_message), 0); for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); if( g_tw_mynode == 0 ) { printf("=============================================\n"); printf("Ping Pong Configuration..............\n"); printf(" Lookahead..............%lf\n", lookahead); printf(" Start-events...........%u\n", g_start_events); printf(" Memory.................%u\n", optimistic_memory); printf("========================================\n\n"); } tw_run(); tw_end(); return 0; }
int main(int argc, char *argv[]) { int i; g_tw_events_per_pe = nlp_per_pe * nlp_per_pe * 1; tw_opt_add(olsr_opts); tw_init(&argc, &argv); tw_define_lps(nlp_per_pe, sizeof(olsr_msg_data), 0); for (i = 0; i < g_tw_nlp; i++) { tw_lp_settype(i, &olsr_lps[0]); } tw_run(); if (tw_ismaster()) { printf("Complete.\n"); } tw_end(); return 0; }
void tcp_init(tcp_state * state, FILE * f, tw_lp * lp) { #if 0 for (layer = node; layer != NULL; layer = layer->next) { if (0 != strcmp((char *)layer->name, "layer")) continue; if (strcmp(xml_getprop(layer, "name"), "tcp") == 0) { tw_lp_settype(lp, TCP_LP_TYPE); break; } } for(e = node->children; e; e = e->next) { if(0 == strcmp((char *) e->name, "mss")) state->mss = atoi((char *)e->children->content); if(0 == strcmp((char *) e->name, "recv_wnd")) state->recv_wnd = atoi((char *)e->children->content); } #endif }
int main(int argc, char **argv, char **env) { int i; tw_opt_add(app_opt); tw_init(&argc, &argv); offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_memory_nqueues = 1; g_tw_events_per_pe = (mult * nlp_per_pe * g_tmr_start_events) + optimistic_memory; tw_define_lps(nlp_per_pe, sizeof(tmr_message), 0); // use g_tw_nlp now for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); tw_kp_memory_init(g_tw_kp, 1000, 100, 1); if(verbose) f = stdout; else f = fopen("output", "w"); //f = fopen("/dev/null", "w"); tw_run(); tw_end(); return 0; }
int main(int argc, char **argv) { int i; tw_lp *lp; tw_kp *kp; tw_pe *pe; tw_opt_add(app_opt); tw_init(&argc, &argv); if( lookahead > 1.0 ) tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n"); //reset mean based on lookahead mean = mean - lookahead; g_tw_memory_nqueues = 16; // give at least 16 memory queue event offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_events_per_pe = (mult * nlp_per_pe * g_phold_start_events) + optimistic_memory; //g_tw_rng_default = TW_FALSE; g_tw_lookahead = lookahead; tw_define_lps(nlp_per_pe, sizeof(tcp_phold_message)); for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); if( g_tw_mynode == 0 ) { printf("Running simulation with following configuration: \n" ); printf(" Processors Used = %d\n", tw_nnodes()); printf(" KPs Used = %lu\n", g_tw_nkp); printf(" LPs Used = %u\n", nlp_per_model); printf(" End Time = %f \n", g_tw_ts_end); printf(" Buffers Allocated Per PE = %d\n", g_tw_events_per_pe); printf(" Gvt Interval = %d\n", g_tw_gvt_interval); printf(" Message Block Size (i.e., Batch) = %d\n", g_tw_mblock); printf("\n\n"); } TWAppStats.sent_packets = 0; TWAppStats.received_packets = 0; TWAppStats.dropped_packets = 0; TWAppStats.timedout_packets = 0; TWAppStats.throughput = 0; tw_run(); tw_end(); tcp_finalize( &TWAppStats ); return 0; }
int main( int argc, char **argv) { int nprocs; int rank; int lps_per_proc; int i; int ret; lp_io_handle handle; g_tw_ts_end = 60*60*24*365; tw_opt_add(app_opt); tw_init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); if((NUM_SERVERS) % nprocs) { fprintf(stderr, "Error: number of server LPs (%d total) is not evenly divisible by the number of MPI processes (%d)\n", NUM_SERVERS, nprocs); exit(-1); } lps_per_proc = (NUM_SERVERS) / nprocs; tw_define_lps(lps_per_proc, sizeof(struct svr_msg), 0); for(i=0; i<lps_per_proc; i++) { tw_lp_settype(i, &svr_lp); } g_tw_lookahead = 100; ret = lp_io_prepare("lp-io-test-results", LP_IO_UNIQ_SUFFIX, &handle, MPI_COMM_WORLD); if(ret < 0) { return(-1); } tw_run(); ret = lp_io_flush(handle, MPI_COMM_WORLD); assert(ret == 0); tw_end(); return 0; }
int main(int argc, char **argv, char **env) { int i; // get rid of error if compiled w/ MEMORY queues g_tw_memory_nqueues=1; // set a min lookahead of 1.0 lookahead = 1.0; tw_opt_add(app_opt); tw_init(&argc, &argv); if( lookahead > 1.0 ) tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n"); //reset mean based on lookahead mean = mean - lookahead; g_tw_memory_nqueues = 16; // give at least 16 memory queue event offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_events_per_pe = (mult * nlp_per_pe * g_phold_start_events) + optimistic_memory; //g_tw_rng_default = TW_FALSE; g_tw_lookahead = lookahead; tw_define_lps(nlp_per_pe, sizeof(phold_message)); for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); if( g_tw_mynode == 0 ) { printf("========================================\n"); printf("PHOLD Model Configuration..............\n"); printf(" Lookahead..............%lf\n", lookahead); printf(" Start-events...........%u\n", g_phold_start_events); printf(" stagger................%u\n", stagger); printf(" Mean...................%lf\n", mean); printf(" Mult...................%lf\n", mult); printf(" Memory.................%u\n", optimistic_memory); printf(" Remote.................%lf\n", percent_remote); printf("========================================\n\n"); } tw_run(); tw_end(); return 0; }
int main(int argc, char * argv[]) { int NumPE = 0; int i = 0; tw_lp *lp; tw_kp *kp; g_tw_ts_end = 300; g_tw_gvt_interval = 16; printf("Please enter the number of processors: "); scanf("%d",&NumPE); if(NumPE < 1 && NumPE > 4){ printf("Invalid number of processors %d\n", NumPE); exit(0); } /* tw_lptype NumPE NumKP NumLP Message_Size*/ tw_init(airport_lps, NumPE, 3, 3, sizeof(Msg_Data)); for(i = 0; i < 3; i++){ lp = tw_getlp(i); kp = tw_getkp(i); tw_lp_settype(lp, AIR_LP); tw_lp_onkp(lp, kp); if(i >= NumPE){ tw_lp_onpe(lp, tw_getpe(NumPE - 1)); tw_kp_onpe(kp, tw_getpe(NumPE - 1)); } else { tw_lp_onpe(lp, tw_getpe(i)); tw_kp_onpe(kp, tw_getpe(i)); } } tw_run(); printf("Number of Landings: %d\n", NumLanded); return 0; }
/* * main - start function for the model, setup global state space of model and * init and run the simulation executive. Also must map LPs to PEs */ int main(int argc, char **argv, char **env) { int i; tw_opt_add(app_opt); tw_init(&argc, &argv); g_tw_events_per_pe = (g_tw_nlp / g_tw_npe) * 4; g_tw_memory_nqueues = 2; tw_define_lps(g_tw_nlp, sizeof(epi_message), 0); epi_disease_init(); // create KP memory buffer queues for(i = 0; i < g_tw_nkp; i++) { g_epi_fd = tw_kp_memory_init(tw_getkp(i), //0, //g_epi_nagents / g_tw_nkp, g_epi_nagents / g_tw_nkp, sizeof(epi_agent), 1); g_epi_pathogen_fd = tw_kp_memory_init(tw_getkp(i), (g_epi_nagents / g_tw_nkp) * g_epi_ndiseases, sizeof(epi_pathogen), 1); } // Round-robin mapping of LPs to KPs and KPs to PEs for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); // read input files, create global data structures, etc epi_agent_init(); tw_run(); epi_model_final(); return 0; }
void traffic_grid_mapping() { tw_lpid x, y; tw_lpid lpid, kpid; tw_lpid num_cells_per_kp, vp_per_proc; tw_lpid local_lp_count; num_cells_per_kp = (NUM_CELLS_X * NUM_CELLS_Y) / (NUM_VP_X * NUM_VP_Y); vp_per_proc = (NUM_VP_X * NUM_VP_Y) / ((tw_nnodes() * g_tw_npe)) ; g_tw_nlp = nlp_per_pe; g_tw_nkp = vp_per_proc; local_lp_count=0; for (y = 0; y < NUM_CELLS_Y; y++) { for (x = 0; x < NUM_CELLS_X; x++) { lpid = (x + (y * NUM_CELLS_X)); if( g_tw_mynode == CellMapping_lp_to_pe(lpid) ) { kpid = local_lp_count/num_cells_per_kp; local_lp_count++; // MUST COME AFTER!! DO NOT PRE-INCREMENT ELSE KPID is WRONG!! if( kpid >= g_tw_nkp ) tw_error(TW_LOC, "Attempting to mapping a KPid (%llu) for Global LPid %llu that is beyond g_tw_nkp (%llu)\n", kpid, lpid, g_tw_nkp ); tw_lp_onpe(CellMapping_to_local_index(lpid), g_tw_pe[0], lpid); if( g_tw_kp[kpid] == NULL ) tw_kp_onpe(kpid, g_tw_pe[0]); tw_lp_onkp(g_tw_lp[CellMapping_to_local_index(lpid)], g_tw_kp[kpid]); tw_lp_settype( CellMapping_to_local_index(lpid), &mylps[0]); } } } }
int srw_main(int argc, char *argv[]) { int i; int num_lps_per_pe = 1; tw_opt_add(srw_opts); /* This configures g_tw_npe */ tw_init(&argc, &argv); /* Must call this to properly set g_tw_nlp */ tw_define_lps(num_lps_per_pe, sizeof(srw_msg_data), 0); #ifdef WITH_NETDMF /* IF we ARE using NETDMF... */ if (!strcmp("", netdmf_config)) { /* AND we DO NOT have a config file */ /* There is no NetDMF configuration file. Create a scenario with fake * data, i.e. no changes are required: fake data is created by default */ for (i = 0; i < g_tw_nlp; i++) { tw_lp_settype(i, &srw_lps[0]); } printf("No NetDMF configuration specified.\n"); } else { /* OR we DO have a config file */ /* Must repeatedly call this to copy the function pointers appropriately */ for (i = 0; i < g_tw_nlp; i++) { tw_lp_settype(i, &netdmf_srw_lps[0]); } /* Read in the netdmf_config file. This must be done after * we set up the LPs (via tw_lp_settype) so we have data * to configure. */ for (i = 0; i < g_tw_npe; i++) { tw_pe_settype(g_tw_pe[i], &srw_pes[0]); } } #else /* WITH_NETDMF */ /* WE are NOT using NETDMF */ /* Must repeatedly call this to copy the function pointers appropriately */ for (i = 0; i < g_tw_nlp; i++) { tw_lp_settype(i, &srw_lps[0]); } #endif /* WITH_NETDMF */ tw_run(); if (tw_ismaster()) { printf("Total radios in simulation: %d\n", total_radios); printf("Total movements: %d\n", total_movements); printf("Total communcation failures: %d\n", total_fail); printf("Total communcation attempts: %d\n", total_comm); printf("Total communication successes: %d\n", total_comm - total_fail); printf("Node %d moved the most: %d\n", top_node, top_move); } tw_end(); return 0; }
int main(int argc, char * argv[]) { g_tw_ts_end = 30; g_tw_gvt_interval = 16; int i; // get rid of error if compiled w/ MEMORY queues g_tw_memory_nqueues=1; // set a min lookahead of 1.0 lookahead = 1.0; //tw_opt_add(app_opt); tw_init(&argc, &argv); if( lookahead > 1.0 ) tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n"); //reset mean based on lookahead mean = mean - lookahead; g_tw_memory_nqueues = 16; // give at least 16 memory queue event offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; //g_tw_rng_default = TW_FALSE; g_tw_lookahead = lookahead; nlp_per_pe = (NUM_CELLS_X * NUM_CELLS_Y) / (tw_nnodes() * g_tw_npe); g_tw_events_per_pe = (mult * nlp_per_pe * g_traffic_start_events) + optimistic_memory; num_cells_per_kp = (NUM_CELLS_X * NUM_CELLS_Y) / (NUM_VP_X * NUM_VP_Y); vp_per_proc = (NUM_VP_X * NUM_VP_Y) / ((tw_nnodes() * g_tw_npe)) ; g_vp_per_proc = vp_per_proc; g_tw_nlp = nlp_per_pe; g_tw_nkp = vp_per_proc; g_tw_mapping = CUSTOM; g_tw_custom_initial_mapping = &traffic_grid_mapping; g_tw_custom_lp_global_to_local_map = &CellMapping_to_lp; tw_define_lps(nlp_per_pe, sizeof(Msg_Data)); for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &mylps[0]); if( g_tw_mynode == 0 ) { printf("========================================\n"); printf("Traffice Model Configuration..............\n"); printf(" Lookahead..............%lf\n", lookahead); printf(" Start-events...........%u\n", g_traffic_start_events); printf(" stagger................%u\n", stagger); printf(" Mean...................%lf\n", mean); printf(" Mult...................%lf\n", mult); printf(" Memory.................%u\n", optimistic_memory); printf(" Remote.................%lf\n", percent_remote); printf("========================================\n\n"); } tw_run(); tw_end(); printf("Number of Arivals: %lld\n", totalCars); printf("Number of Cars reached their dest: %lld\n", carsFinished); return 0; }
int main(int argc, char **argv, char **env) { #ifdef TEST_COMM_ROSS // Init outside of ROSS MPI_Init(&argc, &argv); // Split COMM_WORLD in half even/odd int mpi_rank; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm split_comm; MPI_Comm_split(MPI_COMM_WORLD, mpi_rank%2, mpi_rank, &split_comm); if(mpi_rank%2 == 1){ // tests should catch any MPI_COMM_WORLD collectives MPI_Finalize(); } // Allows ROSS to function as normal tw_comm_set(split_comm); #endif int i; // get rid of error if compiled w/ MEMORY queues g_tw_memory_nqueues=1; // set a min lookahead of 1.0 lookahead = 1.0; tw_opt_add(app_opt); tw_init(&argc, &argv); #ifdef USE_DAMARIS if(g_st_ross_rank) { // only ross ranks should run code between here and tw_run() #endif if( lookahead > 1.0 ) tw_error(TW_LOC, "Lookahead > 1.0 .. needs to be less\n"); //reset mean based on lookahead mean = mean - lookahead; g_tw_memory_nqueues = 16; // give at least 16 memory queue event offset_lpid = g_tw_mynode * nlp_per_pe; ttl_lps = tw_nnodes() * g_tw_npe * nlp_per_pe; g_tw_events_per_pe = (mult * nlp_per_pe * g_phold_start_events) + optimistic_memory; //g_tw_rng_default = TW_FALSE; g_tw_lookahead = lookahead; tw_define_lps(nlp_per_pe, sizeof(phold_message)); for(i = 0; i < g_tw_nlp; i++) { tw_lp_settype(i, &mylps[0]); st_model_settype(i, &model_types[0]); } if( g_tw_mynode == 0 ) { printf("========================================\n"); printf("PHOLD Model Configuration..............\n"); printf(" Lookahead..............%lf\n", lookahead); printf(" Start-events...........%u\n", g_phold_start_events); printf(" stagger................%u\n", stagger); printf(" Mean...................%lf\n", mean); printf(" Mult...................%lf\n", mult); printf(" Memory.................%u\n", optimistic_memory); printf(" Remote.................%lf\n", percent_remote); printf("========================================\n\n"); } tw_run(); #ifdef USE_DAMARIS } // end if(g_st_ross_rank) #endif tw_end(); return 0; }
int main(int argc, char **argv, char **env) { int i; tw_opt_add(app_opt); tw_init(&argc, &argv); for (i=0; i<N_dims; i++) N_nodes*=dim_length[i]; MEAN_INTERVAL = N_nodes/ARRIVAL_RATE; nlp_per_pe = N_nodes/tw_nnodes()/g_tw_npe; g_tw_events_per_pe = nlp_per_pe/g_tw_npe + opt_mem; tw_define_lps(nlp_per_pe, sizeof(nodes_message), 0); for(i = 0; i < g_tw_nlp; i++) tw_lp_settype(i, &nodes_lps[0]); tw_run(); if(tw_ismaster()) { printf("\nTorus Network Model Statistics:\n"); printf("\t%-50s %11lld\n", "Number of nodes", nlp_per_pe * g_tw_npe * tw_nnodes()); } unsigned long long total_finished_storage[N_COLLECT_POINTS]; unsigned long long total_dropped_storage[N_COLLECT_POINTS]; unsigned long long total_generated_storage[N_COLLECT_POINTS]; unsigned long long wait_length,event_length,N_total_finish,N_total_hop; tw_stime total_time_sum,g_max_latency; for( i=0; i<N_COLLECT_POINTS; i++ ) { MPI_Reduce( &N_dropped_storage[i], &total_dropped_storage[i],1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &N_finished_storage[i], &total_finished_storage[i],1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &N_generated_storage[i], &total_generated_storage[i],1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); } MPI_Reduce( &queueing_times_sum, &event_length,1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &total_queue_length, &wait_length,1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &total_time, &total_time_sum,1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &N_finished, &N_total_finish,1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &total_hops, &N_total_hop,1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce( &max_latency, &g_max_latency,1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); unsigned long long total_rand_total; MPI_Reduce( &rand_total, &total_rand_total,1, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); for( i=1; i<N_COLLECT_POINTS; i++ ) { total_dropped_storage[i]+=total_dropped_storage[i-1]; total_finished_storage[i]+=total_finished_storage[i-1]; total_generated_storage[i]+=total_generated_storage[i-1]; } if(tw_ismaster()) { printf("\n ****************** \n"); printf("\n Total drop: %lld; \n", total_dropped_storage[N_COLLECT_POINTS-1]); printf("\n total finish: %lld and %lld; \n", total_finished_storage[N_COLLECT_POINTS-1],N_total_finish); printf("\n total generate: %lld; \n", total_generated_storage[N_COLLECT_POINTS-1]); printf("\n total hops: %lf; \n", (double)N_total_hop/total_finished_storage[N_COLLECT_POINTS-1]); printf("\n total wait length: %lf; \n", (double)wait_length/total_finished_storage[N_COLLECT_POINTS-1]); printf("\n total total queued: %lf; \n", (double)event_length/total_finished_storage[N_COLLECT_POINTS-1]); printf("\n average travel time: %lf; \n\n", total_time_sum/total_finished_storage[N_COLLECT_POINTS-1]); for( i=0; i<N_COLLECT_POINTS; i++ ) { printf(" %d ",i*100/N_COLLECT_POINTS); printf("drop: %lld; finish: %lld; generate: %lld; alive: %lld\n", total_dropped_storage[i], total_finished_storage[i], total_generated_storage[i], total_generated_storage[i]-total_finished_storage[i]); } // capture the steady state statistics unsigned long long steady_sum=0; for( i = N_COLLECT_POINTS/2; i<N_COLLECT_POINTS;i++) steady_sum+=total_generated_storage[i]-total_finished_storage[i]; printf("\n Steady state, packet alive: %lld\n", 2*steady_sum/N_COLLECT_POINTS); printf("Aeverage is %lld\n",total_rand_total/total_generated_storage[N_COLLECT_POINTS-1]); printf("\nMax latency is %lf\n\n",g_max_latency); } tw_end(); return 0; }
int olsr_main(int argc, char *argv[]) { int i; char log[32]; tw_opt_add(olsr_opts); tw_init(&argc, &argv); #if DEBUG sprintf( log, "olsr-log.%ld", g_tw_mynode ); olsr_event_log = fopen( log, "w+"); if( olsr_event_log == nullptr ) tw_error( TW_LOC, "Failed to Open OLSR Event Log file \n"); #endif g_tw_mapping = CUSTOM; g_tw_custom_initial_mapping = &olsr_custom_mapping; g_tw_custom_lp_global_to_local_map = &olsr_mapping_to_lp; // nlp_per_pe = OLSR_MAX_NEIGHBORS;// / tw_nnodes(); //g_tw_lookahead = SA_INTERVAL; SA_range_start = nlp_per_pe; // Increase nlp_per_pe by nlp_per_pe / OMN nlp_per_pe += nlp_per_pe / OLSR_MAX_NEIGHBORS; g_tw_events_per_pe = OLSR_MAX_NEIGHBORS / 2 * nlp_per_pe + 65536; tw_define_lps(nlp_per_pe, sizeof(olsr_msg_data)); for(i = 0; i < OLSR_END_EVENT; i++) g_olsr_event_stats[i] = 0; for (i = 0; i < SA_range_start; i++) { tw_lp_settype(i, &olsr_lps[0]); } for (i = SA_range_start; i < nlp_per_pe; i++) { tw_lp_settype(i, &olsr_lps[1]); } #if DEBUG printf("g_tw_nlp is %llu\n", g_tw_nlp); #endif tw_run(); if( g_tw_synchronization_protocol != 1 ) { MPI_Reduce( g_olsr_event_stats, g_olsr_root_event_stats, OLSR_END_EVENT, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); } else { for (i = 0; i < OLSR_END_EVENT; i++) { g_olsr_root_event_stats[i] = g_olsr_event_stats[i]; } } if (tw_ismaster()) { for( i = 0; i < OLSR_END_EVENT; i++ ) printf("OLSR Type %s Event Count = %llu \n", event_names[i], g_olsr_root_event_stats[i]); printf("Complete.\n"); } tw_end(); return 0; }
void st_analysis_lp_settype(tw_lpid lpid) { tw_lp_settype(lpid, &analysis_lp[0]); }
void tlm_md_init(int argc, char ** argv, char ** env) { tw_lpid nlp_grid; int i; if(!g_rn_environment) return; g_tlm_stats = tw_calloc(TW_LOC, "", sizeof(*g_tlm_stats), 1); // g_tlm_output_fix up global variables g_tw_ts_end += 0.1; if(0 != strcmp(g_rn_tools_dir, "")) sprintf(g_tlm_spatial_terrain_fn, "tools/%s/terrain.txt", g_rn_tools_dir); else tw_error(TW_LOC, "No terrain file specified!"); /* * Open debug plotting files */ #if 0 g_tlm_waves_plt_f = fopen("waves.plt", "w"); g_tlm_nodes_plt_f = fopen("user_nodes.plt", "w"); g_tlm_parts_plt_f = fopen("particles.plt", "w"); if(!g_tlm_nodes_plt_f || !g_tlm_parts_plt_f) tw_error(TW_LOC, "Unable to open plotting files!"); #endif g_tlm_stats = tw_calloc(TW_LOC, "tlm stats", sizeof(tlm_statistics), 1); memset(g_tlm_stats, 0, sizeof(tlm_statistics)); // # of cells around me = 2 * # spatial_dim g_tlm_spatial_dir = g_tlm_spatial_dim * 2; g_tlm_spatial_coeff = 2.0 / g_tlm_spatial_dir; g_tlm_spatial_grid_i = tw_calloc(TW_LOC, "spatial grid i", sizeof(int), g_tlm_spatial_dim); g_tlm_spatial_offset_ts = tw_calloc(TW_LOC, "spatial offset ts", sizeof(tw_stime), g_tlm_spatial_dir); g_tlm_spatial_offset = g_rn_nmachines / (tw_nnodes() * g_tw_npe); g_tlm_spatial_ground_coeff = 0.75; if(0.0 > g_tlm_wave_loss_coeff) { g_tlm_wave_loss_coeff = 1.0 / exp(g_tlm_wave_attenuation * g_tlm_spatial_d[0]); if(tw_ismaster()) printf("\n\tSETTING WAVE LOSS COEFF %lf! \n\n", g_tlm_wave_loss_coeff); } // speed of light in m/s g_tlm_wave_velocity = 299792458.0; nlp_grid = tlm_grid_init(); ntlm_lp_per_pe = ceil(nlp_grid / (tw_nnodes() * g_tw_npe)); if(tw_nnodes() == 1) ntlm_lp_per_pe = nlp_grid; g_tw_events_per_pe = 1.5 * nlp_grid / (tw_nnodes() * g_tw_npe); g_tw_events_per_pe += g_tlm_optmem; #if 0 for(i = 0; i < g_tlm_spatial_offset; i++) tw_lp_settype(i, types); #endif //tw_error(TW_LOC, "setting types not ported"); if(!tw_ismaster()) return; printf("\nInitializing Model: Transmission Line Matrix\n"); #if DWB printf("\t\t%-42s %11d (%ld)\n", "TLM Membufs", 1000000, g_tlm_fd); #endif #if RM_LOG_STATS g_tlm_output_f = fopen("tlm.log", "w"); if(!g_tlm_output_f) tw_error(TW_LOC, "Unable to open TLM logfile!"); #else g_tlm_output_f = stdout; #endif fprintf(g_tlm_output_f, "\n"); fprintf(g_tlm_output_f, "\t%-50s\n", "Spatial Parameters:"); fprintf(g_tlm_output_f, "\n"); fprintf(g_tlm_output_f, "\t\t%-42s %11.4lf\n", "Spatial Coefficient", g_tlm_spatial_coeff); fprintf(g_tlm_output_f, "\n"); fprintf(g_tlm_output_f, "\t\t%-42s %11dD\n", "Dimensions Computed", g_tlm_spatial_dim); for(i = 0; i < g_tlm_spatial_dim; i++) { fprintf(g_tlm_output_f, "\t\t%-42s %11d %dD\n", "Cells per Dimension", g_tlm_spatial_grid[i], i+1); fprintf(g_tlm_output_f, "\t\t%-42s %11d %dD\n", "Cell Spacing ", g_tlm_spatial_d[i], i+1); } fprintf(g_tlm_output_f, "\n"); fprintf(g_tlm_output_f, "\t%-50s\n", "Temporal Parameters:"); fprintf(g_tlm_output_f, "\n"); fprintf(g_tlm_output_f, "\t\t%-42s %11.11lf\n", "Scatter Offset TS", g_tlm_scatter_ts); fprintf(g_tlm_output_f, "\t\t%-42s %11.4lf\n", "Loss Coefficient", g_tlm_wave_loss_coeff); fprintf(g_tlm_output_f, "\t\t%-42s %11.4lf\n", "Velocity", g_tlm_wave_velocity); for(i = 0; i < g_tlm_spatial_dim; i++) fprintf(g_tlm_output_f, "\t\t%-42s %11.11lf %dD\n", "Timestep (d/V)", g_tlm_spatial_offset_ts[i], i+1); fprintf(g_tlm_output_f, "\t\t%-42s %11.4lf\n", "Amplitude Threshold", g_tlm_wave_threshold); fprintf(g_tlm_output_f, "\t%-50s %11d\n", "Spatial Offset", g_tlm_spatial_offset); }
/* * This function initializes the environment model.. should be called * once by user model. Allows EM to control how ROSS is init'd. * * This function provides the Reactive Model with a pre-simulation 'main' */ int rm_initialize(tw_petype * ptypes, tw_lptype * types, tw_peid npe, tw_kpid nkp, tw_lpid nradios, size_t msg_sz) { //FILE *fp; tw_lptype *t; //tw_pe *pe; //tw_kp *kp; //tw_lp *lp; //size_t size; //int max_name; int ntypes; tw_lpid nlp_grid; //int nkp_grid; //int nnodes; int i; //int j; //int k; //int m; //int kp_per_pe; /* * Open debug plotting files */ #if 0 g_rm_waves_plt_f = fopen("waves.plt", "w"); g_rm_nodes_plt_f = fopen("user_nodes.plt", "w"); g_rm_parts_plt_f = fopen("particles.plt", "w"); if(!g_rm_nodes_plt_f || !g_rm_parts_plt_f) tw_error(TW_LOC, "Unable to open plotting files!"); #endif g_rm_stats = tw_calloc(TW_LOC, "rm stats", sizeof(rm_statistics), 1); memset(g_rm_stats, 0, sizeof(rm_statistics)); // # of cells around me = 2 * # spatial_dim g_rm_spatial_dir = g_rm_spatial_dim * 2; g_rm_spatial_offset = nradios; g_rm_spatial_coeff = 2.0 / g_rm_spatial_dir; g_rm_spatial_grid_i = tw_calloc(TW_LOC, "spatial grid i", sizeof(int), g_rm_spatial_dim); g_rm_spatial_offset_ts = tw_calloc(TW_LOC, "spatial offset ts", sizeof(tw_stime), g_rm_spatial_dir); g_rm_spatial_ground_coeff = 0.75; if(0.0 > g_rm_wave_loss_coeff) { g_rm_wave_loss_coeff = 0.5; g_rm_wave_loss_coeff = 1.0 / exp(g_rm_wave_attenuation * g_rm_spatial_d[0]); if(tw_node_eq(&g_tw_mynode, &g_tw_masternode)) printf("\n\tSETTING WAVE LOSS COEFF %lf! \n\n", g_rm_wave_loss_coeff); } g_rm_wave_velocity = 3.0 * 1000.0 * 1000.0 * 1000.0; // Require NULL terminated array, plus LPs for Cells for(ntypes = 2, t = types; t->state_sz; t++) ntypes++; //printf("Creating %d lp types\n", ntypes); t = tw_calloc(TW_LOC, "lp types array", sizeof(tw_lptype), ntypes); memcpy(t, types, sizeof(tw_lptype) * (ntypes-2)); memcpy(&t[ntypes-2], rm_lps, sizeof(rm_lps)); nlp_grid = rm_grid_init(); nrmlp_per_pe = ceil(nlp_grid / (tw_nnodes() * g_tw_npe)); if(tw_nnodes() == 1) nrmlp_per_pe = nlp_grid; nlp_per_pe = nradios + nrmlp_per_pe; g_tw_events_per_pe = .1 * nlp_grid / (tw_nnodes() * g_tw_npe); g_tw_events_per_pe += optimistic_memory; rm_grid_terrain(); for(i = 0; i < g_tw_npe; i++) tw_pe_settype(g_tw_pe[i], rm_pes); tw_pe_settype(&g_rm_pe, ptypes); g_tw_rng_default = TW_FALSE; tw_define_lps(nlp_per_pe, sizeof(rm_message), 0); for(i = 0; i < g_rm_spatial_offset; i++) tw_lp_settype(i, types); for( ; i < g_tw_nlp; i++) tw_lp_settype(i, rm_lps); return 1; }