1 __global__ void kernel_convoSepShx8pH(unsigned char *output, int j_dim, int r)
5 float outval0=0.0, outval1=0.0, outval2=0.0, outval3=0.0 ;
6 float outval4=0.0, outval5=0.0, outval6=0.0, outval7=0.0 ;
7 int bdimX = blockDim.x<<3 ; // all packets width
8 int tidX = threadIdx.x<<3 ; // one packet offset
10 // absolute coordinates of one packet base point
11 int j = (__umul24(blockIdx.x,blockDim.x) + threadIdx.x)<<3 ;
12 int i = __umul24( blockIdx.y, blockDim.y) + threadIdx.y ;
13 int j0= __umul24(blockIdx.x,blockDim.x)<<3 ;
14 // absolute index in the image
15 int idx = __umul24(i,j_dim) + j ;
17 // offset of one ROI row in shared memory
18 int idrow = threadIdx.y*(bdimX+k-1) ;
20 extern __shared__ unsigned char roi8p[];
24 roi8p[ idrow + tidX +p ] = tex2D(tex_img_inc, j-r+p , i) ;
26 if ( threadIdx.x < r )
28 roi8p[ idrow + bdimX + threadIdx.x ] = tex2D( tex_img_inc, j0-r +bdimX+threadIdx.x , i ) ;
29 roi8p[ idrow + bdimX + threadIdx.x +r ] = tex2D( tex_img_inc, j0 +bdimX+threadIdx.x , i ) ;
34 // horizontal convolution
35 for (jc=0 ; jc<k ; jc++)
37 int baseRoi = idrow + tidX +jc ;
38 float valMask = mask[ jc ] ;
39 outval0 += valMask*roi8p[ baseRoi ] ;
40 outval1 += valMask*roi8p[ baseRoi +1 ] ;
41 outval2 += valMask*roi8p[ baseRoi +2 ] ;
42 outval3 += valMask*roi8p[ baseRoi +3 ] ;
43 outval4 += valMask*roi8p[ baseRoi +4 ] ;
44 outval5 += valMask*roi8p[ baseRoi +5 ] ;
45 outval6 += valMask*roi8p[ baseRoi +6 ] ;
46 outval7 += valMask*roi8p[ baseRoi +7 ] ;
49 // 8 pixels per thread --> global mem
50 output[ idx++ ] = outval0 ;
51 output[ idx++ ] = outval1 ;
52 output[ idx++ ] = outval2 ;
53 output[ idx++ ] = outval3 ;
54 output[ idx++ ] = outval4 ;
55 output[ idx++ ] = outval5 ;
56 output[ idx++ ] = outval6 ;
57 output[ idx++ ] = outval7 ;