Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
uvahotspot
GitHub Repository: uvahotspot/HotSpot
Path: blob/master/temperature.h
612 views
1
#ifndef __TEMPERATURE_H_
2
#define __TEMPERATURE_H_
3
4
#include "flp.h"
5
#include "util.h"
6
#include "microchannel.h"
7
#include "materials.h"
8
9
/* temperature sanity check threshold for natural convection and thermal runaway*/
10
#define TEMP_HIGH 500.0
11
12
/* model type */
13
#define BLOCK_MODEL 0
14
#define GRID_MODEL 1
15
#define BLOCK_MODEL_STR "block"
16
#define GRID_MODEL_STR "grid"
17
18
/* grid to block mapping mode */
19
#define GRID_AVG 0
20
#define GRID_MIN 1
21
#define GRID_MAX 2
22
#define GRID_CENTER 3
23
#define GRID_AVG_STR "avg"
24
#define GRID_MIN_STR "min"
25
#define GRID_MAX_STR "max"
26
#define GRID_CENTER_STR "center"
27
28
/* temperature-leakage loop constants */
29
#define LEAKAGE_MAX_ITER 100 /* max thermal-leakage iteration number, if exceeded, report thermal runaway*/
30
#define LEAK_TOL 0.01 /* thermal-leakage temperature convergence criterion */
31
32
/* number of extra nodes due to the model:
33
* 4 spreader nodes, 4 heat sink nodes under
34
* the spreader (center), 4 peripheral heat
35
* sink nodes (north, south, east and west)
36
* and a separate node for the ambient
37
*/
38
#define EXTRA 12
39
/* spreader nodes */
40
#define SP_W 0
41
#define SP_E 1
42
#define SP_N 2
43
#define SP_S 3
44
/* central sink nodes (directly under the spreader) */
45
#define SINK_C_W 4
46
#define SINK_C_E 5
47
#define SINK_C_N 6
48
#define SINK_C_S 7
49
/* peripheral sink nodes */
50
#define SINK_W 8
51
#define SINK_E 9
52
#define SINK_N 10
53
#define SINK_S 11
54
55
/* secondary extra nodes */
56
#define EXTRA_SEC 16
57
/* package substrate nodes */
58
#define SUB_W 12
59
#define SUB_E 13
60
#define SUB_N 14
61
#define SUB_S 15
62
/* solder ball nodes */
63
#define SOLDER_W 16
64
#define SOLDER_E 17
65
#define SOLDER_N 18
66
#define SOLDER_S 19
67
/* central PCB nodes (directly under the solder balls) */
68
#define PCB_C_W 20
69
#define PCB_C_E 21
70
#define PCB_C_N 22
71
#define PCB_C_S 23
72
/* peripheral PCB nodes */
73
#define PCB_W 24
74
#define PCB_E 25
75
#define PCB_N 26
76
#define PCB_S 27
77
78
/* physical constants, now become configurable in the config file */
79
//#define RHO_SI 0.01 /* thermal resistivity of silicon between 300K-400K in (mK)/W */
80
//#define RHO_CU 0.0025 /* thermal resistivity of copper between 300K-400K in (mK)/W */
81
//#define RHO_INT 0.25 /* thermal resistivity of the interface material in (mK)/W */
82
//#define K_SI (1.0/RHO_SI) /* thermal conductivity of silicon */
83
//#define K_CU (1.0/RHO_CU) /* thermal conductivity of copper */
84
//#define K_INT (1.0/RHO_INT) /* thermal conductivity of the interface material */
85
//#define SPEC_HEAT_SI 1.75e6 /* specfic heat of silicon in J/(m^3K) */
86
//#define SPEC_HEAT_CU 3.55e6 /* specific heat of copper in J/(m^3K) */
87
//#define SPEC_HEAT_INT 4e6 /* specific heat of the interface material in J/(m^3K) */
88
89
/* typical thermal properties for secondary path layers */
90
/* */
91
#define RHO_METAL 0.0025
92
#define RHO_DIELECTRIC 1.0
93
#define RHO_C4 0.8
94
#define RHO_UNDERFILL 0.03
95
#define RHO_SUB 0.5
96
#define RHO_SOLDER 0.06
97
#define RHO_PCB 0.333
98
#define K_METAL (1.0/RHO_METAL)
99
#define K_DIELECTRIC (1.0/RHO_DIELECTRIC)
100
#define K_C4 (1.0/RHO_C4)
101
#define K_UNDERFILL (1.0/RHO_UNDERFILL)
102
#define K_SUB (1.0/RHO_SUB)
103
#define K_SOLDER (1.0/RHO_SOLDER)
104
#define K_PCB (1.0/RHO_PCB)
105
//FIXME! the following values need to be found
106
#define SPEC_HEAT_METAL 3.55e6 /* specfic heat of silicon in J/(m^3K) */
107
#define SPEC_HEAT_DIELECTRIC 2.2e6
108
#define SPEC_HEAT_C4 1.65e6
109
#define SPEC_HEAT_UNDERFILL 2.65e6
110
#define SPEC_HEAT_SUB 1.6e6 /* specific heat of copper in J/(m^3K) */
111
#define SPEC_HEAT_SOLDER 2.1e6 /* specific heat of the interface material in J/(m^3K) */
112
#define SPEC_HEAT_PCB 1.32e6
113
114
/* model specific constants */
115
/* changed from 1/2 to 1/3 due to the difference from traditional Elmore Delay scenario */
116
#define C_FACTOR 0.333 /* fitting factor to match floworks (due to lumping) */
117
118
/* constants related to transient temperature calculation */
119
#define MIN_STEP 1e-7 /* 0.1 us */
120
121
/* BLAS/LAPACK definitions */
122
#define MA_NONE 0
123
#define MA_INTEL 1
124
#define MA_AMD 2
125
#define MA_APPLE 3
126
#define MA_SUN 4
127
128
#if (MATHACCEL == MA_INTEL)
129
#include <mkl_cblas.h>
130
#include <mkl_lapack.h>
131
#elif (MATHACCEL == MA_AMD)
132
#include <acml.h>
133
#elif (MATHACCEL == MA_APPLE)
134
#include <vecLib/cblas.h>
135
#include <vecLib/clapack.h>
136
#elif (MATHACCEL == MA_SUN)
137
#include <sunperf.h>
138
#endif
139
140
/* thermal model configuration */
141
typedef struct thermal_config_t_st
142
{
143
/* chip specs */
144
double t_chip; /* chip thickness in meters */
145
double k_chip; /* chip thermal conductivity */
146
double p_chip; /* chip specific heat */
147
double thermal_threshold; /* temperature threshold for DTM (Kelvin)*/
148
149
/* heat sink specs */
150
double c_convec; /* convection capacitance in J/K */
151
double r_convec; /* convection resistance in K/W */
152
double s_sink; /* heatsink side in meters */
153
double t_sink; /* heatsink thickness in meters */
154
double k_sink; /* heatsink thermal conductivity */
155
double p_sink; /* heatsink specific heat */
156
157
/* heat spreader specs */
158
double s_spreader; /* spreader side in meters */
159
double t_spreader; /* spreader thickness in meters */
160
double k_spreader; /* spreader thermal conductivity */
161
double p_spreader; /* spreader specific heat */
162
163
/* interface material specs */
164
double t_interface; /* interface material thickness in meters */
165
double k_interface; /* interface material thermal conductivity */
166
double p_interface; /* interface material specific heat */
167
168
/* secondary path specs */
169
int model_secondary;
170
double r_convec_sec;
171
double c_convec_sec;
172
int n_metal;
173
double t_metal;
174
double t_c4;
175
double s_c4;
176
int n_c4;
177
double s_sub;
178
double t_sub;
179
double s_solder;
180
double t_solder;
181
double s_pcb;
182
double t_pcb;
183
184
/* others */
185
double ambient; /* ambient temperature in kelvin */
186
/* initial temperatures from file */
187
char init_file[STR_SIZE];
188
double init_temp; /* if init_file is NULL */
189
/* steady state temperatures to file */
190
char steady_file[STR_SIZE];
191
double sampling_intvl; /* interval per call to compute_temp */
192
double base_proc_freq; /* in Hz */
193
int dtm_used; /* flag to guide the scaling of init Ts */
194
/* model type - block or grid */
195
char model_type[STR_SIZE];
196
197
/* temperature-leakage loop */
198
int leakage_used;
199
int leakage_mode;
200
201
/* package model */
202
int package_model_used; /* flag to indicate whether package model is used */
203
char package_config_file[STR_SIZE]; /* package/fan configurations */
204
205
/* parameters specific to block model */
206
int block_omit_lateral; /* omit lateral resistance? */
207
208
/* parameters specific to grid model */
209
int grid_rows; /* grid resolution - no. of rows */
210
int grid_cols; /* grid resolution - no. of cols */
211
/* layer configuration from file */
212
char grid_layer_file[STR_SIZE];
213
/* output grid temperatures instead of block temperatures */
214
char grid_steady_file[STR_SIZE];
215
/* mapping mode between grid and block models */
216
char grid_map_mode[STR_SIZE];
217
/* transient grid temperatures to file */
218
char grid_transient_file[STR_SIZE];
219
220
int detailed_3D_used; //BU_3D: Added parameter to check for heterogenous R-C model
221
}thermal_config_t;
222
223
/* defaults */
224
thermal_config_t default_thermal_config(void);
225
/*
226
* parse a table of name-value string pairs and add the configuration
227
* parameters to 'config'
228
*/
229
void thermal_config_add_from_strs(thermal_config_t *config, materials_list_t *materials_list, str_pair *table, int size);
230
/*
231
* convert config into a table of name-value pairs. returns the no.
232
* of parameters converted
233
*/
234
int thermal_config_to_strs(thermal_config_t *config, str_pair *table, int max_entries);
235
236
/* package parameters */
237
typedef struct package_RC_t_st
238
{
239
/* lateral resistances */
240
/* peripheral spreader nodes */
241
double r_sp1_x;
242
double r_sp1_y;
243
/* sink's inner periphery */
244
double r_hs1_x;
245
double r_hs1_y;
246
double r_hs2_x;
247
double r_hs2_y;
248
/* sink's outer periphery */
249
double r_hs;
250
251
/* vertical resistances */
252
/* peripheral spreader nodes */
253
double r_sp_per_x;
254
double r_sp_per_y;
255
/* sink's inner periphery */
256
double r_hs_c_per_x;
257
double r_hs_c_per_y;
258
/* sink's outer periphery */
259
double r_hs_per;
260
261
/* vertical capacitances */
262
/* peripheral spreader nodes */
263
double c_sp_per_x;
264
double c_sp_per_y;
265
/* sink's inner periphery */
266
double c_hs_c_per_x;
267
double c_hs_c_per_y;
268
/* sink's outer periphery */
269
double c_hs_per;
270
271
/* vertical R's and C's to ambient */
272
/* sink's inner periphery */
273
double r_amb_c_per_x;
274
double c_amb_c_per_x;
275
double r_amb_c_per_y;
276
double c_amb_c_per_y;
277
/* sink's outer periphery */
278
double r_amb_per;
279
double c_amb_per;
280
281
/* secondary path R's and C's */
282
283
/* lateral resistances */
284
/* peripheral package substrate nodes */
285
double r_sub1_x;
286
double r_sub1_y;
287
/* peripheral solder ball nodes */
288
double r_solder1_x;
289
double r_solder1_y;
290
/* PCB's inner periphery */
291
double r_pcb1_x;
292
double r_pcb1_y;
293
double r_pcb2_x;
294
double r_pcb2_y;
295
/* PCB's outer periphery */
296
double r_pcb;
297
298
/* vertical resistances */
299
/* peripheral package substrate nodes */
300
double r_sub_per_x;
301
double r_sub_per_y;
302
/* peripheral solder ball nodes */
303
double r_solder_per_x;
304
double r_solder_per_y;
305
/* PCB's inner periphery */
306
double r_pcb_c_per_x;
307
double r_pcb_c_per_y;
308
/* PCB's outer periphery */
309
double r_pcb_per;
310
311
/* vertical capacitances */
312
/* peripheral package substrate nodes */
313
double c_sub_per_x;
314
double c_sub_per_y;
315
/* peripheral solder ballnodes */
316
double c_solder_per_x;
317
double c_solder_per_y;
318
/* PCB's inner periphery */
319
double c_pcb_c_per_x;
320
double c_pcb_c_per_y;
321
/* PCB's outer periphery */
322
double c_pcb_per;
323
324
/* vertical R's and C's to ambient at PCB */
325
/* PCB's inner periphery */
326
double r_amb_sec_c_per_x;
327
double c_amb_sec_c_per_x;
328
double r_amb_sec_c_per_y;
329
double c_amb_sec_c_per_y;
330
/* PCB's outer periphery */
331
double r_amb_sec_per;
332
double c_amb_sec_per;
333
334
}package_RC_t;
335
/* package parameter routines */
336
void populate_package_R(package_RC_t *p, thermal_config_t *config, double width, double height);
337
void populate_package_C(package_RC_t *p, thermal_config_t *config, double width, double height);
338
/* debug print */
339
void debug_print_package_RC(package_RC_t *p);
340
341
/* slope function pointer - used as a call back by the transient solver */
342
typedef void (*slope_fn_ptr)(void *model, void *y, void *p, void *dy);
343
344
/* hotspot thermal model - can be a block or grid model */
345
struct block_model_t_st;
346
struct grid_model_t_st;
347
typedef struct RC_model_t_st
348
{
349
union
350
{
351
struct block_model_t_st *block;
352
struct grid_model_t_st *grid;
353
};
354
/* block model or grid model */
355
int type;
356
thermal_config_t *config;
357
}RC_model_t;
358
359
/* constructor/destructor */
360
/* placeholder is an empty floorplan frame with only the names of the functional units */
361
RC_model_t *alloc_RC_model(thermal_config_t *config, flp_t *placeholder, microchannel_config_t *microchannel_config, materials_list_t *materials_list,
362
int do_detailed_3D, int use_microchannels);
363
void delete_RC_model(RC_model_t *model);
364
365
/* initialization */
366
void populate_R_model(RC_model_t *model, flp_t *flp);
367
void populate_C_model(RC_model_t *model, flp_t *flp);
368
369
/* hotspot main interfaces - temperature.c */
370
void steady_state_temp(RC_model_t *model, double *power, double *temp);
371
void compute_temp(RC_model_t *model, double *power, double *temp, double time_elapsed);
372
/* differs from 'dvector()' in that memory for internal nodes is also allocated */
373
double *hotspot_vector(RC_model_t *model);
374
/* copy 'src' to 'dst' except for a window of 'size'
375
* elements starting at 'at'. useful in floorplan
376
* compaction
377
*/
378
void trim_hotspot_vector(RC_model_t *model, double *dst, double *src,
379
int at, int size);
380
/* update the model's node count */
381
void resize_thermal_model(RC_model_t *model, int n_units);
382
void set_temp (RC_model_t *model, double *temp, double val);
383
void dump_temp (RC_model_t *model, double *temp, char *file);
384
void copy_temp (RC_model_t *model, double *dst, double *src);
385
void read_temp (RC_model_t *model, double *temp, char *file, int clip);
386
void dump_power(RC_model_t *model, double *power, char *file);
387
void read_power (RC_model_t *model, double *power, char *file);
388
double find_max_temp(RC_model_t *model, double *temp);
389
double find_avg_temp(RC_model_t *model, double *temp);
390
/* debug print */
391
void debug_print_model(RC_model_t *model);
392
393
/* other functions used by the above interfaces */
394
395
/* LUP decomposition */
396
void lupdcmp(double**a, int n, int *p, int spd);
397
398
/* get the thermal resistance and capacitance values */
399
double getr(double conductivity, double thickness, double area);
400
double getcap(double sp_heat, double thickness, double area);
401
402
/* LU forward and backward substitution */
403
void lusolve(double **a, int n, int *p, double *b, double *x, int spd);
404
405
/* 4th order Runge Kutta solver with adaptive step sizing */
406
double rk4(void *model, double *y, void *p, int n, double *h, double *yout, slope_fn_ptr f);
407
408
#if SUPERLU > 0
409
/* Backward Euler solver with adaptive step sizing */
410
double backward_euler(SuperMatrix *G, diagonal_matrix_t *C, double *T, double *P, double *h, double *Tout);
411
#endif
412
413
/* matrix and vector routines */
414
void matmult(double **c, double **a, double **b, int n);
415
/* same as above but 'a' is a diagonal matrix stored as a 1-d array */
416
void diagmatmult(double **c, double *a, double **b, int n);
417
void matvectmult(double *vout, double **m, double *vin, int n);
418
/* same as above but 'm' is a diagonal matrix stored as a 1-d array */
419
void diagmatvectmult(double *vout, double *m, double *vin, int n);
420
/*
421
* inv = m^-1, inv, m are n by n matrices.
422
* the spd flag indicates that m is symmetric
423
* and positive definite
424
*/
425
void matinv(double **inv, double **m, int n, int spd);
426
427
/* dst = src1 + scale * src2 */
428
void scaleadd_dvector (double *dst, double *src1, double *src2, int n, double scale);
429
430
/* temperature-aware leakage calculation */
431
double calc_leakage(int mode, double h, double w, double temp);
432
433
/* calculate average heatsink temperature for natural convection package model */
434
double calc_sink_temp(RC_model_t *model, double *temp);
435
436
#endif
437
438