[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 11:25:22 PST 2017


Anastasia added inline comments.


================
Comment at: docs/UsersManual.rst:2065
+
+     $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl
+
----------------
pekka.jaaskelainen wrote:
> Is this correct? I cannot make it work:
> 
> ```
> ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang -finclude-default-header -emit-llvm -cc1 -triple spir64-unknown-unknown kernel/test_halfs.cl -c -S -o -
> clang-4.0: error: unknown argument: '-cc1'
> clang-4.0: error: unknown argument: '-triple'
> clang-4.0: error: no such file or directory: 'spir64-unknown-unknown'
> ```
> 
> -target works instead. (But reveals another issue, there's no printf() declaration, should I file a bug?)
> 
> ```
> ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang -finclude-default-header -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o -
> kernel/test_halfs.cl:10:9: warning: implicit declaration of function 'printf' is invalid in C99 [-Wimplicit-function-declaration]
>         printf("max(a,b)[0] type=uint2 a=0x15b348c9 b=0xf88e7d07 want=0xf88e7d07 got=%x\n", max_[0]);
>         ^
> kernel/test_halfs.cl:10:9: error: function with no prototype cannot use the spir_function calling convention
> 1 warning and 1 error generated.
> ```
> 
> With 3.9 that kernel which calls printf() passes:
> ```
> /local/stow/llvm-3.9-debug/bin/clang -Xclang -finclude-default-header -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o -
> ; ModuleID = 'kernel/test_halfs.cl'
> source_filename = "kernel/test_halfs.cl"
> target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
> target triple = "spir64-unknown-unknown"
> ....
> ```
> 
> 
> 
It should be -triple with -cc1 and -target without.

  clang -cc1 -triple ...
  clang -target ...

We have disabled the C99 builtin functions as per spec v1.2 s6.9.f, but the OpenCL builtins should be available via the header now.

As I can see declaration of printf is in the header under CL1.2 and higher.

Could you try this command instead:
  clang -std=CL1.2 test.cl -Xclang -finclude-default-header



https://reviews.llvm.org/D28080





More information about the cfe-commits mailing list