first attemp
authorIlya Lavrenov <ilya.lavrenov@itseez.com>
Wed, 16 Apr 2014 11:34:18 +0000 (15:34 +0400)
committerIlya Lavrenov <ilya.lavrenov@itseez.com>
Thu, 17 Apr 2014 07:07:01 +0000 (11:07 +0400)
modules/core/include/opencv2/core/base.hpp
modules/core/src/arithm.cpp
modules/core/src/convert.cpp
modules/core/src/copy.cpp
modules/core/src/precomp.hpp
modules/core/src/system.cpp
modules/ts/include/opencv2/ts.hpp
modules/ts/include/opencv2/ts/ts_ext.hpp [new file with mode: 0644]
modules/ts/include/opencv2/ts/ts_perf.hpp

index e9187faba47af48d5db140b081461958fcedf8df..ba5c8fe872661e386d6c86b691a3daafbf4cb6aa 100644 (file)
@@ -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__
index b74678ca671899da545ffe9a855f7c3e055427da..190bdf98f949a99c2d4c884123dce9d83f39d447 100644 (file)
@@ -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);
index 155ca67d6f2258a5b4f923d7961a44cd2290bbef..3d3f1aa62b66d5bfb1ff9b51aea24069f9aa0439 100644 (file)
@@ -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
index 202e7a92256b3cd8c41684fd2fcd9c4c5fb3982a..6a1ff4b3cb1b6ffae5dc24bb3efb6e41f85b5b61 100644 (file)
@@ -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
 
index 1c498cd012bffeb62c31fd61855481aab45cbf09..37e4a34944488da1e5cdeb364061b28f454e1153 100644 (file)
@@ -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;
index cef4db3c2c782e7f4b6849be1cfbc11b5d3f9edd..cf4b986537328786b25ce2f2dc64726b6cc573dd 100644 (file)
@@ -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. */
index 8aeec6571277f6fa80eaed5628bd5b3ee754ab08..07f9845b7632b9c4f7be6925d2e20ee654a9846e 100644 (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();
 }}
diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp
new file mode 100644 (file)
index 0000000..14541fe
--- /dev/null
@@ -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__
index 62e9e1471fcf79d7a67ac3c49754199541056f58..33265568b9613fe3d60fa6bd6057da615ac480f3 100644 (file)
@@ -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();
 }}