// // This file is part of the Bones source-to-source compiler examples. This C-code // demonstrates the use of Bones for an example application: 'Hotspot', taken from // the Rodinia benchmark suite. For more information on the application or on Bones // please use the contact information below. // // == More information on Hotspot // Article............http://dx.doi.org/10.1109/TVLSI.2006.876103 // Original code......https://www.cs.virginia.edu/~skadron/wiki/rodinia/ // // == More information on Bones // Contact............Cedric Nugteren // Web address........http://parse.ele.tue.nl/bones/ // // == File information // Filename...........applications/hotspot.c // Authors............Cedric Nugteren // Last modified on...10-Aug-2012 // //######################################################################## //### Includes //######################################################################## #include #include #include //######################################################################## //### Input parameters //######################################################################## #define GRID_ROWS 64 // Number of rows in the grid (positive integer) #define GRID_COLS 64 // Number of columns in the grid (positive integer) #define SIM_TIME 2 // Number of iterations #define TEMPERATURE_FILE "data/hotspot_temperature_64.txt" // Name of the file containing the initial temperature values of each cell #define POWER_FILE "data/hotspot_power_64.txt" // Name of the file containing the dissipated power values of each cell //######################################################################## //### Defines //######################################################################## #define STRING_SIZE 256 // Length of the strings in the temperature and power files #define MAX_PD (3.0e6) // Maximum power density possible (say 300W for a 10mm x 10mm chip) #define PRECISION 0.001 // Required precision in degrees #define SPEC_HEAT_SI 1.75e6 // #define K_SI 100 // #define FACTOR_CHIP 0.5 // Capacitance fitting factor #define T_CHIP 0.0005 // Chip temperature #define CHIP_HEIGHT 0.016 // Chip height #define CHIP_WIDTH 0.016 // Chip width #define AMB_TEMP 80.0 // Ambient temperature, assuming no package at all //######################################################################## //### Forward declarations //######################################################################## void read_input(double* array, const char* filename); //######################################################################## //### Start of the main function //######################################################################## int main(void) { // Declare the loop iterators int r,c,iter; // Declare other/helper variables int index; double delta; int row = GRID_ROWS; int col = GRID_COLS; double grid_height = CHIP_HEIGHT/row; double grid_width = CHIP_WIDTH/col; // Set domain variables double cap = FACTOR_CHIP*SPEC_HEAT_SI*T_CHIP*grid_width*grid_height; double Rx = grid_width / (2.0*K_SI*T_CHIP*grid_height); double Ry = grid_height / (2.0*K_SI*T_CHIP*grid_width); double Rz = T_CHIP / (K_SI*grid_height*grid_width); double max_slope = MAX_PD / (FACTOR_CHIP*T_CHIP*SPEC_HEAT_SI); double step = PRECISION / max_slope; // Initialising memory printf("\n[hotspot] Initialising memory"); fflush(stdout); double* temperature = (double*) calloc(row*col, sizeof(double)); double* power = (double*) calloc(row*col, sizeof(double)); double* result = (double*) calloc(row*col, sizeof(double)); // Read initial temperature and power arrays printf("\n[hotspot] Populating memory"); fflush(stdout); read_input(temperature, TEMPERATURE_FILE); read_input(power, POWER_FILE); // Perform the computation a given number of times printf("\n[hotspot] Performing the computation %d times",SIM_TIME); fflush(stdout); #pragma scop for (iter=0; iter