[cfe-dev] Clang OpenCL errors and warnings

Bader, Alexey via cfe-dev cfe-dev at lists.llvm.org
Wed May 13 03:13:59 PDT 2020


Hi Enrique,

First error is occurred because default OpenCL C version is 1.0 (or 1.1) and it doesn’t support double precision floating point types. If the target hardware supports doubles, the error can be fixed by either enable `cl_khr_fp64` extension support (-cl-ext=-cl_khr_fp64) or by setting OpenCL C version to 1.2 (-cl-std=CL1.2).

'../Programs/kernels/longest/longest_0038.cl:28:19: warning: incompatible pointer to integer conversion initializing 'const __private int' with an expression of type '__global int *' [-Wint-conversion]
        const int v = a + f * 2 + l % v;'

This warning says that “a + f * 2 + l %v;” expression has `__global int *` type i.e. global address space pointer and assigning it to integer value is not safe. This looks like a bug in the code. One of the variables in the expression (`a`?) is a pointer, which probably should be dereferenced (*a or a[id]).

Also, I would use the driver to compile OpenCL code (i.e. invoke clang without `-cc1` option) if you don’t have reasons to use the front-end.
User’s Manual covers most of the OpenCL options: https://clang.llvm.org/docs/UsersManual.html#opencl-features.

Thanks,
Alexey

From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Enrique Gonzalez via cfe-dev
Sent: Tuesday, May 12, 2020 2:41 PM
To: cfe-dev at lists.llvm.org
Subject: [cfe-dev] Clang OpenCL errors and warnings

Hello everyone,

I am using Clang 11 for an OpenCL-SPIRV project.

When I try to convert some OpenCL programs into bytecode, I receive the following error message in some of them:
'../Programs/kernels/longest/longest_0038.cl:19:5: error: use of type 'double' requires cl_khr_fp64 extension to be enabled
    double const t = 2 * (h + 2);'

Also, I receive some warnings like:
'../Programs/kernels/longest/longest_0038.cl:28:19: warning: incompatible pointer to integer conversion initializing 'const __private int' with an expression of type '__global int *' [-Wint-conversion]
        const int v = a + f * 2 + l % v;'

This OpenCL codes are automatically generated by a tool called "clgen" from github, that I am using as my OpenCL source code database.

This errors and warnings are given because the code is not well written or because I need to use more flags in my clang command?

I use  this command to convert OpenCL programs into bytecode:
'clang -cc1 -triple spir64 -emit-llvm-bc -finclude-default-header -cl-single-precision-constant -disable-llvm-passes INPUT.cl -o INPUT.bc'

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200513/67405a3d/attachment-0001.html>


More information about the cfe-dev mailing list