Relax accuracy requirements in the OpenCL sqrt perf arithmetic test.
authorAaron Greig <aaron.greig@codeplay.com>
Wed, 31 Mar 2021 09:16:19 +0000 (10:16 +0100)
committerAaron Greig <aaron.greig@codeplay.com>
Tue, 6 Apr 2021 16:32:48 +0000 (17:32 +0100)
Also bring perf_imgproc CornerMinEigenVal accuracy requirements in line with
the test_imgproc accuracy requirements on that test and fix indentation on
the latter.

Partially addresses issue #9821

modules/core/perf/opencl/perf_arithm.cpp
modules/imgproc/perf/opencl/perf_imgproc.cpp
modules/imgproc/test/ocl/test_imgproc.cpp

index 9f5f6e9e772d3076284fc152b1d5d031e2190a99..0cbfc2d653d9b5da24b83ce4a72b4fe3e0b41c31 100644 (file)
@@ -678,7 +678,12 @@ OCL_PERF_TEST_P(SqrtFixture, Sqrt, ::testing::Combine(
 
     OCL_TEST_CYCLE() cv::sqrt(src, dst);
 
-    if (CV_MAT_DEPTH(type) >= CV_32F)
+    // To square root 32 bit floats we use native_sqrt, which has implementation
+    // defined accuracy. We know intel devices have accurate native_sqrt, but
+    // otherwise stick to a relaxed sanity check. For types larger than 32 bits
+    // we can do the accuracy check for all devices as normal.
+    if (CV_MAT_DEPTH(type) > CV_32F || !ocl::useOpenCL() ||
+        ocl::Device::getDefault().isIntel())
         SANITY_CHECK(dst, 1e-5, ERROR_RELATIVE);
     else
         SANITY_CHECK(dst, 1);
index 4b61976553da629836ed83188b303a929a67cb91..db4c4ef451aea35303ad2773615645360f326af3 100644 (file)
@@ -166,7 +166,17 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
 
     OCL_TEST_CYCLE() cv::cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
 
-    SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+#ifdef HAVE_OPENCL
+    bool strictCheck = !ocl::useOpenCL() || ocl::Device::getDefault().isIntel();
+#else
+    bool strictCheck = true;
+#endif
+
+    // using native_* OpenCL functions on non-intel devices may lose accuracy
+    if (strictCheck)
+        SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
+    else
+        SANITY_CHECK(dst, 0.1, ERROR_RELATIVE);
 }
 
 ///////////// CornerHarris ////////////////////////
index 35185d339fbbaca7183f36d9156ebaff09a9cf70..f3e9f4bb2002d5f2d39410d52ce7d040f1a1d397 100644 (file)
@@ -234,10 +234,12 @@ OCL_TEST_P(CornerMinEigenVal, Mat)
         OCL_OFF(cv::cornerMinEigenVal(src_roi, dst_roi, blockSize, apertureSize, borderType));
         OCL_ON(cv::cornerMinEigenVal(usrc_roi, udst_roi, blockSize, apertureSize, borderType));
 
-        if (ocl::Device::getDefault().isIntel())
-          Near(1e-5, true);
+        // The corner kernel uses native_sqrt() which has implementation defined accuracy.
+        // If we're using a CL implementation that isn't intel, test with relaxed accuracy.
+        if (!ocl::useOpenCL() || ocl::Device::getDefault().isIntel())
+            Near(1e-5, true);
         else
-          Near(0.1, true);  // using native_* OpenCL functions may lose accuracy
+            Near(0.1, true);
     }
 }