示例#1
0
void x86_mem_config_parse_entry(struct config_t *config, char *section)
{
	char *file_name;

	int core;
	int thread;

	int unified_present;
	int data_inst_present;

	char *data_module_name;
	char *inst_module_name;

	/* Get configuration file name */
	file_name = config_get_file_name(config);

	/* Allow these sections in case we quit before reading them. */
	config_var_allow(config, section, "DataModule");
	config_var_allow(config, section, "InstModule");
	config_var_allow(config, section, "Module");

	/* Check right presence of sections */
	unified_present = config_var_exists(config, section, "Module");
	data_inst_present = config_var_exists(config, section, "DataModule") &&
		config_var_exists(config, section, "InstModule");
	if (!(unified_present ^ data_inst_present))
		fatal("%s: section [%s]: invalid combination of modules.\n"
			"\tAn x86 entry to the memory hierarchy needs to specify either a unified\n"
			"\tentry for data and instructions (variable 'Module'), or two separate\n"
			"\tentries for data and instructions (variables 'DataModule' and 'InstModule'),\n"
			"\tbut not both.\n",
			file_name, section);

	/* Read core */
	core = config_read_int(config, section, "Core", -1);
	if (core < 0)
		fatal("%s: section [%s]: invalid or missing value for 'Core'",
			file_name, section);

	/* Read thread */
	thread = config_read_int(config, section, "Thread", -1);
	if (thread < 0)
		fatal("%s: section [%s]: invalid or missing value for 'Thread'",
			file_name, section);

	/* Check bounds */
	if (core >= x86_cpu_num_cores || thread >= x86_cpu_num_threads)
	{
		warning("%s: section [%s] ignored, referring to x86 Core %d, Thread %d.\n"
			"\tThis section refers to a core or thread that does not currently exists.\n"
			"\tPlease review your x86 configuration file if this behavior is not desired.\n",
			file_name, section, core, thread);
		return;
	}

	/* Check that entry has not been assigned before */
	if (X86_THREAD.data_mod || X86_THREAD.inst_mod)
	{
		assert(X86_THREAD.data_mod && X86_THREAD.inst_mod);
		fatal("%s: section [%s]: entry from Core %d, Thread %d already assigned.\n"
			"\tA different [Entry <name>] section in the memory configuration file has already\n"
			"\tassigned an entry for this particular core and thread. Please review your\n"
			"\tconfiguration file to avoid duplicates.\n",
			file_name, section, core, thread);
	}

	/* Read modules */
	if (data_inst_present)
	{
		data_module_name = config_read_string(config, section, "DataModule", NULL);
		inst_module_name = config_read_string(config, section, "InstModule", NULL);
		assert(data_module_name);
		assert(inst_module_name);
	}
	else
	{
		data_module_name = inst_module_name =
			config_read_string(config, section, "Module", NULL);
		assert(data_module_name);
	}

	/* Assign data module */
	X86_THREAD.data_mod = mem_system_get_mod(data_module_name);
	if (!X86_THREAD.data_mod)
		fatal("%s: section [%s]: '%s' is not a valid module name.\n"
			"\tThe given module name must match a module declared in a section\n"
			"\t[Module <name>] in the memory configuration file.\n",
			file_name, section, data_module_name);

	/* Assign instruction module */
	X86_THREAD.inst_mod = mem_system_get_mod(inst_module_name);
	if (!X86_THREAD.inst_mod)
		fatal("%s: section [%s]: '%s' is not a valid module name.\n"
			"\tThe given module name must match a module declared in a section\n"
			"\t[Module <name>] in the memory configuration file.\n",
			file_name, section, inst_module_name);
	
	/* Add modules to entry list */
	linked_list_add(x86_emu_arch->mem_entry_mod_list, X86_THREAD.data_mod);
	if (X86_THREAD.data_mod != X86_THREAD.inst_mod)
		linked_list_add(x86_emu_arch->mem_entry_mod_list, X86_THREAD.inst_mod);

	/* Debug */
	mem_debug("\tx86 Core %d, Thread %d\n", core, thread);
	mem_debug("\t\tEntry for instructions -> %s\n", X86_THREAD.inst_mod->name);
	mem_debug("\t\tEntry for data -> %s\n", X86_THREAD.data_mod->name);
	mem_debug("\n");
}
示例#2
0
void SIGpuMemConfigParseEntry(Timing *self, struct config_t *config, char *section)
{
	char *file_name;
	char *vector_module_name;
	char *scalar_module_name;

	int unified_present;
	int separate_present;

	int compute_unit_id;

	struct si_compute_unit_t *compute_unit;

	/* Get configuration file name */
	file_name = config_get_file_name(config);

	/* Allow these sections in case we quit before reading them. */
	config_var_allow(config, section, "DataModule");
	config_var_allow(config, section, "ConstantDataModule");
	config_var_allow(config, section, "Module");

	unified_present = config_var_exists(config, section, "Module");
	separate_present = config_var_exists(config, section, 
		"DataModule") && config_var_exists(config, section, 
		"ConstantDataModule");

	if (!unified_present && !separate_present)
	{
		fatal(
	"%s: section [%s]: variable 'Module' missing.\n"
	"\tPlease run use '--mem-help' for more information on the\n"
	"\tconfiguration file format, or consult the Multi2Sim Guide.\n",
			file_name, section);
	}

	if (!(unified_present ^ separate_present))
	{
		fatal(
	"%s: section [%s]: invalid combination of modules.\n"
	"\tA Southern Islands entry to the memory hierarchy needs to specify\n"
	"\teither a unified entry for vector and scalar caches (variable \n"
	"\t'Module'), or two separate entries for data and scalar (constant)\n"
	"\tdata (variables 'DataModule' and 'ConstantDataModule'), but not\n"
	"\tboth.\n",
			file_name, section);
	}

	/* Read compute unit */
	compute_unit_id = config_read_int(config, section, "ComputeUnit", -1);
	if (compute_unit_id < 0)
	{
		fatal("%s: section [%s]: invalid or missing value for "
			"'ComputeUnit'", file_name, section);
	}

	/* Check compute unit boundaries */
	if (compute_unit_id >= si_gpu_num_compute_units)
	{
		warning(
	"%s: section [%s] ignored, referring to Southern Islands \n"
	"\tcompute unit %d. This section refers to a compute unit that\n" 
	"\tdoes not currently exist. Please review your Southern Islands\n" 
	"\tconfiguration file if this is not the desired behavior.\n",
			file_name, section, compute_unit_id);
		return;
	}

	/* Check that entry has not been assigned before */
	compute_unit = si_gpu->compute_units[compute_unit_id];
	if (compute_unit->vector_cache)
	{
		fatal(
	"%s: section [%s]: entry from compute unit %d already assigned.\n"
	"\tA different [Entry <name>] section in the memory configuration\n" 
	"\tfile has already assigned an entry for this particular compute \n"
	"\tunit. Please review your tconfiguration file to avoid duplicates.\n",
			file_name, section, compute_unit_id);
	}

	/* Read modules */
	if (separate_present)
	{
		vector_module_name = config_read_string(config, section, 
			"DataModule", NULL);
		scalar_module_name = config_read_string(config, section, 
			"ConstantDataModule", NULL);
	}
	else
	{
		vector_module_name = scalar_module_name =
			config_read_string(config, section, "Module", NULL);
	}
	assert(vector_module_name);
	assert(scalar_module_name);
	
	/* Assign modules */
	compute_unit->vector_cache = mem_system_get_mod(vector_module_name);
	if (!compute_unit->vector_cache)
	{
		fatal(
	"%s: section [%s]: '%s' is not a valid module name.\n"
	"\tThe given module name must match a module declared in a section\n"
	"\t[Module <name>] in the memory configuration file.\n",
			file_name, section, vector_module_name);
	}
	compute_unit->scalar_cache = mem_system_get_mod(scalar_module_name);
	if (!compute_unit->scalar_cache)
	{
		fatal(
	"%s: section [%s]: '%s' is not a valid module name.\n"
	"\tThe given module name must match a module declared in a section\n"
	"\t[Module <name>] in the memory configuration file.\n",
			file_name, section, scalar_module_name);
	}
	
	/* Add modules to list of memory entries */
	linked_list_add(arch_southern_islands->mem_entry_mod_list, 
		compute_unit->vector_cache);
	linked_list_add(arch_southern_islands->mem_entry_mod_list, 
		compute_unit->scalar_cache);
	
	/* Debug */
	mem_debug("\tSouthern Islands compute unit %d\n", compute_unit_id);
	mem_debug("\t\tEntry for vector mem -> %s\n", 
		compute_unit->vector_cache->name);
	mem_debug("\t\tEntry for scalar mem -> %s\n", 
		compute_unit->scalar_cache->name);
	mem_debug("\n");
}