1 __global__ void kernel_convoSepShx8pV(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 the base point
11 int j = (__umul24(blockIdx.x,blockDim.x) + threadIdx.x)<<3 ;
12 int i = __umul24( blockIdx.y, blockDim.y) + threadIdx.y ;
13 // absolute index in the image
14 int idx = __umul24(i,j_dim) + j ;
15 // offset of one ROI row in shared memory
16 int idrow = threadIdx.y*bdimX ;
18 extern __shared__ unsigned char roi8p[];
22 roi8p[ idrow + tidX +p ] = tex2D(tex_img_inc, j+p , i-r) ;
25 if ( threadIdx.y < k-1 )
27 idrow = (threadIdx.y+blockDim.y)*bdimX ;
28 for (int p=0; p<8; p++)
29 roi8p[ idrow + tidX +p ] = tex2D( tex_img_inc, j+p , i+blockDim.y-r ) ;
33 // vertical convolution
34 for (ic=0 ; ic<k ; ic++)
36 int baseRoi = __umul24(ic+threadIdx.y,bdimX) + tidX ;
37 float valMask = mask[ ic ] ;
38 outval0 += valMask*roi8p[ baseRoi ] ;
39 outval1 += valMask*roi8p[ baseRoi +1 ] ;
40 outval2 += valMask*roi8p[ baseRoi +2 ] ;
41 outval3 += valMask*roi8p[ baseRoi +3 ] ;
42 outval4 += valMask*roi8p[ baseRoi +4 ] ;
43 outval5 += valMask*roi8p[ baseRoi +5 ] ;
44 outval6 += valMask*roi8p[ baseRoi +6 ] ;
45 outval7 += valMask*roi8p[ baseRoi +7 ] ;
48 // 8 pixels per thread --> global mem
49 output[ idx++ ] = outval0 ;
50 output[ idx++ ] = outval1 ;
51 output[ idx++ ] = outval2 ;
52 output[ idx++ ] = outval3 ;
53 output[ idx++ ] = outval4 ;
54 output[ idx++ ] = outval5 ;
55 output[ idx++ ] = outval6 ;
56 output[ idx++ ] = outval7 ;