void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Initialize */ inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while (1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name, net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); debug_done(); /* Finish program */ mhandle_done(); exit(0); }
void dram_system_sim (char *debug_file_name) { struct dram_system_t *dram_system; /* Initialize */ debug_init(); esim_init(); dram_system_init(); dram_debug_category = debug_new_category(debug_file_name); /* Getting the simulation name */ if (!*dram_sim_system_name) panic("%s: no DRAM simulation name", __FUNCTION__); dram_system = dram_system_find(dram_sim_system_name); if (!dram_system) fatal("%s: DRAM system does not exist", dram_sim_system_name); esim_process_events(TRUE); while (1) { long long cycle; cycle = esim_domain_cycle(dram_domain_index); if (cycle >= dram_system_max_cycles) break; if ((list_count(dram_system->dram_request_list)) && dram_system_get_request(dram_system)) list_dequeue(dram_system->dram_request_list); dram_system_process(dram_system); /* Next Cycle */ dram_debug("___cycle %lld___\n", cycle); esim_process_events(TRUE); } dram_system_done(); esim_done(); debug_done(); mhandle_done(); exit(0); }
static void net_traffic_uniform(struct net_t *net, double *inject_time) { while (1) { struct net_node_t *node; struct net_node_t *dst_node; long long cycle; int i; /* Get current cycle */ cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; /* Inject messages */ for (i = 0; i < net->node_count; i++) { /* Get end node */ node = list_get(net->node_list, i); if (node->kind != net_node_end) continue; /* Turn for next injection? */ if (inject_time[i] > cycle) continue; /* Get a random destination node */ do { dst_node = list_get(net->node_list, random() % list_count(net->node_list)); } while (dst_node->kind != net_node_end || dst_node == node); /* Inject */ while (inject_time[i] < cycle) { inject_time[i] += exp_random(net_injection_rate); if (net_can_send(net, node, dst_node, net_msg_size)) net_send(net, node, dst_node, net_msg_size); } } /* Next cycle */ net_debug("___ cycle %lld ___\n", cycle); esim_process_events(TRUE); } }
void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Network Trace = Stand Alone */ if (net_tracing()) { /* Initialization of Trace */ net_trace_header("net.init version=\"%d.%d\"\n", NET_SYSTEM_TRACE_VERSION_MAJOR, NET_SYSTEM_TRACE_VERSION_MINOR); /* Network Trace Header */ net_config_trace(net); } inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while(1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name ,net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); trace_done(); debug_done(); }