示例#1
0
/* 
 * parse a table of name-value string pairs and add the configuration
 * parameters to 'config'
 */
void global_config_from_strs(global_config_t *config, str_pair *table, int size)
{
	int idx;
	if ((idx = get_str_index(table, size, "f")) >= 0) {
		if(sscanf(table[idx].value, "%s", config->flp_file) != 1)
			fatal("invalid format for configuration  parameter flp_file\n");
	} else {
		fatal("required parameter flp_file missing. check usage\n");
	}
	if ((idx = get_str_index(table, size, "p")) >= 0) {
		if(sscanf(table[idx].value, "%s", config->p_infile) != 1)
			fatal("invalid format for configuration  parameter p_infile\n");
	} else {
		fatal("required parameter p_infile missing. check usage\n");
	}
	if ((idx = get_str_index(table, size, "o")) >= 0) {
		if(sscanf(table[idx].value, "%s", config->t_outfile) != 1)
			fatal("invalid format for configuration  parameter t_outfile\n");
	} else {
		strcpy(config->t_outfile, NULLFILE);
	}
	if ((idx = get_str_index(table, size, "c")) >= 0) {
		if(sscanf(table[idx].value, "%s", config->config) != 1)
			fatal("invalid format for configuration  parameter config\n");
	} else {
		strcpy(config->config, NULLFILE);
	}
	if ((idx = get_str_index(table, size, "d")) >= 0) {
		if(sscanf(table[idx].value, "%s", config->dump_config) != 1)
			fatal("invalid format for configuration  parameter dump_config\n");
	} else {
		strcpy(config->dump_config, NULLFILE);
	}
}
示例#2
0
//!
//!
//!
//! @param[in] str
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
libvirtNicType libvirtNicType_from_string(const char *str)
{
    return (libvirtNicType) get_str_index(libvirtNicTypeNames, str);
}
示例#3
0
/* 
 * main function - reads instantaneous power values (in W) from a trace
 * file (e.g. "gcc.ptrace") and outputs instantaneous temperature values (in C) to
 * a trace file("gcc.ttrace"). also outputs steady state temperature values
 * (including those of the internal nodes of the model) onto stdout. the
 * trace files are 2-d matrices with each column representing a functional
 * functional block and each row representing a time unit(sampling_intvl).
 * columns are tab-separated and each row is a separate line. the first
 * line contains the names of the functional blocks. the order in which
 * the columns are specified doesn't have to match that of the floorplan 
 * file.
 */
int main(int argc, char **argv)
{
	int i, j, idx, base = 0, count = 0, n = 0;
	int num, size, lines = 0, do_transient = TRUE;
	char **names;
	double *vals;
	/* trace file pointers	*/
	FILE *pin, *tout = NULL;
	/* floorplan	*/
	flp_t *flp;
	/* hotspot temperature model	*/
	RC_model_t *model;
	/* instantaneous temperature and power values	*/
	double *temp = NULL, *power;
	double total_power = 0.0;
	
	/* steady state temperature and power values	*/
	double *overall_power, *steady_temp;
	/* thermal model configuration parameters	*/
	thermal_config_t thermal_config;
	/* global configuration parameters	*/
	global_config_t global_config;
	/* table to hold options and configuration */
	str_pair table[MAX_ENTRIES];
	
	/* variables for natural convection iterations */
	int natural = 0; 
	double avg_sink_temp = 0;
	int natural_convergence = 0;
	double r_convec_old;

	if (!(argc >= 5 && argc % 2)) {
		usage(argc, argv);
		return 1;
	}
	
	size = parse_cmdline(table, MAX_ENTRIES, argc, argv);
	global_config_from_strs(&global_config, table, size);

	/* no transient simulation, only steady state	*/
	if(!strcmp(global_config.t_outfile, NULLFILE))
		do_transient = FALSE;

	/* read configuration file	*/
	if (strcmp(global_config.config, NULLFILE))
		size += read_str_pairs(&table[size], MAX_ENTRIES, global_config.config);

	/* 
	 * earlier entries override later ones. so, command line options 
	 * have priority over config file 
	 */
	size = str_pairs_remove_duplicates(table, size);

	/* get defaults */
	thermal_config = default_thermal_config();
	/* modify according to command line / config file	*/
	thermal_config_add_from_strs(&thermal_config, table, size);
	
	/* if package model is used, run package model */
	if (((idx = get_str_index(table, size, "package_model_used")) >= 0) && !(table[idx].value==0)) {
		if (thermal_config.package_model_used) {
			avg_sink_temp = thermal_config.ambient + SMALL_FOR_CONVEC;
			natural = package_model(&thermal_config, table, size, avg_sink_temp);
			if (thermal_config.r_convec<R_CONVEC_LOW || thermal_config.r_convec>R_CONVEC_HIGH)
				printf("Warning: Heatsink convection resistance is not realistic, double-check your package settings...\n"); 
		}
	}

	/* dump configuration if specified	*/
	if (strcmp(global_config.dump_config, NULLFILE)) {
		size = global_config_to_strs(&global_config, table, MAX_ENTRIES);
		size += thermal_config_to_strs(&thermal_config, &table[size], MAX_ENTRIES-size);
		/* prefix the name of the variable with a '-'	*/
		dump_str_pairs(table, size, global_config.dump_config, "-");
	}

	/* initialization: the flp_file global configuration 
	 * parameter is overridden by the layer configuration 
	 * file in the grid model when the latter is specified.
	 */
	flp = read_flp(global_config.flp_file, FALSE);

	/* allocate and initialize the RC model	*/
	model = alloc_RC_model(&thermal_config, flp);
	populate_R_model(model, flp);
	
	if (do_transient)
		populate_C_model(model, flp);

	#if VERBOSE > 2
	debug_print_model(model);
	#endif

	/* allocate the temp and power arrays	*/
	/* using hotspot_vector to internally allocate any extra nodes needed	*/
	if (do_transient)
		temp = hotspot_vector(model);
	power = hotspot_vector(model);
	steady_temp = hotspot_vector(model);
	overall_power = hotspot_vector(model);
	
	/* set up initial instantaneous temperatures */
	if (do_transient && strcmp(model->config->init_file, NULLFILE)) {
		if (!model->config->dtm_used)	/* initial T = steady T for no DTM	*/
			read_temp(model, temp, model->config->init_file, FALSE);
		else	/* initial T = clipped steady T with DTM	*/
			read_temp(model, temp, model->config->init_file, TRUE);
	} else if (do_transient)	/* no input file - use init_temp as the common temperature	*/
		set_temp(model, temp, model->config->init_temp);

	/* n is the number of functional blocks in the block model
	 * while it is the sum total of the number of functional blocks
	 * of all the floorplans in the power dissipating layers of the 
	 * grid model. 
	 */
	if (model->type == BLOCK_MODEL)
		n = model->block->flp->n_units;
	else if (model->type == GRID_MODEL) {
		for(i=0; i < model->grid->n_layers; i++)
			if (model->grid->layers[i].has_power)
				n += model->grid->layers[i].flp->n_units;
	} else 
		fatal("unknown model type\n");

	if(!(pin = fopen(global_config.p_infile, "r")))
		fatal("unable to open power trace input file\n");
	if(do_transient && !(tout = fopen(global_config.t_outfile, "w")))
		fatal("unable to open temperature trace file for output\n");

	/* names of functional units	*/
	names = alloc_names(MAX_UNITS, STR_SIZE);
	if(read_names(pin, names) != n)
		fatal("no. of units in floorplan and trace file differ\n");

	/* header line of temperature trace	*/
	if (do_transient)
		write_names(tout, names, n);

	/* read the instantaneous power trace	*/
	vals = dvector(MAX_UNITS);
	while ((num=read_vals(pin, vals)) != 0) {
		if(num != n)
			fatal("invalid trace file format\n");

		/* permute the power numbers according to the floorplan order	*/
		if (model->type == BLOCK_MODEL)
			for(i=0; i < n; i++)
				power[get_blk_index(flp, names[i])] = vals[i];
		else
			for(i=0, base=0, count=0; i < model->grid->n_layers; i++) {
				if(model->grid->layers[i].has_power) {
					for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
						idx = get_blk_index(model->grid->layers[i].flp, names[count+j]);
						power[base+idx] = vals[count+j];
					}
					count += model->grid->layers[i].flp->n_units;
				}	
				base += model->grid->layers[i].flp->n_units;	
			}

		/* compute temperature	*/
		if (do_transient) {
			/* if natural convection is considered, update transient convection resistance first */
			if (natural) {
				avg_sink_temp = calc_sink_temp(model, temp);
				natural = package_model(model->config, table, size, avg_sink_temp);
				populate_R_model(model, flp);
			}
			/* for the grid model, only the first call to compute_temp
			 * passes a non-null 'temp' array. if 'temp' is  NULL, 
			 * compute_temp remembers it from the last non-null call. 
			 * this is used to maintain the internal grid temperatures 
			 * across multiple calls of compute_temp
			 */
			if (model->type == BLOCK_MODEL || lines == 0)
				compute_temp(model, power, temp, model->config->sampling_intvl);
			else
				compute_temp(model, power, NULL, model->config->sampling_intvl);
	
			/* permute back to the trace file order	*/
			if (model->type == BLOCK_MODEL)
				for(i=0; i < n; i++)
					vals[i] = temp[get_blk_index(flp, names[i])];
			else
				for(i=0, base=0, count=0; i < model->grid->n_layers; i++) {
					if(model->grid->layers[i].has_power) {
						for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
							idx = get_blk_index(model->grid->layers[i].flp, names[count+j]);
							vals[count+j] = temp[base+idx];
						}
						count += model->grid->layers[i].flp->n_units;	
					}	
					base += model->grid->layers[i].flp->n_units;	
				}
		
			/* output instantaneous temperature trace	*/
			write_vals(tout, vals, n);
		}		
	
		/* for computing average	*/
		if (model->type == BLOCK_MODEL)
			for(i=0; i < n; i++)
				overall_power[i] += power[i];
		else
			for(i=0, base=0; i < model->grid->n_layers; i++) {
				if(model->grid->layers[i].has_power)
					for(j=0; j < model->grid->layers[i].flp->n_units; j++)
						overall_power[base+j] += power[base+j];
				base += model->grid->layers[i].flp->n_units;	
			}

		lines++;
	}    
	if(!lines)
		fatal("no power numbers in trace file\n");
		
	/* for computing average	*/
	if (model->type == BLOCK_MODEL)
		for(i=0; i < n; i++) {
			overall_power[i] /= lines;
			//overall_power[i] /=150; //reduce input power for natural convection
			total_power += overall_power[i];
		}
	else
		for(i=0, base=0; i < model->grid->n_layers; i++) {
			if(model->grid->layers[i].has_power)
				for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
					overall_power[base+j] /= lines;
					total_power += overall_power[base+j];
				}
			base += model->grid->layers[i].flp->n_units;	
		}
		
	/* natural convection r_convec iteration, for steady-state only */ 		
	natural_convergence = 0;
	if (natural) { /* natural convection is used */
		while (!natural_convergence) {
			r_convec_old = model->config->r_convec;
			/* steady state temperature	*/
			steady_state_temp(model, overall_power, steady_temp);
			avg_sink_temp = calc_sink_temp(model, steady_temp) + SMALL_FOR_CONVEC;
			natural = package_model(model->config, table, size, avg_sink_temp);
			populate_R_model(model, flp);
			if (avg_sink_temp > MAX_SINK_TEMP)
				fatal("too high power for a natural convection package -- possible thermal runaway\n");
			if (fabs(model->config->r_convec-r_convec_old)<NATURAL_CONVEC_TOL) 
				natural_convergence = 1;
		}
	}	else /* natural convection is not used, no need for iterations */
	/* steady state temperature	*/
	steady_state_temp(model, overall_power, steady_temp);

	/* print steady state results	*/
	fprintf(stdout, "Unit\tSteady(Kelvin)\n");
	dump_temp(model, steady_temp, "stdout");

	/* dump steady state temperatures on to file if needed	*/
	if (strcmp(model->config->steady_file, NULLFILE))
		dump_temp(model, steady_temp, model->config->steady_file);

	/* for the grid model, optionally dump the most recent 
	 * steady state temperatures of the grid cells	
	 */
	if (model->type == GRID_MODEL &&
		strcmp(model->config->grid_steady_file, NULLFILE))
		dump_steady_temp_grid(model->grid, model->config->grid_steady_file);

	#if VERBOSE > 2
	if (model->type == BLOCK_MODEL) {
		if (do_transient) {
			fprintf(stdout, "printing temp...\n");
			dump_dvector(temp, model->block->n_nodes);
		}
		fprintf(stdout, "printing steady_temp...\n");
		dump_dvector(steady_temp, model->block->n_nodes);
	} else {
		if (do_transient) {
			fprintf(stdout, "printing temp...\n");
			dump_dvector(temp, model->grid->total_n_blocks + EXTRA);
		}
		fprintf(stdout, "printing steady_temp...\n");
		dump_dvector(steady_temp, model->grid->total_n_blocks + EXTRA);
	}
	#endif

	/* cleanup	*/
	fclose(pin);
	if (do_transient)
		fclose(tout);
	delete_RC_model(model);
	free_flp(flp, FALSE);
	if (do_transient)
		free_dvector(temp);
	free_dvector(power);
	free_dvector(steady_temp);
	free_dvector(overall_power);
	free_names(names);
	free_dvector(vals);

	return 0;
}
示例#4
0
//!
//!
//!
//! @param[in] str
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
hypervisorCapabilityType hypervisorCapabilityType_from_string(const char *str)
{
    return (hypervisorCapabilityType) get_str_index(hypervisorCapabilityTypeNames, str);
}
示例#5
0
//!
//!
//!
//! @param[in] str
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
ncResourceFormatType ncResourceFormatType_from_string(const char *str)
{
    return (ncResourceFormatType) get_str_index(ncResourceFormatTypeNames, str);
}
示例#6
0
//!
//!
//!
//! @param[in] createImage_progress_name
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
createImage_progress createImage_progress_from_string(const char *createImage_progress_name)
{
    return (createImage_progress) get_str_index(createImage_progress_names, createImage_progress_name);
}
示例#7
0
//!
//!
//!
//! @param[in] migration_state_name
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
migration_states migration_state_from_string(const char *migration_state_name)
{
    return (migration_states) get_str_index(migration_state_names, migration_state_name);
}
示例#8
0
//!
//!
//!
//! @param[in] bundling_progress_name
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
bundling_progress bundling_progress_from_string(const char *bundling_progress_name)
{
    return (bundling_progress) get_str_index(bundling_progress_names, bundling_progress_name);
}
示例#9
0
//!
//!
//!
//! @param[in] instance_state_name
//!
//! @return result of get_str_index()
//!
//! @see get_str_index()
//!
instance_states instance_state_from_string(const char *instance_state_name)
{
    return (instance_states) get_str_index(instance_state_names, instance_state_name);
}
示例#10
0
文件: flp.c 项目: JensRasche/HotSpot
/* 
 * parse a table of name-value string pairs and add the configuration
 * parameters to 'config'
 */
void flp_config_add_from_strs(flp_config_t *config, str_pair *table, int size)
{
	int idx;
	if ((idx = get_str_index(table, size, "wrap_l2")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->wrap_l2) != 1)
			fatal("invalid format for configuration  parameter wrap_l2\n");
	if ((idx = get_str_index(table, size, "l2_label")) >= 0)
		if(sscanf(table[idx].value, "%s", config->l2_label) != 1)
			fatal("invalid format for configuration  parameter l2_label\n");
	if ((idx = get_str_index(table, size, "model_rim")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->model_rim) != 1)
			fatal("invalid format for configuration  parameter model_rim\n");
	if ((idx = get_str_index(table, size, "rim_thickness")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->rim_thickness) != 1)
			fatal("invalid format for configuration  parameter rim_thickness\n");
	if ((idx = get_str_index(table, size, "compact_ratio")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->compact_ratio) != 1)
			fatal("invalid format for configuration  parameter compact_ratio\n");
	if ((idx = get_str_index(table, size, "n_orients")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->n_orients) != 1)
			fatal("invalid format for configuration  parameter n_orients\n");
	if ((idx = get_str_index(table, size, "P0")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->P0) != 1)
			fatal("invalid format for configuration  parameter P0\n");
	if ((idx = get_str_index(table, size, "Davg")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->Davg) != 1)
			fatal("invalid format for configuration  parameter Davg\n");
	if ((idx = get_str_index(table, size, "Kmoves")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->Kmoves) != 1)
			fatal("invalid format for configuration  parameter Kmoves\n");
	if ((idx = get_str_index(table, size, "Rcool")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->Rcool) != 1)
			fatal("invalid format for configuration  parameter Rcool\n");
	if ((idx = get_str_index(table, size, "Rreject")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->Rreject) != 1)
			fatal("invalid format for configuration  parameter Rreject\n");
	if ((idx = get_str_index(table, size, "Nmax")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->Nmax) != 1)
			fatal("invalid format for configuration  parameter Nmax\n");
	if ((idx = get_str_index(table, size, "lambdaA")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->lambdaA) != 1)
			fatal("invalid format for configuration  parameter lambdaA\n");
	if ((idx = get_str_index(table, size, "lambdaT")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->lambdaT) != 1)
			fatal("invalid format for configuration  parameter lambdaT\n");
	if ((idx = get_str_index(table, size, "lambdaW")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->lambdaW) != 1)
			fatal("invalid format for configuration  parameter lambdaW\n");
			
	if (config->rim_thickness <= 0)
		fatal("rim thickness should be greater than zero\n");
	if ((config->compact_ratio < 0) || (config->compact_ratio > 1))
		fatal("compact_ratio should be between 0 and 1\n");
	if ((config->n_orients <= 1) || (config->n_orients & 1))
		fatal("n_orients should be an even number greater than 1\n");
	if (config->Kmoves < 0)
		fatal("Kmoves should be non-negative\n");
	if ((config->P0 < 0) || (config->P0 > 1))
		fatal("P0 should be between 0 and 1\n");
	if ((config->Rcool < 0) || (config->Rcool > 1))
		fatal("Rcool should be between 0 and 1\n");
	if ((config->Rreject < 0) || (config->Rreject > 1))
		fatal("Rreject should be between 0 and 1\n");
	if (config->Nmax < 0)
		fatal("Nmax should be non-negative\n");
}
/* 
 * parse a table of name-value string pairs and add the configuration
 * parameters to 'config'
 */
void thermal_config_add_from_strs(thermal_config_t *config, str_pair *table, int size)
{
	int idx;
	if ((idx = get_str_index(table, size, "t_chip")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_chip) != 1)
			fatal("invalid format for configuration  parameter t_chip\n");
	if ((idx = get_str_index(table, size, "k_chip")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->k_chip) != 1)
			fatal("invalid format for configuration  parameter k_chip\n");
	if ((idx = get_str_index(table, size, "p_chip")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->p_chip) != 1)
			fatal("invalid format for configuration  parameter p_chip\n");
	if ((idx = get_str_index(table, size, "thermal_threshold")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->thermal_threshold) != 1)
			fatal("invalid format for configuration  parameter thermal_threshold\n");
	if ((idx = get_str_index(table, size, "c_convec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->c_convec) != 1)
			fatal("invalid format for configuration  parameter c_convec\n");
	if ((idx = get_str_index(table, size, "r_convec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->r_convec) != 1)
			fatal("invalid format for configuration  parameter r_convec\n");
	if ((idx = get_str_index(table, size, "s_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_sink) != 1)
			fatal("invalid format for configuration  parameter s_sink\n");
	if ((idx = get_str_index(table, size, "t_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_sink) != 1)
			fatal("invalid format for configuration  parameter t_sink\n");
	if ((idx = get_str_index(table, size, "k_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->k_sink) != 1)
			fatal("invalid format for configuration  parameter k_sink\n");
	if ((idx = get_str_index(table, size, "p_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->p_sink) != 1)
			fatal("invalid format for configuration  parameter p_sink\n");
	if ((idx = get_str_index(table, size, "s_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_spreader) != 1)
			fatal("invalid format for configuration  parameter s_spreader\n");
	if ((idx = get_str_index(table, size, "t_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_spreader) != 1)
			fatal("invalid format for configuration  parameter t_spreader\n");
	if ((idx = get_str_index(table, size, "k_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->k_spreader) != 1)
			fatal("invalid format for configuration  parameter k_spreader\n");
	if ((idx = get_str_index(table, size, "p_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->p_spreader) != 1)
			fatal("invalid format for configuration  parameter p_spreader\n");
	if ((idx = get_str_index(table, size, "t_interface")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_interface) != 1)
			fatal("invalid format for configuration  parameter t_interface\n");
	if ((idx = get_str_index(table, size, "k_interface")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->k_interface) != 1)
			fatal("invalid format for configuration  parameter k_interface\n");
	if ((idx = get_str_index(table, size, "p_interface")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->p_interface) != 1)
			fatal("invalid format for configuration  parameter p_interface\n");
	if ((idx = get_str_index(table, size, "model_secondary")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->model_secondary) != 1)
			fatal("invalid format for configuration  parameter model_secondary\n");
	if ((idx = get_str_index(table, size, "r_convec_sec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->r_convec_sec) != 1)
			fatal("invalid format for configuration  parameter r_convec_sec\n");
	if ((idx = get_str_index(table, size, "c_convec_sec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->c_convec_sec) != 1)
			fatal("invalid format for configuration  parameter c_convec_sec\n");
	if ((idx = get_str_index(table, size, "n_metal")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->n_metal) != 1)
			fatal("invalid format for configuration  parameter n_metal\n");
	if ((idx = get_str_index(table, size, "t_metal")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_metal) != 1)
			fatal("invalid format for configuration  parameter t_metal\n");
	if ((idx = get_str_index(table, size, "t_c4")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_c4) != 1)
			fatal("invalid format for configuration  parameter t_c4\n");
	if ((idx = get_str_index(table, size, "s_c4")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_c4) != 1)
			fatal("invalid format for configuration  parameter s_c4\n");
	if ((idx = get_str_index(table, size, "n_c4")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->n_c4) != 1)
			fatal("invalid format for configuration  parameter n_c4\n");
	if ((idx = get_str_index(table, size, "s_sub")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_sub) != 1)
			fatal("invalid format for configuration  parameter s_sub\n");	
	if ((idx = get_str_index(table, size, "t_sub")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_sub) != 1)
			fatal("invalid format for configuration  parameter t_sub\n");
	if ((idx = get_str_index(table, size, "s_solder")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_solder) != 1)
			fatal("invalid format for configuration  parameter s_solder\n");
	if ((idx = get_str_index(table, size, "t_solder")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_solder) != 1)
			fatal("invalid format for configuration  parameter t_solder\n");
	if ((idx = get_str_index(table, size, "s_pcb")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_pcb) != 1)
			fatal("invalid format for configuration  parameter s_pcb\n");
	if ((idx = get_str_index(table, size, "t_pcb")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_pcb) != 1)
			fatal("invalid format for configuration  parameter t_pcb\n");		
	if ((idx = get_str_index(table, size, "ambient")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->ambient) != 1)
			fatal("invalid format for configuration  parameter ambient\n");
	if ((idx = get_str_index(table, size, "init_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->init_file) != 1)
			fatal("invalid format for configuration  parameter init_file\n");
	if ((idx = get_str_index(table, size, "init_temp")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->init_temp) != 1)
			fatal("invalid format for configuration  parameter init_temp\n");
	if ((idx = get_str_index(table, size, "steady_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->steady_file) != 1)
			fatal("invalid format for configuration  parameter steady_file\n");
	if ((idx = get_str_index(table, size, "sampling_intvl")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->sampling_intvl) != 1)
			fatal("invalid format for configuration  parameter sampling_intvl\n");
	if ((idx = get_str_index(table, size, "base_proc_freq")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->base_proc_freq) != 1)
			fatal("invalid format for configuration  parameter base_proc_freq\n");
	if ((idx = get_str_index(table, size, "dtm_used")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->dtm_used) != 1)
			fatal("invalid format for configuration  parameter dtm_used\n");
	if ((idx = get_str_index(table, size, "model_type")) >= 0)
		if(sscanf(table[idx].value, "%s", config->model_type) != 1)
			fatal("invalid format for configuration  parameter model_type\n");
		if ((idx = get_str_index(table, size, "leakage_used")) >= 0) 
		if(sscanf(table[idx].value, "%d", &config->leakage_used) != 1)
			fatal("invalid format for configuration  parameter leakage_used\n");
	if ((idx = get_str_index(table, size, "leakage_mode")) >= 0) 
		if(sscanf(table[idx].value, "%d", &config->leakage_mode) != 1)
			fatal("invalid format for configuration  parameter leakage_mode\n");
	if ((idx = get_str_index(table, size, "package_model_used")) >= 0) 
		if(sscanf(table[idx].value, "%d", &config->package_model_used) != 1)
			fatal("invalid format for configuration  parameter package_model_used\n");
	if ((idx = get_str_index(table, size, "package_config_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->package_config_file) != 1)
			fatal("invalid format for configuration  parameter package_config_file\n");
	if ((idx = get_str_index(table, size, "block_omit_lateral")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->block_omit_lateral) != 1)
			fatal("invalid format for configuration  parameter block_omit_lateral\n");
	if ((idx = get_str_index(table, size, "grid_rows")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->grid_rows) != 1)
			fatal("invalid format for configuration  parameter grid_rows\n");
	if ((idx = get_str_index(table, size, "grid_cols")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->grid_cols) != 1)
			fatal("invalid format for configuration  parameter grid_cols\n");
	if ((idx = get_str_index(table, size, "grid_layer_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_layer_file) != 1)
			fatal("invalid format for configuration  parameter grid_layer_file\n");
	if ((idx = get_str_index(table, size, "grid_steady_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_steady_file) != 1)
			fatal("invalid format for configuration  parameter grid_steady_file\n");
	if ((idx = get_str_index(table, size, "grid_map_mode")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_map_mode) != 1)
			fatal("invalid format for configuration  parameter grid_map_mode\n");
	
	if ((config->t_chip <= 0) || (config->s_sink <= 0) || (config->t_sink <= 0) || 
		(config->s_spreader <= 0) || (config->t_spreader <= 0) || 
		(config->t_interface <= 0))
		fatal("chip and package dimensions should be greater than zero\n");
	if ((config->t_metal <= 0) || (config->n_metal <= 0) || (config->t_c4 <= 0) || 
		(config->s_c4 <= 0) || (config->n_c4 <= 0) || (config->s_sub <= 0) || (config->t_sub <= 0) ||
		(config->s_solder <= 0) || (config->t_solder <= 0) || (config->s_pcb <= 0) ||
		(config->t_solder <= 0) || (config->r_convec_sec <= 0) || (config->c_convec_sec <= 0))
		fatal("secondary heat tranfer layer dimensions should be greater than zero\n");
	/* leakage iteration is not supported in transient mode in this release */
	if (config->leakage_used == 1) {
		printf("Warning: transient leakage iteration is not supported in this release...\n");
		printf(" ...all transient results are without thermal-leakage loop.\n");
	}		
	if ((config->model_secondary == 1) && (!strcasecmp(config->model_type, BLOCK_MODEL_STR)))
		fatal("secondary heat tranfer path is supported only in the grid mode\n");	
	if ((config->thermal_threshold < 0) || (config->c_convec < 0) || 
		(config->r_convec < 0) || (config->ambient < 0) || 
		(config->base_proc_freq <= 0) || (config->sampling_intvl <= 0))
		fatal("invalid thermal simulation parameters\n");
	if (strcasecmp(config->model_type, BLOCK_MODEL_STR) &&
		strcasecmp(config->model_type, GRID_MODEL_STR))
		fatal("invalid model type. use 'block' or 'grid'\n");
	if(config->grid_rows <= 0 || config->grid_cols <= 0 ||
	   (config->grid_rows & (config->grid_rows-1)) ||
	   (config->grid_cols & (config->grid_cols-1)))
		fatal("grid rows and columns should both be powers of two\n");
	if (strcasecmp(config->grid_map_mode, GRID_AVG_STR) &&
		strcasecmp(config->grid_map_mode, GRID_MIN_STR) &&
		strcasecmp(config->grid_map_mode, GRID_MAX_STR) &&
		strcasecmp(config->grid_map_mode, GRID_CENTER_STR))
		fatal("invalid mapping mode. use 'avg', 'min', 'max' or 'center'\n");
}
示例#12
0
/* 
 * parse a table of name-value string pairs and add the configuration
 * parameters to 'config'
 */
void thermal_config_add_from_strs(thermal_config_t *config, str_pair *table, int size)
{
	int idx;
	if ((idx = get_str_index(table, size, "t_chip")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_chip) != 1)
			fatal("invalid format for configuration  parameter t_chip");
	if ((idx = get_str_index(table, size, "thermal_threshold")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->thermal_threshold) != 1)
			fatal("invalid format for configuration  parameter thermal_threshold");
	if ((idx = get_str_index(table, size, "c_convec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->c_convec) != 1)
			fatal("invalid format for configuration  parameter c_convec");
	if ((idx = get_str_index(table, size, "r_convec")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->r_convec) != 1)
			fatal("invalid format for configuration  parameter r_convec");
	if ((idx = get_str_index(table, size, "s_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_sink) != 1)
			fatal("invalid format for configuration  parameter s_sink");
	if ((idx = get_str_index(table, size, "t_sink")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_sink) != 1)
			fatal("invalid format for configuration  parameter t_sink");
	if ((idx = get_str_index(table, size, "s_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->s_spreader) != 1)
			fatal("invalid format for configuration  parameter s_spreader");
	if ((idx = get_str_index(table, size, "t_spreader")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_spreader) != 1)
			fatal("invalid format for configuration  parameter t_spreader");
	if ((idx = get_str_index(table, size, "t_interface")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->t_interface) != 1)
			fatal("invalid format for configuration  parameter t_interface");
	if ((idx = get_str_index(table, size, "ambient")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->ambient) != 1)
			fatal("invalid format for configuration  parameter ambient");
	if ((idx = get_str_index(table, size, "init_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->init_file) != 1)
			fatal("invalid format for configuration  parameter init_file");
	if ((idx = get_str_index(table, size, "init_temp")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->init_temp) != 1)
			fatal("invalid format for configuration  parameter init_temp");
	if ((idx = get_str_index(table, size, "steady_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->steady_file) != 1)
			fatal("invalid format for configuration  parameter steady_file");
	if ((idx = get_str_index(table, size, "sampling_intvl")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->sampling_intvl) != 1)
			fatal("invalid format for configuration  parameter sampling_intvl");
	if ((idx = get_str_index(table, size, "base_proc_freq")) >= 0)
		if(sscanf(table[idx].value, "%lf", &config->base_proc_freq) != 1)
			fatal("invalid format for configuration  parameter base_proc_freq");
	if ((idx = get_str_index(table, size, "dtm_used")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->dtm_used) != 1)
			fatal("invalid format for configuration  parameter dtm_used");
	if ((idx = get_str_index(table, size, "model_type")) >= 0)
		if(sscanf(table[idx].value, "%s", config->model_type) != 1)
			fatal("invalid format for configuration  parameter model_type");
	if ((idx = get_str_index(table, size, "block_omit_lateral")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->block_omit_lateral) != 1)
			fatal("invalid format for configuration  parameter block_omit_lateral");
	if ((idx = get_str_index(table, size, "grid_rows")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->grid_rows) != 1)
			fatal("invalid format for configuration  parameter grid_rows");
	if ((idx = get_str_index(table, size, "grid_cols")) >= 0)
		if(sscanf(table[idx].value, "%d", &config->grid_cols) != 1)
			fatal("invalid format for configuration  parameter grid_cols");
	if ((idx = get_str_index(table, size, "grid_layer_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_layer_file) != 1)
			fatal("invalid format for configuration  parameter grid_layer_file");
	if ((idx = get_str_index(table, size, "grid_steady_file")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_steady_file) != 1)
			fatal("invalid format for configuration  parameter grid_steady_file");
	if ((idx = get_str_index(table, size, "grid_map_mode")) >= 0)
		if(sscanf(table[idx].value, "%s", config->grid_map_mode) != 1)
			fatal("invalid format for configuration  parameter grid_map_mode");
	
	if ((config->t_chip <= 0) || (config->s_sink <= 0) || (config->t_sink <= 0) || 
		(config->s_spreader <= 0) || (config->t_spreader <= 0) || 
		(config->t_interface <= 0))
		fatal("chip and package dimensions should be greater than zero\n");
	if ((config->thermal_threshold < 0) || (config->c_convec < 0) || 
		(config->r_convec < 0) || (config->ambient < 0) || 
		(config->base_proc_freq <= 0) || (config->sampling_intvl <= 0))
		fatal("invalid thermal simulation parameters\n");
	if (strcasecmp(config->model_type, BLOCK_MODEL_STR) &&
		strcasecmp(config->model_type, GRID_MODEL_STR))
		fatal("invalid model type. use 'block' or 'grid'\n");
	if(config->grid_rows <=1 || config->grid_cols <= 1)
		fatal("grid rows and columns should both be greater than 1\n");
	if (strcasecmp(config->grid_map_mode, GRID_AVG_STR) &&
		strcasecmp(config->grid_map_mode, GRID_MIN_STR) &&
		strcasecmp(config->grid_map_mode, GRID_MAX_STR) &&
		strcasecmp(config->grid_map_mode, GRID_CENTER_STR))
		fatal("invalid mapping mode. use 'avg', 'min', 'max' or 'center'\n");
}