Example #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);
}
Example #2
0
/* GPU disassembler tool */
void si_emu_disasm(char *path)
{
	struct elf_file_t *elf_file;
	struct elf_symbol_t *symbol;
	struct elf_section_t *section;

	struct si_bin_file_t *amd_bin;

	char kernel_name[MAX_STRING_SIZE];

	int i;

	/* Initialize disassembler */
	si_disasm_init();

	/* Decode external ELF */
	elf_file = elf_file_create_from_path(path);
	for (i = 0; i < list_count(elf_file->symbol_table); i++)
	{
		/* Get symbol and section */
		symbol = list_get(elf_file->symbol_table, i);
		section = list_get(elf_file->section_list, symbol->section);
		if (!section)
			continue;

		/* If symbol is '__OpenCL_XXX_kernel', it points to internal ELF */
		if (str_prefix(symbol->name, "__OpenCL_") && str_suffix(symbol->name, "_kernel"))
		{
			/* Decode internal ELF */
			str_substr(kernel_name, sizeof(kernel_name), symbol->name, 9, strlen(symbol->name) - 16);
			amd_bin = si_bin_file_create(section->buffer.ptr + symbol->value, symbol->size, kernel_name);

			/* Get kernel name */
			printf("**\n** Disassembly for '__kernel %s'\n**\n\n", kernel_name);
			si_disasm_buffer(&amd_bin->enc_dict_entry_southern_islands->sec_text_buffer, stdout);
			printf("\n\n\n");

			/* Free internal ELF */
			si_bin_file_free(amd_bin);
		}
	}

	/* Free external ELF */
	elf_file_free(elf_file);
	si_disasm_done();

	/* End */
	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);
}
Example #4
0
/* GPU OpenGL disassembler tool */
void si_emu_opengl_disasm(char *path, int opengl_shader_index)
{
	void *file_buffer;
	int file_size;

	struct si_opengl_bin_file_t *amd_opengl_bin;
	struct si_opengl_shader_t *amd_opengl_shader;

	/* Initialize disassembler */
	si_disasm_init();

	/* Load file into memory buffer */
	file_buffer = read_buffer(path, &file_size);
	if(!file_buffer)
		fatal("%s:Invalid file!", path);

	/* Analyze the file and initialize structure */	
	amd_opengl_bin = si_opengl_bin_file_create(file_buffer, file_size, path);

	free_buffer(file_buffer);

	/* Basic info of the shader binary */
	printf("This shader binary contains %d shaders\n\n", list_count(amd_opengl_bin->shader_list));
	if (opengl_shader_index > list_count(amd_opengl_bin->shader_list) || opengl_shader_index <= 0 )
	{
		fatal("Shader index out of range! Please choose <index> from 1 ~ %d", list_count(amd_opengl_bin->shader_list));
	}

	/* Disassemble */
	amd_opengl_shader = list_get(amd_opengl_bin->shader_list, opengl_shader_index - 1 );
	printf("**\n** Disassembly for shader %d\n**\n\n", opengl_shader_index);
	si_disasm_buffer(&amd_opengl_shader->isa_buffer, stdout);
	printf("\n\n\n");

	/* Free */
	si_opengl_bin_file_free(amd_opengl_bin);
	si_disasm_done();

	/* End */
	mhandle_done();
	exit(0);
}
Example #5
0
int main(int argc, char **argv) {
    uint64_t t;
    int myargc = 2;
    ///char **myargv;
    //	printf("\n argc val =%d",argc);
    ///	argc = 2;
    ////	argv[0] = "myself";
    //char *name = "/home/prajakta/praj_multi2sim_RandD/guestos_multi2sim/mytest/simple";
    //printf("\n The length of the hardcoded complete path of simple file is : %d\n", strlen(name));
    //argv[1] = "/home/prajakta/praj_multi2sim_RandD/guestos_multi2sim/mytest/simple";


    fprintf(stderr, "********************************************************");
    fprintf(stderr, "\n WELCOME TO GUESTOS\n");
    fprintf(stderr, "********************************************************\n");
    //Subhajit Changes

    /* Options */
    opt_init();
    sim_reg_options();
    ///////////////////////////////////////
    /////	p_reg_options();
    ///	cache_system_reg_options();
    ////	opt_check_options(&argc, argv);

    /////////////////////////////////////////////





    /* Initialize */
    ke_init();

    boot();

    /////	install_sighandler();
    //	printf("\n enter path:");
    //	fgets(user_prog_path,200,stdin);
    //for( ii=0;ii<strlen(user_prog_path);ii++)
    //	argv[1][ii]=user_prog_path[ii];
    //char * origargv= argv;
    //argv=argv++;
    //argv[1]=(char *)user_prog_path;
    //The following lines are written to take the file path from the user and removing the last string terminating character....
    /*	argv[1] = (char *)malloc(strlen( (user_prog_path) - 1) * sizeof(char));
    	for(i = 0; i < strlen(user_prog_path) - 1;i++)
    	argv[1][i] = user_prog_path[i];*/
    //argv=origargv;

    //argv=argv++;
    //// argv=user_prog_path;
    //argv=origargv;
    ///fgets(user_prog_path,max_path_length,stdin);
    shell();
    if (*configfile) {
        ///		printf("\n Entered inside checking\n\n")	;
        opt_check_config(configfile);
    }
    //////////printf("\n User entered path of binary in main : %s",user_prog_path);
    //strncpy(*(argv+1),user_prog_path,max_path_length);
    //	strncpy(myargv[0],user_prog_path,200);
    //	strcpy(argv[1],user_prog_path);
    //printf("\nafter strcpy");
    //argv[1] = user_prog_path;
    //printf("\n\n\\nnnnnnnnnnnnnnnnnnnnnnnn");
    //	printf("\n Value of argv[1] is : %s\n\n\n", argv[1]);
    //	printf("\n Length of file name in argv[1] = %d\n", strlen(argv[1]));
    //strncpy(argv[1],user_prog_path,max_path_length);
    ///////strcpy(argv[0],user_prog_path);
    ///printf("\n the rcvd pa ths is %s \n",user_prog_path);

    ///printf("\n the rcvd pa ths is %s \n",user_prog_path);
    ///printf("\n the rcvd pa ths is %s \n",user_prog_path);
    /* Load programs from configuration file and command line. */
    ///////	if (*ctxconfig)
    ld_load_prog_from_ctxconfig(ctxconfig);
    ///////////////////if (argc >= 1)
    ///		ld_load_prog_from_cmdline(argc - 1, user_prog_path );
    ////////////		ld_load_prog_from_cmdline(argc - 1, argv + 1);
    ///		ld_load_prog_from_cmdline(argc - 1, myargv);

    /* Simulation loop */
    signal(SIGINT, &sim_signal_handler);
    signal(SIGABRT, &sim_signal_handler);
    signal(SIGFPE, &sim_signal_handler);
    signal(SIGUSR2, &sim_signal_handler);
    //raise(8);
    //raise(10);
    //raise(12);
    while (!sigint_received) {

        /* Break point */
        if (break_point && ke->context_list_head->regs->eip == break_point) {
            regs_dump(ke->context_list_head->regs, stdout);
            break;
        }

        /* Run an instruction from each running context */
        ke_run();
        sim_inst += ke->running_count;
        if (!ke->context_list_head)
            break;

        /* Stop conditions */
        sim_cycle++;
        if ((sim_cycle >= max_cycles && max_cycles) ||
                (sim_inst >= max_inst && max_inst)) {
            regs_dump(isa_regs, stdout);
            ke_dump(stdout);
            break;
        }
        if (sim_cycle == inst_reset && inst_reset)
            isa_inst_stat_reset();

        if (*inst_stop && !strcmp(isa_inst.format, inst_stop))
            panic("instruction '%s' found", inst_stop);


    }

    /* Finalization */
    ke_done();
    ///opt_done();
    ///debug_done();
    mhandle_done();
    return 0;
}
Example #6
0
File: m2s.c Project: 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;
}