c - effective parallelisation of bilinear interpolation using OpenMP -
i want parallelise bilinear interpolation using openmp in such way there should least memory access of input array. in code below, each iteration of , j in output array, input data according longitude , latitude values read , processed.
- input[20][20] - input array contains data values eg{1,2,3,..,400} in 2d
- lon[100][100] - longitudinal positions of each interpolation point in output array in horizontal axis not equidistant. eg. {2.34,2.65,2.74... }
- lat[100][100] - latitudinal positions of each interpolation point in output array in vertical axis not equidistant.eg. {5.76,5.92,6.26... }
- output[100][100] - array containing interpolated values
void interpolate(float (*lon)[100] ,float (*lat)[100] , float (*input)[20],float (*output)[100]) {
int i,j,floori,floorj; float fractionj,fractioni; for(j = 0; j < 100; j++) { for(i = 0; < 100; i++) { floori = lon[i][j]; fractioni = lon[i][j] - floori; floorj = lat[i][j]; fractionj = lat[i][j] - floorj; output[i][j] = (1.0-fractioni)*(1.0-fractionj)*input[floori][floorj] + fractioni*(1.0-fractionj)*input[floori+1][floorj] + (1.0-fractioni)*fractionj*input[floori][floorj+1] + fractioni * fractionj *input[floori+1][floorj+1]; } }
}
i need divide work in such way interpolation points specified using lon , lat values within block of input[floori][floorj],input[floori+1][floorj],input[floori][floorj+1],input[floori+1][floorj+1] should go 1 thread input values read once memory register each thread.