Merged float and int kernel with Macros. The float4 kernel is specific to 1 channel and Intel.
Merging that creates more macros and cluttered code. Is it ok to keep it separate.

From: Alexander Alekhin [mailto:notifications@github.com]
Sent: Monday, April 14, 2014 7:57 AM
To: Itseez/opencv
Cc: Ravunnikutty, Girish
Subject: Re: [opencv] Pullreq/140319 bilateral b (#2612)


In modules/imgproc/src/opencl/bilateral.cl:

> +        for (int k = 0; k < maxk; k++ )

> +        {

> +            float_t val = convert_float_t(loadpix(src + src_index + space_ofs[k]));

> +            float i = SUM(fabs(val - val0));

> +            float w = space_weight[k] * native_exp(i * i * as_float(gauss_color_coeff));

> +            sum += val * w;

> +            wsum += w;

> +        }

> +        storepix(convert_uchar_t(sum / (float_t)(wsum)), dst + dst_index);

> +    }

> +}

> +

> +//for single channgel x4 sized images.

> +__kernel void bilateral_float4(__global const uchar * src, int src_step, int src_offset,

> +                               __global uchar * dst, int dst_step, int dst_offset, int dst_rows, int dst_cols,

> +                               __constant float * space_weight, __constant int * space_ofs)

It is very hard to maintain copy-pasted code from the different places. So we prefer to have single kernel with templated datatypes (float_t) and operations (convert_uchar_t).
It will be great to have optimizations with minimal changes.

—
Reply to this email directly or view it on GitHub<https://github.com/Itseez/opencv/pull/2612/files#r11588141>.