/* Send an IP datagram. Modeled after the example interface on p 32 of * RFC 791 */ int ip_send( int32 source, /* source address */ int32 dest, /* Destination address */ char protocol, /* Protocol */ char tos, /* Type of service */ char ttl, /* Time-to-live */ struct mbuf **bpp, /* Data portion of datagram */ uint16 length, /* Optional length of data portion */ uint16 id, /* Optional identification */ char df /* Don't-fragment flag */ ){ struct ip ip; /* IP header */ ipOutRequests++; if(bpp == NULL) return -1; if(source == INADDR_ANY) source = locaddr(dest); if(length == 0 && *bpp != NULL) length = len_p(*bpp); if(id == 0) id = Id_cntr++; if(ttl == 0) ttl = ipDefaultTTL; /* Fill in IP header */ ip.version = IPVERSION; ip.tos = tos; ip.length = IPLEN + length; ip.id = id; ip.offset = 0; ip.flags.mf = 0; ip.flags.df = df; ip.flags.congest = 0; ip.ttl = ttl; ip.protocol = protocol; ip.source = source; ip.dest = dest; ip.optlen = 0; if(Ip_trace) dumpip(NULL,&ip,*bpp,0); htonip(&ip,bpp,IP_CS_NEW); if(ismyaddr(ip.dest)){ /* Pretend it has been sent by the loopback interface before * it appears in the receive queue */ #ifdef SIM net_sim(bpp); #else net_route(&Loopback,bpp); #endif Loopback.ipsndcnt++; Loopback.rawsndcnt++; Loopback.lastsent = secclock(); } else net_route(NULL,bpp); return 0; }
int main(int argc, char **argv) { /* Initial information */ fprintf(stderr, "\n"); fprintf(stderr, "; Multi2Sim %s - A Simulation Framework for CPU-GPU Heterogeneous Computing\n", VERSION); fprintf(stderr, "; Please use command 'm2s --help' for a list of command-line options.\n"); fprintf(stderr, "; Last compilation: %s %s\n", __DATE__, __TIME__); fprintf(stderr, "\n"); /* Read command line */ sim_read_command_line(&argc, argv); /* CPU disassembler tool */ if (*cpu_disasm_file_name) ke_disasm(cpu_disasm_file_name); /* GPU disassembler tool */ if (*gpu_disasm_file_name) gk_disasm(gpu_disasm_file_name); /* OpenGL disassembler tool */ if (*opengl_disasm_file_name) gl_disasm(opengl_disasm_file_name, opengl_disasm_shader_index); /* GPU visualization tool */ if (*gpu_visual_file_name) vgpu_run(gpu_visual_file_name); /* Memory hierarchy visualization tool */ if (*visual_file_name) vmem_run(visual_file_name); /* Network simulation tool */ if (*net_sim_network_name) net_sim(net_debug_file_name); /* Debug */ debug_init(); isa_inst_debug_category = debug_new_category(isa_inst_debug_file_name); isa_call_debug_category = debug_new_category(isa_call_debug_file_name); elf_debug_category = debug_new_category(elf_debug_file_name); net_debug_category = debug_new_category(net_debug_file_name); ld_debug_category = debug_new_category(loader_debug_file_name); sys_debug_category = debug_new_category(syscall_debug_file_name); ctx_debug_category = debug_new_category(ctx_debug_file_name); mem_debug_category = debug_new_category(mem_debug_file_name); opencl_debug_category = debug_new_category(opencl_debug_file_name); gpu_isa_debug_category = debug_new_category(gpu_isa_debug_file_name); gpu_stack_debug_category = debug_new_category(gpu_stack_debug_file_name); /* GPU-REL */ gpu_faults_debug_category = debug_new_category(gpu_faults_debug_file_name); /* GPU-REL */ gpu_pipeline_debug_category = debug_new_category(gpu_pipeline_debug_file_name); error_debug_category = debug_new_category(error_debug_file_name); esim_debug_init(esim_debug_file_name); /* Trace */ trace_init(trace_file_name); mem_trace_category = trace_new_category(); /* Initialization for functional simulation */ esim_init(); ke_init(); net_init(); /* Initialization for detailed simulation */ if (cpu_sim_kind == cpu_sim_detailed) cpu_init(); if (gpu_sim_kind == gpu_sim_detailed) gpu_init(); /* Memory hierarchy initialization, done after we initialized CPU cores * and GPU compute units. */ mem_system_init(); /* Load programs */ cpu_load_progs(argc, argv, ctxconfig_file_name); /* Simulation loop */ if (ke->running_list_head) { if (cpu_sim_kind == cpu_sim_detailed) cpu_run(); else ke_run(); } /* Flush event-driven simulation */ esim_process_all_events(0); /* Dump statistics summary */ sim_stats_summary(); /* Finalization of memory system */ mem_system_done(); /* Finalization of detailed CPU simulation */ if (cpu_sim_kind == cpu_sim_detailed) { esim_debug_done(); cpu_done(); } /* Finalization of detailed GPU simulation */ if (gpu_sim_kind == gpu_sim_detailed) gpu_done(); /* Finalization */ net_done(); esim_done(); trace_done(); ke_done(); debug_done(); mhandle_done(); /* End */ return 0; }