Repository: opencv
Issue: OCL sepFilter2D and Scharr freeze for several minutes
Labels: bug,category: imgproc,platform: android,category: ocl

### System Information

OpenCV version: 4.10.0 (appeared earlier?)
Device: Nothing Phone 2
OS: Android 14
CPU: Qualcomm Snapdragon 8+ Gen1
iGPU: QUALCOMM Adreno(TM) (OpenCL 3.0 Adreno(TM) 730)

### Detailed description

There are two test cases at which `cv::sepFilter2D` and `cv::Scharr()` misbehave, i.e. freeze for about 240 secs (Scharr) or 60 secs (sepFilter2D) and quit with wrong results.

In both cases they invoke OpenCL version and freeze [at the same place](https://github.com/opencv/opencv/blob/e4bcd46f64ee44b10a21cbd048bb428a83f9f417/modules/imgproc/src/filter.dispatch.cpp#L849) after running `col_filter` kernel.

The test cases are:

 * `OCL_Filter/Scharr3x3_cols16_rows2.Mat/26, where GetParam() = (8UC1, 0, 1x0, BORDER_REFLECT, 0.2, false, 1)`
   - full ROI of size 16x30
   - kernel arguments:
   ```
   -D RADIUSY=1 -D LSIZE0=16 -D LSIZE1=10 -D CN=1 -D srcT=float -D dstT=uchar
   -D convertToFloatT=noconvert -D floatT=float -D convertToDstT=convert_uchar_sat_rte 
   -D srcT1=float -D dstT1=uchar -D SHIFT_BITS=0
   -D COEFF=DIG(0.6000000238f)DIG(2.000000000f)DIG(0.6000000238f)
   ```
* `OCL_ImageProc/SepFilter2D.Mat/10, where GetParam() = (CV_8U, Channels(1), BORDER_REFLECT, true, false)`
  - full ROI of size 60x51
  - kernel arguments:
  ```
  -D RADIUSY=3 -D LSIZE0=16 -D LSIZE1=10 -D CN=1 -D srcT=float -D dstT=uchar
  -D convertToFloatT=noconvert -D floatT=float -D convertToDstT=convert_uchar_sat_rte
  -D srcT1=float -D dstT1=uchar -D SHIFT_BITS=0
  -D COEFF=DIG(0.008996695280f)DIG(-0.01206895430f)DIG(0.3683320880f)DIG(-0.1414978057f)DIG(-0.1748190373f)DIG(-0.1139794663f)DIG(-0.1803059429f)
  ```

The root cause is still unclear to me:
* I've found only two such cases, no idea why these specific 2 cases among several hundreds
* Changing local group size or turning off barriers does not change the behavior
* All attempts to run this code with hardware sanitizer enabled result in an immediate segfault even before the first test is started

### Steps to reproduce

Build OpenCV for ARM Android, upload binaries to device and run the tests.

CMake flags for build:
```
WITH_OPENCL : true
ANDROID_ABI : "arm64-v8a"
ANDROID_SDK : "~/Android/Sdk"
ANDROID_NDK : "~/Android/Sdk/ndk/26.1.10909125"
CMAKE_TOOLCHAIN_FILE : "~/Android/Sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake"
BUILD_ANDROID_PROJECTS : false
```
Upload binary:
```
adb push ${OpenCV_build_directory}/bin/opencv_test_imgproc /data/local/tmp
```
Run:
```
adb shell '/data/local/tmp/opencv_test_imgproc --gtest_filter=*OCL_ImageProc/SepFilter2D.Mat/10'
```

```
adb shell '/data/local/tmp/opencv_test_imgproc --gtest_filter=*OCL_Filter/Scharr3x3_cols16_rows2.Mat/26'
```


### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)