Example #1
0
void EvgGpuCreate(EvgGpu *self)
{
	struct evg_compute_unit_t *compute_unit;
	int compute_unit_id;

	/* Parent */
	TimingCreate(asTiming(self));

	/* Frequency */
	asTiming(self)->frequency = evg_gpu_frequency;
	asTiming(self)->frequency_domain = esim_new_domain(evg_gpu_frequency);

	/* Initialize */
	self->trash_uop_list = linked_list_create();
	self->compute_units = xcalloc(evg_gpu_num_compute_units, sizeof(void *));
	EVG_GPU_FOREACH_COMPUTE_UNIT(compute_unit_id)
	{
		self->compute_units[compute_unit_id] = evg_compute_unit_create();
		compute_unit = self->compute_units[compute_unit_id];
		compute_unit->id = compute_unit_id;
		DOUBLE_LINKED_LIST_INSERT_TAIL(self, ready, compute_unit);
	}

	/* Virtual functions */
	asObject(self)->Dump = EvgGpuDump;
	asTiming(self)->DumpSummary = EvgGpuDumpSummary;
	asTiming(self)->Run = EvgGpuRun;
	asTiming(self)->MemConfigCheck = EvgGpuMemConfigCheck;
	asTiming(self)->MemConfigDefault = EvgGpuMemConfigDefault;
	asTiming(self)->MemConfigParseEntry = EvgGpuMemConfigParseEntry;
}
Example #2
0
void X86CpuCreate(X86Cpu *self, X86Emu *emu) {
  X86Core *core;
  X86Thread *thread;

  char name[MAX_STRING_SIZE];

  int i;
  int j;

  /* Parent */
  TimingCreate(asTiming(self));

  /* Frequency */
  asTiming(self)->frequency = x86_cpu_frequency;
  asTiming(self)->frequency_domain = esim_new_domain(x86_cpu_frequency);

  /* Initialize */
  self->emu = emu;
  self->uop_trace_list = linked_list_create();

  /* Create cores */
  self->cores = xcalloc(x86_cpu_num_cores, sizeof(X86Core *));
  for (i = 0; i < x86_cpu_num_cores; i++) self->cores[i] = new (X86Core, self);

  /* Assign names and IDs to cores and threads */
  for (i = 0; i < x86_cpu_num_cores; i++) {
    core = self->cores[i];
    snprintf(name, sizeof name, "c%d", i);
    X86CoreSetName(core, name);
    core->id = i;
    for (j = 0; j < x86_cpu_num_threads; j++) {
      thread = core->threads[j];
      snprintf(name, sizeof name, "c%dt%d", i, j);
      X86ThreadSetName(thread, name);
      thread->id_in_core = j;
      thread->id_in_cpu = i * x86_cpu_num_threads + j;
    }
  }

  /* Virtual functions */
  asObject(self)->Dump = X86CpuDump;
  asTiming(self)->DumpSummary = X86CpuDumpSummary;
  asTiming(self)->Run = X86CpuRun;
  asTiming(self)->MemConfigCheck = X86CpuMemConfigCheck;
  asTiming(self)->MemConfigDefault = X86CpuMemConfigDefault;
  asTiming(self)->MemConfigParseEntry = X86CpuMemConfigParseEntry;

  /* Trace */
  x86_trace_header("x86.init version=\"%d.%d\" num_cores=%d num_threads=%d\n",
                   X86_TRACE_VERSION_MAJOR, X86_TRACE_VERSION_MINOR,
                   x86_cpu_num_cores, x86_cpu_num_threads);
}
Example #3
0
void net_read_config(void) {
    struct config_t *config;
    struct list_t *net_name_list;
    char *section;
    int i;

    /* Configuration file */
    if (!*net_config_file_name) {
        net_domain_index = esim_new_domain(net_frequency);
        return;
    }

    /* Open network configuration file */
    config = config_create(net_config_file_name);
    if (*net_config_file_name) config_load(config);

    /* Section with generic configuration parameters */
    section = "General";

    /* Frequency */
    net_frequency = config_read_int(config, section, "Frequency", net_frequency);
    if (!IN_RANGE(net_frequency, 1, ESIM_MAX_FREQUENCY))
        fatal("%s: invalid value for 'Frequency'", net_config_file_name);

    /* Create frequency domain */
    net_domain_index = esim_new_domain(net_frequency);

    /* Create a temporary list of network names found in configuration
     * file */
    net_name_list = list_create();
    for (section = config_section_first(config); section;
            section = config_section_next(config)) {
        char *delim = ".";

        char section_str[MAX_STRING_SIZE];
        char *token;
        char *net_name;

        /* Create a copy of section name */
        snprintf(section_str, sizeof section_str, "%s", section);
        section = section_str;

        /* First token must be 'Network' */
        token = strtok(section, delim);
        if (strcasecmp(token, "Network")) continue;

        /* Second token is network name */
        net_name = strtok(NULL, delim);
        if (!net_name) continue;

        /* No third token */
        token = strtok(NULL, delim);
        if (token) continue;

        /* Insert new network name */
        net_name = xstrdup(net_name);
        list_add(net_name_list, net_name);
    }

    /* Print network names */
    net_debug("%s: loading network configuration file\n", net_config_file_name);
    net_debug("networks found:\n");
    for (i = 0; i < net_name_list->count; i++)
        net_debug("\t%s\n", (char *)list_get(net_name_list, i));
    net_debug("\n");

    /* Load networks */
    net_table = hash_table_create(0, 0);
    for (i = 0; i < net_name_list->count; i++) {
        struct net_t *network;
        char *net_name;

        net_name = list_get(net_name_list, i);
        network = net_create_from_config(config, net_name);

        hash_table_insert(net_table, net_name, network);
    }

    /* Free list of network names and configuration file */
    while (net_name_list->count) free(list_remove_at(net_name_list, 0));
    list_free(net_name_list);
    config_free(config);
}
void dram_system_read_config(void)
{
	int i ;
	struct config_t *config;
	struct list_t *dram_system_list;
	char *section;

	if (!*dram_config_file_name)
	{
		dram_domain_index = esim_new_domain(dram_frequency);
		return;
	}

	config = config_create(dram_config_file_name);
	if (*dram_config_file_name)
		config_load(config);

	/* Section with Generic Configuration Parameters */
	section = "General";

	/* Frequency */
	dram_frequency = config_read_int(config, section, "Frequency", dram_frequency);
	if (!IN_RANGE(dram_frequency, 1, ESIM_MAX_FREQUENCY))
		fatal("%s: Invalid value for 'Frequency'", dram_config_file_name);

	/* Creating the Frequency Domain */
	dram_domain_index = esim_new_domain(dram_frequency);

	/* Create a temporary List of all Dram Systems found in
	 * the configuration file */
	dram_system_list = list_create();
	for (section = config_section_first(config); section;
			section = config_section_next(config))
	{
		char *delim = ".";

		char section_str[MAX_STRING_SIZE];
		char *token;
		char *dram_system_name;

		/*Creating a copy of the name of the section */
		snprintf(section_str, sizeof section_str, "%s", section);
		section = section_str;

		/* First Token Must be 'DRAMsystem' */
		token = strtok(section, delim);
		if (strcasecmp(token, "DRAMsystem"))
			continue;

		/* Second Token must be the system Name */
		dram_system_name = strtok(NULL, delim);
		if (!dram_system_name)
			continue;

		/* No third term is required */
		token = strtok(NULL, delim);
		if (token)
			continue;

		/* Insert the new DRAM system name */
		dram_system_name = xstrdup(dram_system_name);
		list_add(dram_system_list, dram_system_name);
	}

	/* Print DRAM system Names in debug */
	dram_debug("%s: loading DRAM system configuration file \n",
			dram_config_file_name);
	dram_debug("DRAM systems found:\n");
	for (i = 0; i < dram_system_list->count; i++)
		dram_debug("\t%s\n", (char *) list_get(dram_system_list, i));
	dram_debug("\n");

	/* Load DRAM systems */
	dram_system_table = hash_table_create(0, 0);
	for ( i = 0; i < dram_system_list->count; i++)
	{
		struct dram_system_t *system;
		char *dram_system_name;

		dram_system_name = list_get(dram_system_list, i);
		system = dram_system_config_with_file(config, dram_system_name);

		hash_table_insert(dram_system_table, dram_system_name, system);
	}
	while (dram_system_list->count)
		free(list_remove_at(dram_system_list, 0));
	list_free(dram_system_list);
	config_free(config);
}