optimized cv::countNonZero

This commit is contained in:
Ilya Lavrenov
2014-05-28 18:39:02 +04:00
parent 7804d57f8b
commit 002a79bfc4
2 changed files with 42 additions and 7 deletions

View File

@@ -645,7 +645,7 @@ namespace cv {
static bool ocl_countNonZero( InputArray _src, int & res )
{
int type = _src.type(), depth = CV_MAT_DEPTH(type);
int type = _src.type(), depth = CV_MAT_DEPTH(type), kercn = ocl::predictOptimalVectorWidth(_src);
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
if (depth == CV_64F && !doubleSupport)
@@ -660,9 +660,10 @@ static bool ocl_countNonZero( InputArray _src, int & res )
wgs2_aligned >>= 1;
ocl::Kernel k("reduce", ocl::core::reduce_oclsrc,
format("-D srcT=%s -D OP_COUNT_NON_ZERO -D WGS=%d "
"-D WGS2_ALIGNED=%d%s%s",
ocl::typeToStr(type), (int)wgs,
format("-D srcT=%s -D srcT1=%s -D cn=1 -D OP_COUNT_NON_ZERO -D WGS=%d "
"-D kercn=%d -D WGS2_ALIGNED=%d%s%s",
ocl::typeToStr(CV_MAKE_TYPE(depth, kercn)),
ocl::typeToStr(depth), (int)wgs, kercn,
wgs2_aligned, doubleSupport ? " -D DOUBLE_SUPPORT" : "",
_src.isContinuous() ? " -D HAVE_SRC_CONT" : ""));
if (k.empty())