added norm_inf support to minmaxloc kernel
This commit is contained in:
@@ -41,10 +41,15 @@
|
||||
|
||||
#if kercn != 3
|
||||
#define loadpix(addr) *(__global const srcT *)(addr)
|
||||
#define srcTSIZE (int)sizeof(srcT1)
|
||||
#define srcTSIZE (int)sizeof(srcT)
|
||||
#else
|
||||
#define loadpix(addr) vload3(0, (__global const srcT1 *)(addr))
|
||||
#define srcTSIZE ((int)sizeof(srcT1))
|
||||
#define srcTSIZE ((int)sizeof(srcT1) * 3)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MASK
|
||||
#undef srcTSIZE
|
||||
#define srcTSIZE (int)sizeof(srcT1)
|
||||
#endif
|
||||
|
||||
#ifdef NEED_MINLOC
|
||||
@@ -106,7 +111,12 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
|
||||
{
|
||||
int lid = get_local_id(0);
|
||||
int gid = get_group_id(0);
|
||||
int id = get_global_id(0) * kercn;
|
||||
int id = get_global_id(0)
|
||||
#ifndef HAVE_MASK
|
||||
* kercn;
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
srcptr += src_offset;
|
||||
#ifdef HAVE_MASK
|
||||
@@ -150,7 +160,11 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
|
||||
dstT temp2;
|
||||
#endif
|
||||
|
||||
for (int grain = groupnum * WGS * kercn; id < total; id += grain)
|
||||
for (int grain = groupnum * WGS
|
||||
#ifndef HAVE_MASK
|
||||
* kercn
|
||||
#endif
|
||||
; id < total; id += grain)
|
||||
{
|
||||
#ifdef HAVE_MASK
|
||||
#ifdef HAVE_MASK_CONT
|
||||
|
||||
@@ -543,32 +543,9 @@
|
||||
#define CALC_RESULT \
|
||||
storepix(localmem[0], dstptr + dstTSIZE * gid)
|
||||
|
||||
// norm (NORM_INF) with cn > 1 and mask
|
||||
#elif defined OP_NORM_INF_MASK
|
||||
|
||||
#define DECLARE_LOCAL_MEM \
|
||||
__local srcT localmem_max[WGS2_ALIGNED]
|
||||
#define DEFINE_ACCUMULATOR \
|
||||
srcT maxval = MIN_VAL, temp
|
||||
#define REDUCE_GLOBAL \
|
||||
MASK_INDEX; \
|
||||
if (mask[mask_index]) \
|
||||
{ \
|
||||
temp = loadpix(srcptr + src_index); \
|
||||
maxval = max(maxval, (srcT)(temp >= (srcT)(0) ? temp : -temp)); \
|
||||
}
|
||||
#define SET_LOCAL_1 \
|
||||
localmem_max[lid] = maxval
|
||||
#define REDUCE_LOCAL_1 \
|
||||
localmem_max[lid - WGS2_ALIGNED] = max(maxval, localmem_max[lid - WGS2_ALIGNED])
|
||||
#define REDUCE_LOCAL_2 \
|
||||
localmem_max[lid] = max(localmem_max[lid], localmem_max[lid2])
|
||||
#define CALC_RESULT \
|
||||
storepix(localmem_max[0], dstptr + dstTSIZE * gid)
|
||||
|
||||
#else
|
||||
#error "No operation"
|
||||
#endif // end of norm (NORM_INF) with cn > 1 and mask
|
||||
#endif
|
||||
|
||||
#ifdef OP_DOT
|
||||
#undef EXTRA_PARAMS
|
||||
|
||||
Reference in New Issue
Block a user