first attemp

pull/2628/head
Ilya Lavrenov 11 years ago
parent e11d998cfb
commit f3c56f8310
  1. 3
      modules/core/include/opencv2/core/base.hpp
  2. 28
      modules/core/src/arithm.cpp
  3. 2
      modules/core/src/convert.cpp
  4. 1
      modules/core/src/copy.cpp
  5. 3
      modules/core/src/precomp.hpp
  6. 10
      modules/core/src/system.cpp
  7. 3
      modules/ts/include/opencv2/ts.hpp
  8. 89
      modules/ts/include/opencv2/ts/ts_ext.hpp
  9. 3
      modules/ts/include/opencv2/ts/ts_perf.hpp

@ -560,6 +560,9 @@ namespace cudev
template <typename _Tp> class GpuMat_;
}
CV_EXPORTS void setIppStatus(int status);
CV_EXPORTS int getIppStatus();
} // cv
#endif //__OPENCV_CORE_BASE_HPP__

@ -464,6 +464,7 @@ static void add8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpAdd<uchar>, IF_SIMD(VAdd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -483,6 +484,7 @@ static void add16u( const ushort* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<ushort, OpAdd<ushort>, IF_SIMD(VAdd<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -495,6 +497,7 @@ static void add16s( const short* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<short, OpAdd<short>, IF_SIMD(VAdd<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -514,6 +517,7 @@ static void add32f( const float* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp32<float, OpAdd<float>, IF_SIMD(VAdd<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -533,6 +537,7 @@ static void sub8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpSub<uchar>, IF_SIMD(VSub<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -552,6 +557,7 @@ static void sub16u( const ushort* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<ushort, OpSub<ushort>, IF_SIMD(VSub<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -564,6 +570,7 @@ static void sub16s( const short* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppStatus(-1);
#endif
(vBinOp<short, OpSub<short>, IF_SIMD(VSub<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -583,6 +590,7 @@ static void sub32f( const float* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp32<float, OpSub<float>, IF_SIMD(VSub<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -617,6 +625,7 @@ static void max8u( const uchar* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp<uchar, OpMax<uchar>, IF_SIMD(VMax<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -648,6 +657,7 @@ static void max16u( const ushort* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp<ushort, OpMax<ushort>, IF_SIMD(VMax<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -686,6 +696,7 @@ static void max32f( const float* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp32<float, OpMax<float>, IF_SIMD(VMax<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -717,6 +728,7 @@ static void min8u( const uchar* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp<uchar, OpMin<uchar>, IF_SIMD(VMin<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -748,6 +760,7 @@ static void min16u( const ushort* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp<ushort, OpMin<ushort>, IF_SIMD(VMin<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -786,6 +799,7 @@ static void min32f( const float* src1, size_t step1,
}
if (i == sz.height)
return;
setIppStatus(-1);
#endif
vBinOp32<float, OpMin<float>, IF_SIMD(VMin<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -802,9 +816,11 @@ static void absdiff8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
printf("!\n");
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpAbsDiff<uchar>, IF_SIMD(VAbsDiff<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -821,9 +837,11 @@ static void absdiff16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
printf("!\n");
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<ushort, OpAbsDiff<ushort>, IF_SIMD(VAbsDiff<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -847,9 +865,11 @@ static void absdiff32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
printf("!\n");
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp32<float, OpAbsDiff<float>, IF_SIMD(VAbsDiff<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -870,6 +890,7 @@ static void and8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpAnd<uchar>, IF_SIMD(VAnd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -882,6 +903,7 @@ static void or8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpOr<uchar>, IF_SIMD(VOr<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -894,6 +916,7 @@ static void xor8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpXor<uchar>, IF_SIMD(VXor<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -906,6 +929,7 @@ static void not8u( const uchar* src1, size_t step1,
fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2;
if (0 <= ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz)))
return;
setIppStatus(-1);
#endif
(vBinOp<uchar, OpNot<uchar>, IF_SIMD(VNot<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -2390,6 +2414,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppStatus(-1);
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2473,6 +2498,7 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppStatus(-1);
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2488,6 +2514,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppStatus(-1);
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2594,6 +2621,7 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppStatus(-1);
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);

@ -1086,6 +1086,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
{ \
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \
return; \
setIppStatus(-1); \
cvt_(src, sstep, dst, dstep, size); \
}
@ -1095,6 +1096,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
{ \
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \
return; \
setIppStatus(-1); \
cvt_(src, sstep, dst, dstep, size); \
}
#else

@ -574,6 +574,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
IppStatus status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis);
if (status >= 0)
return;
setIppStatus(-1);
}
#endif

@ -235,13 +235,14 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl
struct CoreTLSData
{
CoreTLSData() : device(0), useOpenCL(-1)
CoreTLSData() : device(0), useOpenCL(-1), ippStatus(0)
{}
RNG rng;
int device;
ocl::Queue oclQueue;
int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized
int ippStatus; // 0 - all is ok, -1 - IPP functions failed
};
extern TLSData<CoreTLSData> coreTlsData;

@ -1063,6 +1063,16 @@ TLSStorage::~TLSStorage()
TLSData<CoreTLSData> coreTlsData;
void setIppStatus(int status)
{
coreTlsData.get()->ippStatus = status;
}
int getIppStatus()
{
return coreTlsData.get()->ippStatus;
}
} // namespace cv
/* End of file. */

@ -25,6 +25,7 @@
#define GTEST_DONT_DEFINE_TEST 0
#include "opencv2/ts/ts_gtest.h"
#include "opencv2/ts/ts_ext.hpp"
#ifndef GTEST_USES_SIMPLE_RE
# define GTEST_USES_SIMPLE_RE 0
@ -553,7 +554,7 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true);
#endif
#endif
#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE)
#if defined(HAVE_OPENCL)
namespace cvtest { namespace ocl {
void dumpOpenCLDevice();
}}

@ -0,0 +1,89 @@
#ifndef __OPENCV_TS_EXT_HPP__
#define __OPENCV_TS_EXT_HPP__
#define CHECK_IPP_STATUS \
do \
{ \
EXPECT_LE(0, getIppStatus()); \
} while ((void)0, 0)
#undef TEST
#define TEST(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public ::testing::Test {\
public:\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody();\
virtual void Body();\
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
};\
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
#test_case_name, #test_name, NULL, NULL, \
(::testing::internal::GetTestTypeId()), \
::testing::Test::SetUpTestCase, \
::testing::Test::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#undef TEST_F
#define TEST_F(test_fixture, test_name)\
class GTEST_TEST_CLASS_NAME_(test_fixture, test_name) : public test_fixture {\
public:\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name)() {}\
private:\
virtual void TestBody();\
virtual void Body(); \
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name));\
};\
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_fixture, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
#test_fixture, #test_name, NULL, NULL, \
(::testing::internal::GetTypeId<test_fixture>()), \
test_fixture::SetUpTestCase, \
test_fixture::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body()
#undef TEST_P
#define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
: public test_case_name { \
public: \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
private: \
virtual void Body(); \
virtual void TestBody(); \
static int AddToRegistry() { \
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
GetTestCasePatternHolder<test_case_name>(\
#test_case_name, __FILE__, __LINE__)->AddTestPattern(\
#test_case_name, \
#test_name, \
new ::testing::internal::TestMetaFactory< \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
return 0; \
} \
static int gtest_registering_dummy_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
}; \
int GTEST_TEST_CLASS_NAME_(test_case_name, \
test_name)::gtest_registering_dummy_ = \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#endif // __OPENCV_TS_EXT_HPP__

@ -3,6 +3,7 @@
#include "opencv2/core.hpp"
#include "ts_gtest.h"
#include "ts_ext.hpp"
#include <functional>
@ -512,7 +513,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
#endif
#endif
#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE)
#ifdef HAVE_OPENCL
namespace cvtest { namespace ocl {
void dumpOpenCLDevice();
}}

Loading…
Cancel
Save