Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
uvahotspot
GitHub Repository: uvahotspot/HotSpot
Path: blob/master/temperature_grid.h
612 views
1
#ifndef __TEMPERATURE_GRID_H_
2
#define __TEMPERATURE_GRID_H_
3
4
/* grid model differs from the block model in its use of
5
* a mesh of cells whose resolution is configurable. unlike
6
* the block model, it can also model a stacked 3-D chip,
7
* with each layer having a different floorplan. information
8
* about the floorplan and the properties of each layer is
9
* input in the form of a layer configuration file.
10
*/
11
#include "temperature.h"
12
#include "microchannel.h"
13
14
#if SUPERLU > 0
15
/* Lib for SuperLU */
16
#include "slu_ddefs.h"
17
#endif
18
19
/* layer configuration file constants */
20
#define LCF_NPARAMS 7 /* no. of parameters per layer */
21
#define LCF_SNO 0 /* serial number */
22
#define LCF_LATERAL 1 /* has lateral heat flow? */
23
#define LCF_POWER 2 /* dissipates power? */
24
#define LCF_SP 3 /* specific heat capacity */
25
#define LCF_RHO 4 /* resistivity */
26
#define LCF_THICK 5 /* thickness */
27
#define LCF_FLP 6 /* floorplan file */
28
29
/* vector types - power / temperature */
30
#define V_POWER 0
31
#define V_TEMP 1
32
33
/* default no. of chip layers (excluding spreader
34
* and sink). used when LCF file is not specified
35
*/
36
#define DEFAULT_CHIP_LAYERS 2
37
#define LAYER_SI 0
38
#define LAYER_INT 1
39
40
/* layers of secondary path with same area as die */
41
#define SEC_CHIP_LAYERS 2
42
#define LAYER_C4 0
43
#define LAYER_METAL 1
44
45
/* default no. of package layers */
46
#define DEFAULT_PACK_LAYERS 2
47
#define LAYER_SP 0
48
#define LAYER_SINK 1
49
50
/* additional package layers from secondary path */
51
#define SEC_PACK_LAYERS 3
52
#define LAYER_PCB 0
53
#define LAYER_SOLDER 1
54
#define LAYER_SUB 2
55
56
/* Occupancy threshold for border-cell calculation.
57
Effective only when the detailed 3D modeling is turned on. */
58
#define OCCUPANCY_THRESHOLD 0.95
59
60
/* block list: block to grid mapping data structure.
61
* list of blocks mapped to a grid cell
62
*/
63
typedef struct blist_t_st
64
{
65
/* index of the mapped block */
66
int idx;
67
/* ratio of this block's area within the grid cell
68
* to the total area of the grid cell
69
*/
70
double occupancy;
71
/* next block mapped to the same cell */
72
struct blist_t_st *next;
73
//BU_3D: The following variables contain the grid specific conductances
74
int lock, hasRes,hasCap;/*lock: is occupancy >OCCUPANCY_THRESHOLD% lock the thermal resistance values */
75
/*hasRes: integer(1 or 0) to see if grid has grid specific resistance */
76
/*hasCap: integer(1 or 0) to see if grid has grid specific Capacitance */
77
double rx,ry,rz;//Thermal Resistance in x,y,z directions
78
double capacitance;//Thermal Capacitance
79
//end->BU_3D
80
}blist_t;
81
82
/* grid list: grid to block mapping data structure.
83
* start and end indices of grid cells in a block
84
* (both in the x and y directions)
85
*/
86
typedef struct glist_t_st
87
{
88
/* start index in the y direction */
89
int i1;
90
/* end index in the y direction + 1 */
91
int i2;
92
/* start index in the x direction */
93
int j1;
94
/* end index in the x direction + 1 */
95
int j2;
96
} glist_t;
97
98
/* one layer of the grid model. a 3-D chip is a stacked
99
* set of layers
100
*/
101
typedef struct layer_t_st
102
{
103
/* floorplan */
104
flp_t *flp;
105
106
/* configuration parameters */
107
int no; /* serial number */
108
int has_lateral; /* model lateral spreading of heat? */
109
int has_power; /* dissipates power? */
110
double k; /* 1/resistivity */
111
double thickness;
112
double sp; /* specific heat capacity */
113
114
/* microchannel parameters */
115
int is_microchannel; /* is a microchannel layer? */
116
microchannel_config_t *microchannel_config; /* config information if is_microchannel = 1 */
117
118
/* extracted information */
119
double rx, ry, rz; /* x, y and z resistors */
120
double c; /* capacitance */
121
122
/* block-grid map - 2-d array of block lists */
123
blist_t ***b2gmap;
124
/* grid-block map - a 1-d array of grid lists */
125
glist_t *g2bmap;
126
}layer_t;
127
128
/* grid model's internal vector datatype */
129
typedef struct grid_model_vector_t_st
130
{
131
/* 3-d grid of nodes */
132
double ***cuboid;
133
/* extra spreader and sink nodes */
134
double *extra;
135
}grid_model_vector_t;
136
137
/* grid thermal model */
138
typedef struct grid_model_t_st
139
{
140
/* configuration */
141
thermal_config_t config;
142
143
/* layer information */
144
layer_t *layers;
145
int n_layers;
146
147
/* grid resolution */
148
int rows;
149
int cols;
150
/* dimensions */
151
double width;
152
double height;
153
154
/* package parameters */
155
package_RC_t pack;
156
157
/* sum total of the functional blocks of all floorplans */
158
int total_n_blocks;
159
/* grid-to-block mapping mode */
160
int map_mode;
161
162
/* flags */
163
int r_ready; /* are the R's initialized? */
164
int c_ready; /* are the C's initialized? */
165
int has_lcf; /* LCF file specified? */
166
167
/* internal state - most recently computed
168
* steady state temperatures
169
*/
170
grid_model_vector_t *last_steady;
171
/* internal state - most recently computed
172
* transient temperatures
173
*/
174
/* grid cell temperatures */
175
grid_model_vector_t *last_trans;
176
/* block temperatures */
177
double *last_temp;
178
179
/* to allow for resizing */
180
int base_n_units;
181
182
/* default microchannel config */
183
int use_microchannels;
184
microchannel_config_t *default_microchannel_config;
185
186
/* Variables used in simulation with SuperLU */
187
#if SUPERLU > 0
188
SuperMatrix G;
189
diagonal_matrix_t *C;
190
#endif
191
}grid_model_t;
192
193
//BU_3D: Functions used to retrieve data from the det3D_grid_reference structure
194
double find_res_3D(int n, int i, int j, grid_model_t *model, int choice);
195
double find_cap_3D(int n, int i, int j, grid_model_t *model);
196
/* constructor/destructor */
197
grid_model_t *alloc_grid_model(thermal_config_t *config, flp_t *flp_default, microchannel_config_t *microchannel_config,
198
materials_list_t *materials_list, int do_detailed_3D, int use_microchannels);//BU_3D: added do_detailed_3D
199
void delete_grid_model(grid_model_t *model);
200
201
/* initialization */
202
void populate_R_model_grid(grid_model_t *model, flp_t *flp);
203
void populate_C_model_grid(grid_model_t *model, flp_t *flp);
204
205
/* hotspot main interfaces - temperature.c */
206
void steady_state_temp_grid(grid_model_t *model, double *power, double *temp);
207
void compute_temp_grid(grid_model_t *model, double *power, double *temp, double time_elapsed);
208
209
/* differs from 'dvector()' in that memory for internal nodes is also allocated */
210
double *hotspot_vector_grid(grid_model_t *model);
211
/* copy 'src' to 'dst' except for a window of 'size'
212
* elements starting at 'at'. useful in floorplan
213
* compaction
214
*/
215
void trim_hotspot_vector_grid(grid_model_t *model, double *dst, double *src,
216
int at, int size);
217
/* update the model's node count */
218
void resize_thermal_model_grid(grid_model_t *model, int n_units);
219
void set_temp_grid (grid_model_t *model, double *temp, double val);
220
void dump_steady_temp_grid (grid_model_t *model, char *file);
221
void dump_temp_grid (grid_model_t *model, double *temp, char *file);
222
void dump_transient_temp_grid(grid_model_t *model, int trace_num, double sampling_intvl, char *filename);
223
void copy_temp_grid (grid_model_t *model, double *dst, double *src);
224
void read_temp_grid (grid_model_t *model, double *temp, char *file, int clip);
225
void dump_power_grid(grid_model_t *model, double *power, char *file);
226
void read_power_grid (grid_model_t *model, double *power, char *file);
227
double find_max_temp_grid(grid_model_t *model, double *temp);
228
double find_avg_temp_grid(grid_model_t *model, double *temp);
229
double calc_sink_temp_grid(grid_model_t *model, double *temp, thermal_config_t *config);
230
231
/* grid_model_vector routines */
232
/* constructor */
233
grid_model_vector_t *new_grid_model_vector(grid_model_t *model);
234
/* destructor */
235
void free_grid_model_vector(grid_model_vector_t *v);
236
/* translate power/temperature between block and grid vectors */
237
void xlate_vector_b2g(grid_model_t *model, double *b, grid_model_vector_t *g, int type);
238
/* translate temperature between grid and block vectors */
239
void xlate_temp_g2b(grid_model_t *model, double *b, grid_model_vector_t *g);
240
/* debug print */
241
void debug_print_grid(grid_model_t *model);
242
243
#if SUPERLU > 0
244
/* steady-state solver */
245
void direct_SLU(grid_model_t *model, grid_model_vector_t *power, grid_model_vector_t *temp);
246
247
/* build steady-state matrices */
248
SuperMatrix build_steady_grid_matrix(grid_model_t *model);
249
SuperMatrix build_steady_rhs_vector(grid_model_t *model, grid_model_vector_t *power, double **rhs);
250
251
SuperMatrix build_transient_grid_matrix(grid_model_t *model);
252
double *build_transient_power_vector(grid_model_t *model, grid_model_vector_t *power);
253
diagonal_matrix_t *build_diagonal_matrix(grid_model_t *model);
254
#endif
255
256
#endif
257
258