__global__ void kernel_convoSepShx8pH(unsigned char *output, int j_dim, int r) { int ic, jc, p; int k = 2*r+1 ; float outval0=0.0, outval1=0.0, outval2=0.0, outval3=0.0 ; float outval4=0.0, outval5=0.0, outval6=0.0, outval7=0.0 ; int bdimX = blockDim.x<<3 ; // all packets width int tidX = threadIdx.x<<3 ; // one packet offset // absolute coordinates of one packet base point int j = (__umul24(blockIdx.x,blockDim.x) + threadIdx.x)<<3 ; int i = __umul24( blockIdx.y, blockDim.y) + threadIdx.y ; int j0= __umul24(blockIdx.x,blockDim.x)<<3 ; // absolute index in the image int idx = __umul24(i,j_dim) + j ; // offset of one ROI row in shared memory int idrow = threadIdx.y*(bdimX+k-1) ; extern __shared__ unsigned char roi8p[]; // top left block for (p=0; p<8; p++) roi8p[ idrow + tidX +p ] = tex2D(tex_img_inc, j-r+p , i) ; // top right block if ( threadIdx.x < r ) { roi8p[ idrow + bdimX + threadIdx.x ] = tex2D( tex_img_inc, j0-r +bdimX+threadIdx.x , i ) ; roi8p[ idrow + bdimX + threadIdx.x +r ] = tex2D( tex_img_inc, j0 +bdimX+threadIdx.x , i ) ; } __syncthreads(); // horizontal convolution for (jc=0 ; jc global mem output[ idx++ ] = outval0 ; output[ idx++ ] = outval1 ; output[ idx++ ] = outval2 ; output[ idx++ ] = outval3 ; output[ idx++ ] = outval4 ; output[ idx++ ] = outval5 ; output[ idx++ ] = outval6 ; output[ idx ] = outval7 ; }