struct frm_mod_t *frm_mod_create_with_name(char *name) { struct frm_mod_t *mod; enum frm_token_type_t token_type = frm_token_invalid; char long_name[40]; /* % is removed from the mod in the previous processing but the * frm_token_map has % in each token, so it's added back. This will * be changed later */ strcpy(long_name, "%"); strcat(long_name, name); /* Allocate */ mod = xcalloc(1, sizeof(struct frm_mod_t)); /* create mod obj according to the mod type */ token_type = str_map_string_case(&frm_token_map, long_name); if (token_type != frm_token_invalid) { mod->type = token_type; } else { mod->type = token_type; printf("invalid modifier type! [%s]\n", name); } /* Return */ return mod; }
static int mem_system_command_get_state(struct list_t *token_list, char *command_line) { int state; /* Get state */ mem_system_command_expect(token_list, command_line); state = str_map_string_case(&cache_block_state_map, str_token_list_first(token_list)); if (!state && strcasecmp(str_token_list_first(token_list), "I")) fatal("%s: invalid state.\n\t> %s", __FUNCTION__, command_line); /* Return */ str_token_list_shift(token_list); return state; }
static enum mod_access_kind_t mem_system_command_get_mod_access(struct list_t *token_list, char *command_line) { char mod_access_name[MAX_STRING_SIZE]; int mod_access; /* Get access */ mem_system_command_expect(token_list, command_line); snprintf(mod_access_name, sizeof mod_access_name, "%s", str_token_list_first(token_list)); /* Decode access */ mod_access = str_map_string_case(&mod_access_kind_map, mod_access_name); if (!mod_access) fatal("%s: %s: invalid access.\n\t> %s", __FUNCTION__, mod_access_name, command_line); /* Return */ str_token_list_shift(token_list); return mod_access; }
void evg_gpu_read_config(void) { struct config_t *gpu_config; char *section; char *err_note = "\tPlease run 'm2s --evg-help' or consult the Multi2Sim Guide for a\n" "\tdescription of the GPU configuration file format."; char *gpu_register_alloc_granularity_str; char *gpu_sched_policy_str; /* Load GPU configuration file */ gpu_config = config_create(evg_gpu_config_file_name); if (*evg_gpu_config_file_name) config_load(gpu_config); /* Device */ section = "Device"; /* Frequency */ evg_gpu_frequency = config_read_int(gpu_config, section, "Frequency", evg_gpu_frequency); if (!IN_RANGE(evg_gpu_frequency, 1, ESIM_MAX_FREQUENCY)) fatal("%s: invalid value for 'Frequency'.\n%s", evg_gpu_config_file_name, err_note); evg_gpu_num_compute_units = config_read_int(gpu_config, section, "NumComputeUnits", evg_gpu_num_compute_units); evg_gpu_num_stream_cores = config_read_int(gpu_config, section, "NumStreamCores", evg_gpu_num_stream_cores); evg_gpu_num_registers = config_read_int(gpu_config, section, "NumRegisters", evg_gpu_num_registers); evg_gpu_register_alloc_size = config_read_int(gpu_config, section, "RegisterAllocSize", evg_gpu_register_alloc_size); gpu_register_alloc_granularity_str = config_read_string(gpu_config, section, "RegisterAllocGranularity", "WorkGroup"); evg_emu_wavefront_size = config_read_int(gpu_config, section, "WavefrontSize", evg_emu_wavefront_size); evg_gpu_max_work_groups_per_compute_unit = config_read_int(gpu_config, section, "MaxWorkGroupsPerComputeUnit", evg_gpu_max_work_groups_per_compute_unit); evg_gpu_max_wavefronts_per_compute_unit = config_read_int(gpu_config, section, "MaxWavefrontsPerComputeUnit", evg_gpu_max_wavefronts_per_compute_unit); gpu_sched_policy_str = config_read_string(gpu_config, section, "SchedulingPolicy", "RoundRobin"); if (evg_gpu_num_compute_units < 1) fatal("%s: invalid value for 'NumComputeUnits'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_num_stream_cores < 1) fatal("%s: invalid value for 'NumStreamCores'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_register_alloc_size < 1) fatal("%s: invalid value for 'RegisterAllocSize'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_num_registers < 1) fatal("%s: invalid value for 'NumRegisters'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_num_registers % evg_gpu_register_alloc_size) fatal("%s: 'NumRegisters' must be a multiple of 'RegisterAllocSize'.\n%s", evg_gpu_config_file_name, err_note); evg_gpu_register_alloc_granularity = str_map_string_case(&evg_gpu_register_alloc_granularity_map, gpu_register_alloc_granularity_str); if (evg_gpu_register_alloc_granularity == evg_gpu_register_alloc_invalid) fatal("%s: invalid value for 'RegisterAllocGranularity'.\n%s", evg_gpu_config_file_name, err_note); evg_gpu_sched_policy = str_map_string_case(&evg_gpu_sched_policy_map, gpu_sched_policy_str); if (evg_gpu_sched_policy == evg_gpu_sched_invalid) fatal("%s: invalid value for 'SchedulingPolicy'.\n%s", evg_gpu_config_file_name, err_note); if (evg_emu_wavefront_size < 1) fatal("%s: invalid value for 'WavefrontSize'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_max_work_groups_per_compute_unit < 1) fatal("%s: invalid value for 'MaxWorkGroupsPerComputeUnit'.\n%s", evg_gpu_config_file_name, err_note); if (evg_gpu_max_wavefronts_per_compute_unit < 1) fatal("%s: invalid value for 'MaxWavefrontsPerComputeUnit'.\n%s", evg_gpu_config_file_name, err_note); /* Local memory */ section = "LocalMemory"; evg_gpu_local_mem_size = config_read_int(gpu_config, section, "Size", evg_gpu_local_mem_size); evg_gpu_local_mem_alloc_size = config_read_int(gpu_config, section, "AllocSize", evg_gpu_local_mem_alloc_size); evg_gpu_local_mem_block_size = config_read_int(gpu_config, section, "BlockSize", evg_gpu_local_mem_block_size); evg_gpu_local_mem_latency = config_read_int(gpu_config, section, "Latency", evg_gpu_local_mem_latency); evg_gpu_local_mem_num_ports = config_read_int(gpu_config, section, "Ports", evg_gpu_local_mem_num_ports); if ((evg_gpu_local_mem_size & (evg_gpu_local_mem_size - 1)) || evg_gpu_local_mem_size < 4) fatal("%s: %s->Size must be a power of two and at least 4.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_local_mem_alloc_size < 1) fatal("%s: invalid value for %s->Allocsize.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_local_mem_size % evg_gpu_local_mem_alloc_size) fatal("%s: %s->Size must be a multiple of %s->AllocSize.\n%s", evg_gpu_config_file_name, section, section, err_note); if ((evg_gpu_local_mem_block_size & (evg_gpu_local_mem_block_size - 1)) || evg_gpu_local_mem_block_size < 4) fatal("%s: %s->BlockSize must be a power of two and at least 4.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_local_mem_alloc_size % evg_gpu_local_mem_block_size) fatal("%s: %s->AllocSize must be a multiple of %s->BlockSize.\n%s", evg_gpu_config_file_name, section, section, err_note); if (evg_gpu_local_mem_latency < 1) fatal("%s: invalid value for %s->Latency.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_local_mem_size < evg_gpu_local_mem_block_size) fatal("%s: %s->Size cannot be smaller than %s->BlockSize * %s->Banks.\n%s", evg_gpu_config_file_name, section, section, section, err_note); /* CF Engine */ section = "CFEngine"; evg_gpu_cf_engine_inst_mem_latency = config_read_int(gpu_config, section, "InstructionMemoryLatency", evg_gpu_cf_engine_inst_mem_latency); if (evg_gpu_cf_engine_inst_mem_latency < 1) fatal("%s: invalid value for %s->InstructionMemoryLatency.\n%s", evg_gpu_config_file_name, section, err_note); /* ALU Engine */ section = "ALUEngine"; evg_gpu_alu_engine_inst_mem_latency = config_read_int(gpu_config, section, "InstructionMemoryLatency", evg_gpu_alu_engine_inst_mem_latency); evg_gpu_alu_engine_fetch_queue_size = config_read_int(gpu_config, section, "FetchQueueSize", evg_gpu_alu_engine_fetch_queue_size); evg_gpu_alu_engine_pe_latency = config_read_int(gpu_config, section, "ProcessingElementLatency", evg_gpu_alu_engine_pe_latency); if (evg_gpu_alu_engine_inst_mem_latency < 1) fatal("%s: invalid value for %s->InstructionMemoryLatency.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_alu_engine_fetch_queue_size < 56) fatal("%s: the minimum value for %s->FetchQueueSize is 56.\n" "This is the maximum size of one VLIW bundle, including 5 ALU instructions\n" "(2 words each), and 4 literal constants (1 word each).\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_alu_engine_pe_latency < 1) fatal("%s: invalid value for %s->ProcessingElementLatency.\n%s", evg_gpu_config_file_name, section, err_note); /* TEX Engine */ section = "TEXEngine"; evg_gpu_tex_engine_inst_mem_latency = config_read_int(gpu_config, section, "InstructionMemoryLatency", evg_gpu_tex_engine_inst_mem_latency); evg_gpu_tex_engine_fetch_queue_size = config_read_int(gpu_config, section, "FetchQueueSize", evg_gpu_tex_engine_fetch_queue_size); evg_gpu_tex_engine_load_queue_size = config_read_int(gpu_config, section, "LoadQueueSize", evg_gpu_tex_engine_load_queue_size); if (evg_gpu_tex_engine_inst_mem_latency < 1) fatal("%s: invalid value for %s.InstructionMemoryLatency.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_tex_engine_fetch_queue_size < 16) fatal("%s: the minimum value for %s.FetchQueueSize is 16.\n" "This size corresponds to the 4 words comprising a TEX Evergreen instruction.\n%s", evg_gpu_config_file_name, section, err_note); if (evg_gpu_tex_engine_load_queue_size < 1) fatal("%s: the minimum value for %s.LoadQueueSize is 1.\n%s", evg_gpu_config_file_name, section, err_note); /* Periodic report */ evg_periodic_report_config_read(gpu_config); evg_spatial_report_config_read(gpu_config); /* Close GPU configuration file */ config_check(gpu_config); config_free(gpu_config); }