Hi,
You need to include OpenCL library headers from libclc
(http://libclc.llvm.org/) to compile most OpenCL code.
Here is an example command:
clang -include /path/to/libclc/headers/clc.h -I /path/to/libclc/headers -Dcl_clang_storage_class_specifiers -target amdgcn--amdhsa -mcpu=carrizo $INPUT_FILE -o $OUTPUT_FILE
-Tom
> - Paweł
> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hi Tom,
to piggy-pack on this question. To load this kernel in OpenCL, is it sufficient to just pass $OUTPUT_FILE
to clCreateProgramWithBinary?
Also, assuming this is enough. Is the code quality for recent AMD GPUs quality-wise on the level of what AMD's closed-source driver would generate.
Thank you,
Tobias
Hi Tobias,
The are currently no OpenCL runtimes that can load the AMDGPU binaries
emitted by clang. If you want to use OpenCL with the AMDGPU backend,
you will need to install Mesa[0], enable OpenCL support[1], and use the
OpenCL API to compile the OpenCL C code.
You can however load AMDGPU binaries using the hsa-runtime.
Take a look at the example code in my repo[2]. Note that this requires that
you build lld along with llvm and clang.
> Also, assuming this is enough. Is the code quality for recent AMD GPUs quality-wise on the level of what AMD's closed-source driver would generate.
>
I haven't done a lot of comparisons, so the best answer I can give is 'not as good'.
The main feature that is missing is OpenCL images. We support OpenGL images,
but they just haven't been wired up yet to the OpenCL builtin library.
There is experimental assembler / inline assembly support for AMDGPU in clang, so
you could always write a kernel in assembly if you are concerned about performance.
-Tom
[0] http://cgit.freedesktop.org/mesa/mesa/
[1] http://dri.freedesktop.org/wiki/GalliumCompute/
[2] https://github.com/tstellarAMD/hsa-runtime/tree/kalmar-150911/samples/hello_world
OK, thank you Tom for this information!