Skip to content

Commit

Permalink
ipp_countNonZero build fix;
Browse files Browse the repository at this point in the history
Removed IPP port for tiny arithm.cpp functions

Additional warnings fix on various platforms.

Build without OPENCL and GCC warnings fixed

Fixed warnings, trailing spaces and removed unused secure_cpy.

IPP code refactored.

IPP code path  implemented as separate static functions to simplify future work with IPP code and make it more readable.
Dmitry Budnikov authored and Pavel Vlasov committed Jun 18, 2015
1 parent b1a8e4f commit a5a2101
Showing 20 changed files with 2,635 additions and 2,307 deletions.
1 change: 1 addition & 0 deletions modules/core/include/opencv2/core/base.hpp
Original file line number Diff line number Diff line change
@@ -305,6 +305,7 @@ enum BorderTypes {
#define CV_SUPPRESS_DEPRECATED_START
#define CV_SUPPRESS_DEPRECATED_END
#endif
#define CV_UNUSED(name) (void)name
//! @endcond

/*! @brief Signals an error and raises the exception.
58 changes: 58 additions & 0 deletions modules/core/include/opencv2/core/private.hpp
Original file line number Diff line number Diff line change
@@ -235,9 +235,67 @@ static inline IppDataType ippiGetDataType(int depth)
# define IPP_VERSION_X100 0
#endif

#ifdef HAVE_IPP_ICV_ONLY
#define HAVE_ICV 1
#else
#define HAVE_ICV 0
#endif


#define CV_IPP_CHECK_COND (cv::ipp::useIPP())
#define CV_IPP_CHECK() if(CV_IPP_CHECK_COND)

#ifdef HAVE_IPP

#ifdef CV_IPP_RUN_VERBOSE
#define CV_IPP_RUN_(condition, func, ...) \
{ \
if (cv::ipp::useIPP() && (condition) && func) \
{ \
printf("%s: IPP implementation is running\n", CV_Func); \
fflush(stdout); \
CV_IMPL_ADD(CV_IMPL_IPP); \
return __VA_ARGS__; \
} \
else \
{ \
printf("%s: Plain implementation is running\n", CV_Func); \
fflush(stdout); \
} \
}
#elif defined CV_IPP_RUN_ASSERT
#define CV_IPP_RUN_(condition, func, ...) \
{ \
if (cv::ipp::useIPP() && (condition)) \
{ \
if(func) \
{ \
CV_IMPL_ADD(CV_IMPL_IPP); \
} \
else \
{ \
setIppErrorStatus(); \
CV_Error(cv::Error::StsAssert, #func); \
} \
return __VA_ARGS__; \
} \
}
#else
#define CV_IPP_RUN_(condition, func, ...) \
if (cv::ipp::useIPP() && (condition) && func) \
{ \
CV_IMPL_ADD(CV_IMPL_IPP); \
return __VA_ARGS__; \
}
#endif

#else
#define CV_IPP_RUN_(condition, func, ...)
#endif

#define CV_IPP_RUN(condition, func, ...) CV_IPP_RUN_(condition, func, __VA_ARGS__)


#ifndef IPPI_CALL
# define IPPI_CALL(func) CV_Assert((func) >= 0)
#endif
96 changes: 57 additions & 39 deletions modules/core/src/convert.cpp
Original file line number Diff line number Diff line change
@@ -5194,17 +5194,9 @@ dtype* dst, size_t dstep, Size size, double* scale) \
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
{ \
CV_IPP_CHECK()\
if (src && dst)\
{\
if (src && dst)\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \
{\
CV_IMPL_ADD(CV_IMPL_IPP)\
return; \
}\
setIppErrorStatus(); \
}\
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0)\
}\
cvt_(src, sstep, dst, dstep, size); \
}
@@ -5213,17 +5205,9 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
{ \
CV_IPP_CHECK()\
if (src && dst)\
{\
if (src && dst)\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \
{\
CV_IMPL_ADD(CV_IMPL_IPP)\
return; \
}\
setIppErrorStatus(); \
}\
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0)\
}\
cvt_(src, sstep, dst, dstep, size); \
}
@@ -5907,6 +5891,55 @@ class LUTParallelBody : public ParallelLoopBody

}

namespace cv
{
#if defined(HAVE_IPP)
static bool ipp_lut(InputArray _src, InputArray _lut, OutputArray _dst)
{
int cn = _src.channels();
int lutcn = _lut.channels();

Mat src = _src.getMat(), lut = _lut.getMat();
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
Mat dst = _dst.getMat();

if (_src.dims() <= 2)
{
bool ok = false;
Ptr<ParallelLoopBody> body;

size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
#if 0 // there are no performance benefits (PR #2653)
if (lutcn == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
body.reset(p);
}
else
#endif
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
body.reset(p);
}

if (body != NULL && ok)
{
Range all(0, dst.rows);
if (dst.total()>>18)
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16));
else
(*body)(all);
if (ok)
return true;
}
}
return false;
}
#endif
}


void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
{
int cn = _src.channels(), depth = _src.depth();
@@ -5919,6 +5952,10 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2,
ocl_LUT(_src, _lut, _dst))

CV_IPP_RUN((_src.dims() <= 2 && ((lutcn == 1 || lutcn == 3 || lutcn == 4) && CV_ELEM_SIZE1(_dst.depth()) == 1) && lutcn != 1), //lutcn == 1 ipp implementation switched off
ipp_lut(_src, _lut, _dst));


Mat src = _src.getMat(), lut = _lut.getMat();
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
Mat dst = _dst.getMat();
@@ -5927,25 +5964,6 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
{
bool ok = false;
Ptr<ParallelLoopBody> body;
#if defined(HAVE_IPP)
CV_IPP_CHECK()
{
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
#if 0 // there are no performance benefits (PR #2653)
if (lutcn == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
body.reset(p);
}
else
#endif
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
body.reset(p);
}
}
#endif
if (body == NULL || ok == false)
{
ok = false;
Loading

0 comments on commit a5a2101

Please sign in to comment.