3D-ICE 3.0.0
power_grid.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <stdlib.h> // For the memory functions malloc/calloc/free
40
41#include "power_grid.h"
42#include "macros.h"
43
44/******************************************************************************/
45
47{
48 pgrid->NLayers = (CellIndex_t) 0u ;
49 pgrid->NCells = (CellIndex_t) 0u ;
50 pgrid->NCellsLayer = (CellIndex_t) 0u ;
51 pgrid->LayersTypeProfile = NULL ;
52 pgrid->FloorplansProfile = NULL ;
53 pgrid->Sources = NULL ;
54 pgrid->Channel = NULL ;
55 pgrid->TopHeatSink = NULL ;
56 pgrid->BottomHeatSink = NULL ;
57 pgrid->HeatSinkTopTcs = NULL ;
58 pgrid->HeatSinkBottomTcs = NULL ;
59 pgrid->CellsCapacities = NULL ;
60}
61
62/******************************************************************************/
63
65{
66 pgrid->NLayers = get_number_of_layers (dimensions) ;
67 pgrid->NCells = get_number_of_cells (dimensions) ;
68 pgrid->NCellsLayer = get_layer_area (dimensions) ;
69
70 pgrid->LayersTypeProfile =
71
72 (StackLayerType_t *) malloc (pgrid->NLayers * sizeof (StackLayerType_t)) ;
73
74 if (pgrid->LayersTypeProfile == NULL)
75
76 return TDICE_FAILURE ;
77
78 pgrid->FloorplansProfile =
79
80 (Floorplan_t **) malloc (pgrid->NLayers * sizeof (Floorplan_t *)) ;
81
82 if (pgrid->FloorplansProfile == NULL)
83 {
84 free (pgrid->LayersTypeProfile) ;
85
86 return TDICE_FAILURE ;
87 }
88
89 pgrid->Sources = (Source_t *) calloc (pgrid->NCells, sizeof(Source_t)) ;
90
91 if (pgrid->Sources == NULL)
92 {
93 fprintf (stderr, "Cannot malloc source vector\n") ;
94
95 free (pgrid->LayersTypeProfile) ;
96 free (pgrid->FloorplansProfile) ;
97
98 return TDICE_FAILURE ;
99 }
100
101 // Update HeatSinkTopTcs and HeatSinkBottomTcs for non-uniform scenario
102 if (dimensions->NonUniform == 1)
103 {
104 // enumerate the top layer
105 CellIndex_t cell_num_top_layer = 0;
106 Non_uniform_cellListNode_t* cell_tmp = dimensions->Cell_list.Last;
107 CellIndex_t layer_info = cell_tmp->Data.layer_info;
108 for(; cell_tmp != NULL && layer_info == cell_tmp->Data.layer_info; cell_tmp=cell_tmp->Prev)
109 {
110 cell_num_top_layer++;
111 layer_info = cell_tmp->Data.layer_info;
112 }
113
114 pgrid->HeatSinkTopTcs = (SolidTC_t *) calloc (cell_num_top_layer, sizeof (SolidTC_t)) ;
115
116 if (pgrid->HeatSinkTopTcs == NULL)
117 {
118 free (pgrid->LayersTypeProfile) ;
119 free (pgrid->FloorplansProfile) ;
120 free (pgrid->Sources) ;
121
122 return TDICE_FAILURE ;
123 }
124
125 // enumerate the bottom layer
126 CellIndex_t cell_num_bottom_layer = 0;
127 cell_tmp = dimensions->Cell_list.First;
128 layer_info = cell_tmp->Data.layer_info;
129 for(; cell_tmp != NULL && layer_info == cell_tmp->Data.layer_info; cell_tmp=cell_tmp->Next)
130 {
131 cell_num_bottom_layer++;
132 layer_info = cell_tmp->Data.layer_info;
133 }
134
135 pgrid->HeatSinkBottomTcs = (SolidTC_t *) calloc (cell_num_bottom_layer, sizeof (SolidTC_t)) ;
136
137 if (pgrid->HeatSinkBottomTcs == NULL)
138 {
139 free (pgrid->LayersTypeProfile) ;
140 free (pgrid->FloorplansProfile) ;
141 free (pgrid->Sources) ;
142 free (pgrid->HeatSinkTopTcs) ;
143
144 return TDICE_FAILURE ;
145 }
146 }
147 else
148 {
149 pgrid->HeatSinkTopTcs = (SolidTC_t *) calloc (pgrid->NCellsLayer, sizeof (SolidTC_t)) ;
150
151 if (pgrid->HeatSinkTopTcs == NULL)
152 {
153 free (pgrid->LayersTypeProfile) ;
154 free (pgrid->FloorplansProfile) ;
155 free (pgrid->Sources) ;
156
157 return TDICE_FAILURE ;
158 }
159
160 pgrid->HeatSinkBottomTcs = (SolidTC_t *) calloc (pgrid->NCellsLayer, sizeof (SolidTC_t)) ;
161
162 if (pgrid->HeatSinkBottomTcs == NULL)
163 {
164 free (pgrid->LayersTypeProfile) ;
165 free (pgrid->FloorplansProfile) ;
166 free (pgrid->Sources) ;
167 free (pgrid->HeatSinkTopTcs) ;
168
169 return TDICE_FAILURE ;
170 }
171 }
172
173 pgrid->CellsCapacities = (Capacity_t *) calloc (pgrid->NCells, sizeof(Capacity_t)) ;
174
175 if (pgrid->CellsCapacities == NULL)
176 {
177 free (pgrid->LayersTypeProfile) ;
178 free (pgrid->FloorplansProfile) ;
179 free (pgrid->Sources) ;
180 free (pgrid->HeatSinkTopTcs) ;
181 free (pgrid->HeatSinkBottomTcs) ;
182
183 return TDICE_FAILURE ;
184 }
185
186
187 CellIndex_t lindex = 0 ;
188
189 while (lindex != pgrid->NLayers)
190 {
191 pgrid->LayersTypeProfile [lindex] = TDICE_LAYER_NONE ;
192 pgrid->FloorplansProfile [lindex] = NULL ;
193
194 lindex++ ;
195 }
196
197 return TDICE_SUCCESS ;
198}
199
200/******************************************************************************/
201
203{
204 if (pgrid->LayersTypeProfile != NULL) free (pgrid->LayersTypeProfile) ;
205
206 if (pgrid->FloorplansProfile != NULL) free (pgrid->FloorplansProfile) ;
207
208 if (pgrid->Sources != NULL) free (pgrid->Sources) ;
209
210 if (pgrid->HeatSinkTopTcs != NULL) free (pgrid->HeatSinkTopTcs) ;
211
212 if (pgrid->HeatSinkBottomTcs != NULL) free (pgrid->HeatSinkBottomTcs) ;
213
214 if (pgrid->CellsCapacities != NULL) free (pgrid->CellsCapacities) ;
215
216 power_grid_init (pgrid) ;
217}
218
219/******************************************************************************/
220
222(
223 PowerGrid_t *pgrid,
224 ThermalGrid_t *tgrid,
225 StackElementList_t *list,
226 Dimensions_t *dimensions
227)
228{
229 StackElementListNode_t *stkeln ;
230
231 for (stkeln = stack_element_list_end (list) ;
232 stkeln != NULL ;
233 stkeln = stack_element_list_prev (stkeln))
234 {
235 StackElement_t *stack_element = stack_element_list_data (stkeln) ;
236
237 CellIndex_t index = stack_element->Offset ;
238
239 switch (stack_element->SEType)
240 {
242 {
243 CellIndex_t tmp = 0u ;
244 LayerListNode_t *lnd ;
245
246 for (lnd = layer_list_end (&stack_element->Pointer.Die->Layers) ;
247 lnd != NULL ;
248 lnd = layer_list_prev (lnd))
249 {
250 pgrid->LayersTypeProfile [index + tmp] = TDICE_LAYER_SOLID ;
251
252 pgrid->FloorplansProfile [index + tmp] = NULL ;
253
254 tmp++ ;
255 }
256
257 tmp = stack_element->Pointer.Die->SourceLayerOffset ;
258
259 pgrid->LayersTypeProfile [index + tmp] = TDICE_LAYER_SOURCE ;
260
261 pgrid->FloorplansProfile [index + tmp] = &stack_element->Pointer.Die->Floorplan ;
262
263 break ;
264 }
266 {
267 pgrid->LayersTypeProfile [index] = TDICE_LAYER_SOLID ;
268
269 pgrid->FloorplansProfile [index] = NULL ;
270
271 break ;
272 }
274 {
275 pgrid->Channel = stack_element->Pointer.Channel ;
276
277 switch (pgrid->Channel->ChannelModel)
278 {
280
282
283 break ;
284
286
288 pgrid->LayersTypeProfile [index + 1] = TDICE_LAYER_VWALL_CHANNEL ;
289 pgrid->LayersTypeProfile [index + 2] = TDICE_LAYER_CHANNEL_2RM ;
290 pgrid->LayersTypeProfile [index + 3] = TDICE_LAYER_TOP_WALL ;
291
292 break ;
293
295
297 pgrid->LayersTypeProfile [index + 1] = TDICE_LAYER_VWALL_PINFINS ;
298 pgrid->LayersTypeProfile [index + 2] = TDICE_LAYER_PINFINS_INLINE ;
299 pgrid->LayersTypeProfile [index + 3] = TDICE_LAYER_TOP_WALL ;
300
301 break ;
302
304
306 pgrid->LayersTypeProfile [index + 1] = TDICE_LAYER_VWALL_PINFINS ;
308 pgrid->LayersTypeProfile [index + 3] = TDICE_LAYER_TOP_WALL ;
309
310 break ;
311
313
314 fprintf (stderr, "WARNING: unset channel model\n") ;
315
316 break ;
317
318 default :
319
320 fprintf (stderr,
321 "WARNING: unknown channel model %d\n",
322 stack_element->Pointer.Channel->ChannelModel) ;
323
324 break ;
325 }
326
327 break ;
328 }
329
331
332 fprintf (stderr, "Error! Found stack element with unset type\n") ;
333 break ;
334
335 default :
336
337 fprintf (stderr, "Error! Unknown stack element type %d\n", stack_element->SEType) ;
338
339 } /* switch stack_element->Type */
340 }
341
342 CellIndex_t layer ;
343 CellIndex_t row ;
344 CellIndex_t column ;
345
346 Capacity_t *tmp = pgrid->CellsCapacities ;
347
348 // NOTE: if the top heatsink is pluggable, there are more elements to fill
349 if (dimensions->NonUniform == 1)
350 {
351 for( Non_uniform_cellListNode_t* i_cell = dimensions->Cell_list.First; i_cell != NULL; i_cell = i_cell->Next)
352 {
353 if (i_cell->Data.layer_info >= dimensions->Grid.NLayers)
354 {
355 break; //don't fill for spreder layer
356 }
357 *tmp++ = get_capacity_non_uniform (tgrid, dimensions, i_cell) ;
358 }
359
360 }
361 else{
362 for (layer = first_layer (dimensions) ;
363 layer <= last_layer (dimensions) ; layer++)
364
365 for (row = first_row (dimensions) ;
366 row <= last_row (dimensions) ; row++)
367
368 for (column = first_column (dimensions) ;
369 column <= last_column (dimensions) ; column++)
370
371 *tmp++ = get_capacity (tgrid, dimensions, layer, row, column) ;
372 }
373
374
375 StackElement_t *bmost = stack_element_list_data (stack_element_list_end (list)) ;
376 StackElement_t *tmost = stack_element_list_data (stack_element_list_begin (list)) ;
377
378 if (tmost->TopSink != NULL)
379 {
380 pgrid->TopHeatSink = tmost->TopSink ;
381
383 {
384 if (pgrid->LayersTypeProfile [pgrid->NLayers - 1] == TDICE_LAYER_SOLID)
385
387
388 else if (pgrid->LayersTypeProfile [pgrid->NLayers - 1] == TDICE_LAYER_SOURCE)
389
391
392 row = (CellIndex_t) 0u ;
393 column = (CellIndex_t) 0u ;
394 layer = last_layer (dimensions) ;
395
396 //Add non-unifrom grid scenario for HeatSinkTopTcs
397 SolidTC_t *tmp = pgrid->HeatSinkTopTcs ;
398 if (dimensions->NonUniform == 1)
399 {
400 // top heatsink grids are aligned with the top layer
401 CellIndex_t last_layer_index = dimensions->Cell_list.Last->Data.layer_info;
402 for( Non_uniform_cellListNode_t* cell_tmp = dimensions->Cell_list.First;
403 cell_tmp != NULL;
404 cell_tmp=cell_tmp->Next)
405 {
406 if (cell_tmp->Data.layer_info == last_layer_index)
407 {
408 *tmp += ( 2.0
409 * get_thermal_conductivity (tgrid->LayersProfile + last_layer_index,
410 0, 0,
411 dimensions)
412 * tgrid->TopHeatSink->AmbientHTC
413 * cell_tmp->Data.length
414 * cell_tmp->Data.width
415 )
416 /
417 ( get_cell_height (dimensions, last_layer_index)
418 * tgrid->TopHeatSink->AmbientHTC
419 + 2.0
420 * get_thermal_conductivity (tgrid->LayersProfile + last_layer_index,
421 0, 0,
422 dimensions)
423 ) ;
424 tmp++;
425 }
426 }
427 }
428 else
429 {
430 for (row = first_row (dimensions) ;
431 row <= last_row (dimensions) ; row++)
432 {
433 for (column = first_column (dimensions) ;
434 column <= last_column (dimensions) ; column++)
435 {
436 *tmp++ += get_conductance_top (tgrid, dimensions, layer, row, column) ;
437
438 } // FOR_EVERY_COLUMN
439 } // FOR_EVERY_ROW
440 }
441
442 }
444 {
445 if (pgrid->LayersTypeProfile [pgrid->NLayers - 1] == TDICE_LAYER_SOLID)
446
448
449 else if (pgrid->LayersTypeProfile [pgrid->NLayers - 1] == TDICE_LAYER_SOURCE)
450
452
453 // Add the missing capacities to pgrid->CellsCapacities
454 for(row = 0; row < tmost->TopSink->NRows; row++)
455 for(column = 0; column < tmost->TopSink->NColumns; column++)
456 *tmp++ = get_spreader_capacity(tmost->TopSink);
457 }
458 else
459 {
460 fprintf (stderr, "Unknown top heatsink model\n") ;
461 }
462 }
463
464 if (bmost->BottomSink != NULL)
465 {
466 pgrid->BottomHeatSink = bmost->BottomSink ;
467
468 if (pgrid->LayersTypeProfile [ 0 ] == TDICE_LAYER_SOLID)
469
471
472 else if (pgrid->LayersTypeProfile [ 0 ] == TDICE_LAYER_SOURCE)
473
475
480
481 fprintf (stderr, "Top and bottom sink on the same layer ! not handled yed\n") ;
482
483 row = (CellIndex_t) 0u ;
484 column = (CellIndex_t) 0u ;
485 SolidTC_t *tmp = pgrid->HeatSinkBottomTcs ;
486
487 if (dimensions->NonUniform == 1)
488 {
489 // bottom heatsink grids are aligned with the bottom layer
490 Non_uniform_cellListNode_t* cell_tmp = dimensions->Cell_list.First;
491 for( CellIndex_t layer_info = cell_tmp->Data.layer_info;
492 cell_tmp != NULL && layer_info == cell_tmp->Data.layer_info;
493 cell_tmp=cell_tmp->Next)
494 {
495 // Darong_TODO.Question: Check why it is different from the way to compute thermal
496 // conductivity for the top heatsink [reference functions, get_conductance_top, get_conductance_bottom]
497 *tmp += ( get_thermal_conductivity (tgrid->LayersProfile + layer_info,
498 0, 0,
499 dimensions)
500 * cell_tmp->Data.length
501 * cell_tmp->Data.width
502 )
503 / (get_cell_height (dimensions, layer_info) / 2.0) ;
504 tmp++;
505 }
506 }
507 else
508 {
509 for (row = first_row (dimensions) ;
510 row <= last_row (dimensions) ; row++)
511 {
512 for (column = first_column (dimensions) ;
513 column <= last_column (dimensions) ; column++)
514 {
515 *tmp++ += get_conductance_bottom (tgrid, dimensions, 0, row, column) ;
516
517 } // FOR_EVERY_COLUMN
518 } // FOR_EVERY_ROW
519 }
520
521
522 }
523}
524
525/******************************************************************************/
526
528(
529 PowerGrid_t *pgrid,
530 Dimensions_t *dimensions
531)
532{
533 // reset all the source vector to 0
534
535 Quantity_t layer ;
536 CellIndex_t ccounter ;
537 Source_t *sources ;
538
539 for (ccounter = 0u, sources = pgrid->Sources ;
540 ccounter != pgrid->NCells ;
541 ccounter++, sources++)
542
543 *sources = (Source_t) 0.0 ;
544
545 if (dimensions->NonUniform==1)
546 {
547 sources = pgrid->Sources;
548 Non_uniform_cellListNode_t* cell_node = dimensions->Cell_list.First;
549 for (layer = 0u;
550 layer != pgrid->NLayers ;
551 layer++)
552 {
553 switch (pgrid->LayersTypeProfile [layer])
554 {
555 case TDICE_LAYER_SOURCE :
557 {
558 Floorplan_t *floorplan = pgrid->FloorplansProfile [layer];
559 Source_t *sources_temp = sources;
560
561 Quantity_t index = 0u ;
562
563 FloorplanElementListNode_t *flpeln ;
564
565 for (flpeln = floorplan_element_list_begin (&floorplan->ElementsList) ;
566 flpeln != NULL ;
567 flpeln = floorplan_element_list_next (flpeln))
568 {
569 FloorplanElement_t *flpel = floorplan_element_list_data (flpeln) ;
570
571 if (is_empty_powers_queue (flpel->PowerValues) == true)
572
573 return TDICE_FAILURE ;
574
575 CellIndex_t cell_per_element = (flpel->ICElements.First->Data.Discr_X) * (flpel->ICElements.First->Data.Discr_Y );
576
577 floorplan->Bpowers [ index ] = get_from_powers_queue (flpel->PowerValues) ;
578 for(CellIndex_t i = 0; i<cell_per_element; i++)
579 {
580 *(sources_temp) += floorplan->Bpowers [ index ] / cell_per_element;
581 sources_temp++;
582 }
583 index++;
584 }
585
586 break ;
587 }
588 case TDICE_LAYER_SOLID :
594
595 break ;
596
598 {
599 Source_t *tmpS = sources ;
600 SolidTC_t *tmpT = pgrid->HeatSinkTopTcs ;
601
602 Non_uniform_cellListNode_t* cell_node_tmp;
603 for (cell_node_tmp = cell_node;
604 cell_node_tmp != NULL; cell_node_tmp = cell_node_tmp->Next)
605
606 *tmpS++ += pgrid->TopHeatSink->AmbientTemperature * *tmpT++ ;
607
608 break ;
609 }
610
612 {
613 Source_t *tmpS = sources ;
614 SolidTC_t *tmpT = pgrid->HeatSinkTopTcs ;
615
616 Non_uniform_cellListNode_t* cell_node_tmp;
617 for (cell_node_tmp = cell_node;
618 cell_node_tmp != NULL; cell_node_tmp = cell_node_tmp->Next)
619
620 *tmpS++ += pgrid->TopHeatSink->AmbientTemperature * *tmpT++ ;
621
622 Floorplan_t *floorplan = pgrid->FloorplansProfile [layer];
623 Source_t *sources_temp = sources;
624
625 Quantity_t index = 0u ;
626
627 FloorplanElementListNode_t *flpeln ;
628
629 for (flpeln = floorplan_element_list_begin (&floorplan->ElementsList) ;
630 flpeln != NULL ;
631 flpeln = floorplan_element_list_next (flpeln))
632 {
633 FloorplanElement_t *flpel = floorplan_element_list_data (flpeln) ;
634
635 if (is_empty_powers_queue (flpel->PowerValues) == true)
636
637 return TDICE_FAILURE ;
638
639 CellIndex_t cell_per_element = (flpel->ICElements.First->Data.Discr_X) * (flpel->ICElements.First->Data.Discr_Y );
640
641 floorplan->Bpowers [ index ] = get_from_powers_queue (flpel->PowerValues) ;
642 for(CellIndex_t i = 0; i<cell_per_element; i++)
643 {
644 *(sources_temp) += floorplan->Bpowers [ index ] / cell_per_element;
645 sources_temp++;
646 }
647 index++;
648 }
649
650 break ;
651 }
652
654 {
655 Source_t *tmpS = sources ;
656 SolidTC_t *tmpT = pgrid->HeatSinkBottomTcs ;
657
658 Non_uniform_cellListNode_t* cell_node_tmp;
659 for (cell_node_tmp = cell_node;
660 cell_node_tmp != NULL; cell_node_tmp = cell_node_tmp->Next)
661
662 *tmpS++ += pgrid->BottomHeatSink->AmbientTemperature * *tmpT++ ;
663
664 break ;
665 }
666
668 {
669 Source_t *tmpS = sources ;
670 SolidTC_t *tmpT = pgrid->HeatSinkBottomTcs ;
671
672 Non_uniform_cellListNode_t* cell_node_tmp;
673 for (cell_node_tmp = cell_node;
674 cell_node_tmp != NULL; cell_node_tmp = cell_node_tmp->Next)
675
676 *tmpS++ += pgrid->BottomHeatSink->AmbientTemperature * *tmpT++ ;
677
678
679 Floorplan_t *floorplan = pgrid->FloorplansProfile [layer];
680 Source_t *sources_temp = sources;
681
682 Quantity_t index = 0u ;
683
684 FloorplanElementListNode_t *flpeln ;
685
686 for (flpeln = floorplan_element_list_begin (&floorplan->ElementsList) ;
687 flpeln != NULL ;
688 flpeln = floorplan_element_list_next (flpeln))
689 {
690 FloorplanElement_t *flpel = floorplan_element_list_data (flpeln) ;
691
692 if (is_empty_powers_queue (flpel->PowerValues) == true)
693
694 return TDICE_FAILURE ;
695
696 CellIndex_t cell_per_element = (flpel->ICElements.First->Data.Discr_X) * (flpel->ICElements.First->Data.Discr_Y );
697
698 floorplan->Bpowers [ index ] = get_from_powers_queue (flpel->PowerValues) ;
699 for(CellIndex_t i = 0; i<cell_per_element; i++)
700 {
701 *(sources_temp) += floorplan->Bpowers [ index ] / cell_per_element;
702 sources_temp++;
703 }
704 index++;
705 }
706
707 break ;
708 }
709
714 {
715 Source_t *tmp = sources ;
716
717 CellIndex_t column ;
718
719 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
720 {
721 if (IS_CHANNEL_COLUMN (pgrid->Channel->ChannelModel, column) == true)
722 {
723 *tmp = (Source_t) 2.0
724
726
727 (pgrid->Channel, dimensions, layer, first_row (dimensions), column)
728
729 * pgrid->Channel->Coolant.TIn ;
730
731 }
732
733 tmp++ ;
734
735 } // FOR_EVERY_COLUMN
736
737 break ;
738 }
739
740 case TDICE_LAYER_NONE :
741
742 fprintf (stderr, "ERROR: unset layer type\n") ;
743
744 return TDICE_FAILURE ;
745
746 default:
747 fprintf (stderr, "ERROR: unknown layer type in non-uniform grid scenario %d\n",
748 pgrid->LayersTypeProfile [layer]) ;
749
750 return TDICE_FAILURE ;
751
752
753 }
754
755 for ( ; cell_node != NULL; cell_node = cell_node->Next)
756 {
757 if (cell_node->Data.layer_info != layer)
758 break;
759 sources++;
760 }
761
762
763 }
764 }
765 else
766 {
767 for (layer = 0u, sources = pgrid->Sources ;
768 layer != pgrid->NLayers ;
769 layer++, sources += get_layer_area (dimensions))
770 {
771 switch (pgrid->LayersTypeProfile [layer])
772 {
773 case TDICE_LAYER_SOURCE :
775 {
777
778 (pgrid->FloorplansProfile [layer], sources) ;
779
780 if (error == TDICE_FAILURE)
781
782 return TDICE_FAILURE ;
783
784 break ;
785 }
786
788 {
789 Source_t *tmpS = sources ;
790 SolidTC_t *tmpT = pgrid->HeatSinkTopTcs ;
791
792 CellIndex_t index = (CellIndex_t) 0u ;
793
794 for (index = (CellIndex_t) 0u ;
795 index != pgrid->NCellsLayer ; index++)
796
797 *tmpS++ += pgrid->TopHeatSink->AmbientTemperature * *tmpT++ ;
798
799 break ;
800 }
801
803 {
804 Source_t *tmpS = sources ;
805 SolidTC_t *tmpT = pgrid->HeatSinkTopTcs ;
806
807 CellIndex_t index = (CellIndex_t) 0u ;
808
809 for (index = (CellIndex_t) 0u ;
810 index != pgrid->NCellsLayer ; index++)
811
812 *tmpS++ += pgrid->TopHeatSink->AmbientTemperature * *tmpT++ ;
813
815
816 (pgrid->FloorplansProfile [layer], sources) ;
817
818 if (error == TDICE_FAILURE)
819
820 return TDICE_FAILURE ;
821
822 break ;
823 }
824
826 {
827 Source_t *tmpS = sources ;
828 SolidTC_t *tmpT = pgrid->HeatSinkBottomTcs ;
829
830 CellIndex_t index = (CellIndex_t) 0u ;
831
832 for (index = (CellIndex_t) 0u ;
833 index != pgrid->NCellsLayer ; index++)
834
835 *tmpS++ += pgrid->BottomHeatSink->AmbientTemperature * *tmpT++ ;
836
837 break ;
838 }
839
841 {
842 Source_t *tmpS = sources ;
843 SolidTC_t *tmpT = pgrid->HeatSinkBottomTcs ;
844
845 CellIndex_t index = (CellIndex_t) 0u ;
846
847 for (index = (CellIndex_t) 0u ;
848 index != pgrid->NCellsLayer ; index++)
849
850 *tmpS++ += pgrid->BottomHeatSink->AmbientTemperature * *tmpT++ ;
851
853
854 (pgrid->FloorplansProfile [layer], sources) ;
855
856 if (error == TDICE_FAILURE)
857
858 return TDICE_FAILURE ;
859
860 break ;
861 }
862
867 {
868 Source_t *tmp = sources ;
869
870 CellIndex_t column ;
871
872 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
873 {
874 if (IS_CHANNEL_COLUMN (pgrid->Channel->ChannelModel, column) == true)
875 {
876 *tmp = (Source_t) 2.0
877
879
880 (pgrid->Channel, dimensions, layer, first_row (dimensions), column)
881
882 * pgrid->Channel->Coolant.TIn ;
883
884 }
885
886 tmp++ ;
887
888 } // FOR_EVERY_COLUMN
889
890 break ;
891 }
892
893 case TDICE_LAYER_SOLID :
899
900 break ;
901
902 case TDICE_LAYER_NONE :
903
904 fprintf (stderr, "ERROR: unset layer type\n") ;
905
906 return TDICE_FAILURE ;
907
908 default :
909
910 fprintf (stderr, "ERROR: unknown layer type %d\n",
911 pgrid->LayersTypeProfile [layer]) ;
912
913 return TDICE_FAILURE ;
914 }
915 }
916 }
917
918 // for (ccounter = 0u, sources = pgrid->Sources ;
919 // ccounter != pgrid->NCells ;
920 // ccounter++, sources++)
921
922 // printf("%d: %f\n", ccounter, *sources) ;
923 return TDICE_SUCCESS ;
924}
925
926/******************************************************************************/
927
929{
930 Quantity_t layer ;
931 Source_t *sources ;
932
933 for (layer = 0u, sources = pgrid->Sources ;
934 layer != pgrid->NLayers ;
935 layer++, sources += get_layer_area (dimensions))
936 {
937 switch (pgrid->LayersTypeProfile [layer])
938 {
943 {
944 Source_t *tmp = sources ;
945
946 CellIndex_t column ;
947
948 for (column = first_column (dimensions) ; column <= last_column (dimensions) ; column++)
949 {
950 if (IS_CHANNEL_COLUMN (pgrid->Channel->ChannelModel, column) == true)
951 {
952 *tmp = (Source_t) 2.0
953
955
956 (pgrid->Channel, dimensions, layer, first_row (dimensions), column)
957
958 * pgrid->Channel->Coolant.TIn ;
959
960 }
961
962 tmp++ ;
963
964 } // FOR_EVERY_COLUMN
965
966 break ;
967 }
968
969 case TDICE_LAYER_SOURCE :
976 case TDICE_LAYER_SOLID :
981
982 break ;
983
984 case TDICE_LAYER_NONE :
985
986 fprintf (stderr, "ERROR: unset layer type\n") ;
987
988 return ;
989
990 default :
991
992 fprintf (stderr, "ERROR: unknown layer type %d\n",
993 pgrid->LayersTypeProfile [layer]) ;
994
995 return ;
996 }
997 }
998}
999
1000/******************************************************************************/
1001
1003{
1004 Quantity_t layer ;
1005
1006 for (layer = 0u ; layer != pgrid->NLayers ; layer++)
1007 {
1008 switch (pgrid->LayersTypeProfile [layer])
1009 {
1010 case TDICE_LAYER_SOURCE :
1014 {
1016
1017 (pgrid->FloorplansProfile [layer], pvalues) ;
1018
1019 if (result == TDICE_FAILURE)
1020
1021 return TDICE_FAILURE ;
1022
1023 break ;
1024 }
1025
1033 case TDICE_LAYER_SOLID :
1038
1039 break ;
1040
1041 case TDICE_LAYER_NONE :
1042
1043 fprintf (stderr, "ERROR: unset layer type\n") ;
1044
1045 return TDICE_FAILURE ;
1046
1047 default :
1048
1049 fprintf (stderr, "ERROR: unknown layer type %d\n",
1050 pgrid->LayersTypeProfile [layer]) ;
1051
1052 return TDICE_FAILURE ;
1053 }
1054 }
1055
1056 return TDICE_SUCCESS ;
1057}
Cconv_t get_convective_term(Channel_t *channel, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
CellDimension_t get_cell_height(Dimensions_t *dimensions, CellIndex_t layer_index)
Definition: dimensions.c:536
CellIndex_t get_number_of_layers(Dimensions_t *dimensions)
Definition: dimensions.c:631
CellIndex_t last_column(Dimensions_t *dimensions)
Definition: dimensions.c:456
CellIndex_t get_number_of_cells(Dimensions_t *dimensions)
Definition: dimensions.c:652
CellIndex_t last_layer(Dimensions_t *dimensions)
Definition: dimensions.c:470
CellIndex_t first_layer(Dimensions_t *dimensions)
CellIndex_t first_column(Dimensions_t *dimensions)
CellIndex_t get_layer_area(Dimensions_t *dimensions)
Definition: dimensions.c:666
CellIndex_t first_row(Dimensions_t *dimensions)
CellIndex_t last_row(Dimensions_t *dimensions)
Definition: dimensions.c:442
Error_t fill_sources_floorplan(Floorplan_t *floorplan, Source_t *sources)
Definition: floorplan.c:267
Error_t insert_power_values_floorplan(Floorplan_t *floorplan, PowersQueue_t *pvalues)
Definition: floorplan.c:298
Capacity_t get_spreader_capacity(HeatSink_t *hsink)
Definition: heat_sink.c:377
SolidTC_t get_thermal_conductivity(Layer_t *layer, CellIndex_t row_index, CellIndex_t column_index, Dimensions_t *dimensions)
Definition: layer.c:187
#define IS_CHANNEL_COLUMN(channel_model, column)
Definition: macros.h:101
void power_grid_fill(PowerGrid_t *pgrid, ThermalGrid_t *tgrid, StackElementList_t *list, Dimensions_t *dimensions)
Definition: power_grid.c:222
Error_t insert_power_values(PowerGrid_t *pgrid, PowersQueue_t *pvalues)
Definition: power_grid.c:1002
void update_channel_sources(PowerGrid_t *pgrid, Dimensions_t *dimensions)
Definition: power_grid.c:928
Error_t power_grid_build(PowerGrid_t *pgrid, Dimensions_t *dimensions)
Definition: power_grid.c:64
Error_t update_source_vector(PowerGrid_t *pgrid, Dimensions_t *dimensions)
Definition: power_grid.c:528
void power_grid_init(PowerGrid_t *pgrid)
Definition: power_grid.c:46
void power_grid_destroy(PowerGrid_t *pgrid)
Definition: power_grid.c:202
bool is_empty_powers_queue(PowersQueue_t *pqueue)
Definition: powers_queue.c:190
Power_t get_from_powers_queue(PowersQueue_t *pqueue)
Definition: powers_queue.c:244
Coolant_t Coolant
Definition: channel.h:106
ChannelModel_t ChannelModel
Definition: channel.h:74
Temperature_t TIn
Definition: coolant.h:97
CellIndex_t SourceLayerOffset
Definition: die.h:81
Floorplan_t Floorplan
Definition: die.h:94
LayerList_t Layers
Definition: die.h:90
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
GridDimensions_t Grid
Definition: dimensions.h:318
uint8_t NonUniform
Definition: dimensions.h:326
Non_uniform_cellList_t Cell_list
Definition: dimensions.h:337
Structure containing information about a floorplan element.
PowersQueue_t * PowerValues
ICElementList_t ICElements
The floorplan representing the IC as a set of floorplan elements.
Definition: floorplan.h:69
Power_t * Bpowers
Definition: floorplan.h:90
FloorplanElementList_t ElementsList
Definition: floorplan.h:80
CellIndex_t NLayers
Definition: dimensions.h:173
Temperature_t AmbientTemperature
Definition: heat_sink.h:82
CellIndex_t NColumns
Definition: heat_sink.h:114
HeatSinkModel_t SinkModel
Definition: heat_sink.h:72
AmbientHTC_t AmbientHTC
Definition: heat_sink.h:77
CellIndex_t NRows
Definition: heat_sink.h:110
Structure used to store data about the power sources.
Definition: power_grid.h:70
StackLayerType_t * LayersTypeProfile
Definition: power_grid.h:85
CellIndex_t NCells
Definition: power_grid.h:77
HeatSink_t * BottomHeatSink
Definition: power_grid.h:105
Floorplan_t ** FloorplansProfile
Definition: power_grid.h:89
Source_t * Sources
Definition: power_grid.h:93
Channel_t * Channel
Definition: power_grid.h:97
CellIndex_t NCellsLayer
Definition: power_grid.h:81
CellIndex_t NLayers
Definition: power_grid.h:73
SolidTC_t * HeatSinkBottomTcs
Definition: power_grid.h:121
HeatSink_t * TopHeatSink
Definition: power_grid.h:101
Capacity_t * CellsCapacities
Definition: power_grid.h:129
SolidTC_t * HeatSinkTopTcs
Definition: power_grid.h:113
A First In - First Out circular queue to store power values.
Definition: powers_queue.h:63
Structure used to store data about the stack element that compose the 2D/3D stack.
Definition: stack_element.h:93
StackElement_p Pointer
HeatSink_t * TopSink
CellIndex_t Offset
StackElementType_t SEType
HeatSink_t * BottomSink
Structure used to store data about the thermal cells / RC nodes.
Definition: thermal_grid.h:68
HeatSink_t * TopHeatSink
Definition: thermal_grid.h:88
Layer_t * LayersProfile
Definition: thermal_grid.h:80
Capacity_t get_capacity(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: thermal_grid.c:425
Conductance_t get_conductance_top(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
Definition: thermal_grid.c:904
Capacity_t get_capacity_non_uniform(ThermalGrid_t *tgrid, Dimensions_t *dimensions, Non_uniform_cellListNode_t *i_cell)
Definition: thermal_grid.c:326
Conductance_t get_conductance_bottom(ThermalGrid_t *tgrid, Dimensions_t *dimensions, CellIndex_t layer_index, CellIndex_t row_index, CellIndex_t column_index)
double Capacity_t
Definition: types.h:119
Error_t
Definition: types.h:401
@ TDICE_SUCCESS
The function returns with success.
Definition: types.h:402
@ TDICE_FAILURE
The function retuerns with a generic error.
Definition: types.h:403
StackLayerType_t
Definition: types.h:243
@ TDICE_LAYER_CHANNEL_2RM
Definition: types.h:286
@ TDICE_LAYER_CHANNEL_4RM
Definition: types.h:282
@ TDICE_LAYER_SOURCE_CONNECTED_TO_SPREADER
Definition: types.h:274
@ TDICE_LAYER_SOLID_CONNECTED_TO_AMBIENT
Definition: types.h:258
@ TDICE_LAYER_SOLID_CONNECTED_TO_SPREADER
Definition: types.h:262
@ TDICE_LAYER_NONE
Definition: types.h:246
@ TDICE_LAYER_SOURCE_CONNECTED_TO_PCB
Definition: types.h:278
@ TDICE_LAYER_PINFINS_STAGGERED
Definition: types.h:294
@ TDICE_LAYER_SOLID
Definition: types.h:250
@ TDICE_LAYER_SOLID_CONNECTED_TO_PCB
Definition: types.h:266
@ TDICE_LAYER_SOURCE
Definition: types.h:254
@ TDICE_LAYER_SOURCE_CONNECTED_TO_AMBIENT
Definition: types.h:270
@ TDICE_LAYER_PINFINS_INLINE
Definition: types.h:290
@ TDICE_LAYER_BOTTOM_WALL
Definition: types.h:310
@ TDICE_LAYER_VWALL_CHANNEL
Definition: types.h:298
@ TDICE_LAYER_VWALL_PINFINS
Definition: types.h:302
@ TDICE_LAYER_TOP_WALL
Definition: types.h:306
double SolidTC_t
Definition: types.h:107
@ TDICE_CHANNEL_MODEL_PF_INLINE
Inline pin fins - 2 Resistors model.
Definition: types.h:350
@ TDICE_CHANNEL_MODEL_PF_STAGGERED
Staggered pin fins - 2 Resistors model.
Definition: types.h:351
@ TDICE_CHANNEL_MODEL_NONE
Undefined type.
Definition: types.h:347
@ TDICE_CHANNEL_MODEL_MC_4RM
Microchannel - 4 Resistors model.
Definition: types.h:348
@ TDICE_CHANNEL_MODEL_MC_2RM
Microchannel - 2 Resistors model.
Definition: types.h:349
double Source_t
Definition: types.h:77
@ TDICE_STACK_ELEMENT_NONE
Undefined type.
Definition: types.h:326
@ TDICE_STACK_ELEMENT_LAYER
Layer.
Definition: types.h:327
@ TDICE_STACK_ELEMENT_CHANNEL
Channel.
Definition: types.h:328
@ TDICE_STACK_ELEMENT_DIE
Die.
Definition: types.h:329
uint32_t Quantity_t
Definition: types.h:59
uint32_t CellIndex_t
Definition: types.h:213
@ TDICE_HEATSINK_TOP
Top heat sink (top-most layer)
Definition: types.h:226
@ TDICE_HEATSINK_TOP_PLUGGABLE
Top pluggable heat sink.
Definition: types.h:228
Channel_t * Channel
Definition: stack_element.h:74