siposcsaba89 / stereo-sgm-opencl

SGM implementation
56 stars 15 forks source link

OpenCL build info: BC-src-code:179:20: error: '__local' can only appear in __kernel functions at function scope #6

Closed YeahTech closed 1 year ago

YeahTech commented 3 years ago

hi, When i run this code with opencl 2.0, i get the following error.

`Platform name: QUALCOMM Snapdragon(TM) Device name: QUALCOMM Adreno(TM) OpenCL build info: BC-src-code:179:20: error: 'local' can only appear in kernel functions at function scope local uint32_t local_min_shared[BLOCK_SIZE]; ^ 1 diagnostic(s) generated.

opencl error : Error at /local/mnt/workspace/lnxbuild/project/trees_in_use/free_tree_dir/checkout/build-qti-distro-ubuntu-fullstack-perf/tmp-glibc/work/qrb5165_rb5-oe-linux/adreno/1.0-r0/adreno200/cb/src/cb_program.c:1322: Function clCompileProgram raised CL_BUILD_PROGRAM_FAILURE. Build QUALCOMM build: commit # changeid # Date: 03/03/21 Wed Local Branch: Remote Branch: from Mar 3 2021 14:04:20. terminate called after throwing an instance of 'std::runtime_error' what(): Cannot build ocl program! Aborted `

But when i run this code with opencl 2.2, it is successful. Can you tell me the resion? I will be very grateful for that.

siposcsaba89 commented 3 years ago

Hi @yaoxinghua,

The compiler is correct here, I violated the opencl specification when declared a local variable in function code and not in kernel code: https://github.com/siposcsaba89/stereo-sgm-opencl/blob/4344a4b780f211e92096cc3e26e2fa63c7f9ba33/src/ocl/path_aggregation_common.cl#L30 . You can fix this by adding a new parameter to the update function, and declare the variable at kernel scope, from where this function is called and pass it as a function argument. I will fix this when I will have time, unfortunately nvidia and amd opencl compilers accepted it.

Sorry for the inconvenience.

OpenCL "local" manual page: https://www.khronos.org/registry/OpenCL/sdk/2.2/docs/man/html/local.html