// // This file is part of the Bones source-to-source compiler examples. This C-code // demonstrates the use of Bones for an example application: 'Speckle Reducing // Anisotropic Diffusion' or 'SRAD', taken from the Rodinia benchmark suite. For // more information on the application or on Bones please use the contact infor- // mation below. // // == More information on SRAD (Speckle Reducing Anisotropic Diffusion): // Article............http://dx.doi.org/10.1109/TIP.2002.804276 // 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/srad.c // Authors............Cedric Nugteren // Original authors...Rob Janiczek, Drew Gilliam, Lukasz Szafaryn // Last modified on...10-Aug-2012 // //######################################################################## //### Includes //######################################################################## #include #include #include //######################################################################## //### Defines //######################################################################## #define ROWS 128 // Number of ROWS in the domain #define COLS 128 // Number of COLS in the domain #define R1 0 // y1 position of the speckle #define R2 31 // y2 position of the speckle #define C1 0 // x1 position of the speckle #define C2 31 // x2 position of the speckle #define LAMBDA 0.5 // Lambda value #define NITER 2 // Number of iterations //######################################################################## //### Start of the main function //######################################################################## int main(void) { // Declare the loop iterators int i,j,iter; // Declare domain variables float mean_roi, var_roi; float q0s, qs; float divergence; float cN, cS, cW, cE; float G2, L; // Declare other/helper variables int index; float temp_value; float sum1, sum2; float current_value; float temp_a, temp_b; // Check for valid row and column sizes if ((ROWS%16 != 0 ) || (COLS%16 != 0)) { printf("[srad] Error: the number of rows and columns must be multiples of 16\n"); fflush(stdout); exit(1); } // Initialising memory printf("\n[srad] Initialising memory"); fflush(stdout); int size = COLS*ROWS; int size_roi = (R2-R1+1)*(C2-C1+1); float* values = (float*) malloc(sizeof(float)*size); float* coefficent = (float*) malloc(sizeof(float)*size); float* dN = (float*) malloc(sizeof(float)*size); float* dS = (float*) malloc(sizeof(float)*size); float* dW = (float*) malloc(sizeof(float)*size); float* dE = (float*) malloc(sizeof(float)*size); // Populate the input matrix printf("\n[srad] Populating the input matrix with random values"); fflush(stdout); for (i=0; i 1) { coefficent[index] = 1; } } } // Iterate over the full image again and compute the final values for (i=0; i