Repository: opencv
Issue: OpenCL related test failures on MacOS 10.14 (AppleClang 10.0)
Labels: bug,priority: low,platform: ios/osx,category: ocl

<!--
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

Please:

* Read the documentation to test with the latest developer build.
* Check if other person has already created the same issue to avoid duplicates. You can comment on it if there already is an issue.
* Try to be as detailed as possible in your report.
* Report only one problem per created issue.


This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 3.1
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
-->

- OpenCV => 4.0.1
- Operating System / Platform => macOS 10.14.2 (18C54)
- Compiler => Apple LLVM version 10.0.0 (clang-1000.10.44.4)

Hardware (as reported by opencv tests)
```
OpenCL Platforms: 
    Apple
        CPU: Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz (OpenCL 1.2 )
        iGPU: Intel(R) UHD Graphics 630 (OpenCL 1.2 )
Current OpenCL device: 
    Type = iGPU
    Name = Intel(R) UHD Graphics 630
    Version = OpenCL 1.2 
    Driver version = 1.2(Nov 26 2018 20:27:30)
```
##### Detailed description

* **opencv_test_gapi** produces the following errors:
```
[  FAILED  ] 32 tests, listed below:
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/5, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 125, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/4, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 125, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/6, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 125, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/7, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 125, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/12, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 240, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/13, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 240, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/14, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 240, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/15, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 3, 240, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/20, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 125, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/21, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 125, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/22, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 125, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/23, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 125, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/28, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 240, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/29, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 240, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/30, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 240, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/31, where GetParam() = (48-byte object ..., 8UC1, 1280x720, 120, 240, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/36, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 125, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/37, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 125, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/38, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 125, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/39, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 125, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/44, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 240, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/45, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 240, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/46, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 240, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/47, where GetParam() = (48-byte object ..., 8UC1, 640x480, 3, 240, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/52, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 125, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/53, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 125, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/54, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 125, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/55, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 125, 5, true, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/60, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 240, 5, false, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/61, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 240, 5, false, true, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/62, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 240, 5, true, false, { 32-byte object ... })
[  FAILED  ] CannyTestGPU/CannyTest.AccuracyTest/63, where GetParam() = (48-byte object ..., 8UC1, 640x480, 120, 240, 5, true, true, { 32-byte object ... })
```

In all the cases above the error is similar to this below:
```
2-7F 00-00 70-C8 A8-A4 A2-7F 00-00>, 8UC1, 640x480, 3, 240, 5, false, true, { 32-byte object <26-67 61-70 69-2E 6B-65 72-6E 65-6C 5F-70 61-63 6B-61 67-65 00-00 00-00 90-8E 47-A4 A2-7F 00-00> })
AbsSimilarPoints error: err_points=116124  max_err_points=15360 (total=307200)  diff_tolerance=0
opencv/modules/gapi/test/common/gapi_imgproc_tests_inl.hpp:407: Failure
Value of: cmpF(out_mat_gapi, out_mat_ocv)
  Actual: false
Expected: true
```

* **opencv_test_imgproc** produces the following errors:

```
[  FAILED  ] OCL_ImgProc/Canny.Accuracy/4, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(false))
[  FAILED  ] OCL_ImgProc/Canny.Accuracy/5, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(true))
[  FAILED  ] OCL_ImgProc/Canny.Accuracy/6, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(true), UseRoi(false))
[  FAILED  ] OCL_ImgProc/Canny.Accuracy/7, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(true), UseRoi(true))
[  FAILED  ] OCL_ImgProc/Canny.AccuracyCustomGradient/4, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(false))
[  FAILED  ] OCL_ImgProc/Canny.AccuracyCustomGradient/5, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(true))
[  FAILED  ] OCL_ImgProc/Canny.AccuracyCustomGradient/6, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(true), UseRoi(false))
[  FAILED  ] OCL_ImgProc/Canny.AccuracyCustomGradient/7, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(true), UseRoi(true))
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/0, where GetParam() = (CV_8U, Channels(1), BORDER_CONSTANT, false, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/2, where GetParam() = (CV_8U, Channels(1), BORDER_CONSTANT, true, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/4, where GetParam() = (CV_8U, Channels(1), BORDER_REPLICATE, false, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/6, where GetParam() = (CV_8U, Channels(1), BORDER_REPLICATE, true, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/8, where GetParam() = (CV_8U, Channels(1), BORDER_REFLECT, false, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/10, where GetParam() = (CV_8U, Channels(1), BORDER_REFLECT, true, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/12, where GetParam() = (CV_8U, Channels(1), BORDER_REFLECT_101, false, false)
[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/14, where GetParam() = (CV_8U, Channels(1), BORDER_REFLECT_101, true, false)
```

The errors are as below:
```
[ RUN      ] OCL_ImgProc/Canny.AccuracyCustomGradient/5, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(true))
opencv/modules/imgproc/test/ocl/test_canny.cpp:126: Failure
Expected: (checkSimilarity(dst_roi, udst_roi)) <= (eps), actual: 0.428767 vs 0.03
Size: [512 x 480]

opencv/modules/imgproc/test/ocl/test_canny.cpp:127: Failure
Expected: (checkSimilarity(dst, udst)) <= (eps), actual: 0.428351 vs 0.03
Size: [514 x 556]

[  FAILED  ] OCL_ImgProc/Canny.AccuracyCustomGradient/5, where GetParam() = (Channels(1), ApertureSize(5), L2gradient(false), UseRoi(true)) (14 ms)
```
```
[ RUN      ] OCL_ImageProc/SepFilter2D.Mat/6, where GetParam() = (CV_8U, Channels(1), BORDER_REPLICATE, true, false)
opencv/modules/imgproc/test/ocl/test_sepfilter2d.cpp:105: Failure
Expected: (TestUtils::checkNorm2(dst_roi, udst_roi)) <= (threshold), actual: 78 vs 1
Size: [60 x 51]

[  FAILED  ] OCL_ImageProc/SepFilter2D.Mat/6, where GetParam() = (CV_8U, Channels(1), BORDER_REPLICATE, true, false) (4 ms)
```

In both cases the errors go away if I run the tests with environment variable: `OPENCV_OPENCL_DEVICE=disabled`
##### Steps to reproduce
Just let it build with the defaults
```
  OpenCL:                        YES (no extra features)
    Include path:                NO
    Link libraries:              -framework OpenCL
```