Esempio n. 1
0
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);
}
Esempio n. 2
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);
}
Esempio n. 3
0
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();
}
Esempio n. 4
0
File: m2s.c Progetto: abhaykadam/vm
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;
}